diff options
author | kraxel <kraxel> | 2004-03-28 11:31:57 +0000 |
---|---|---|
committer | kraxel <kraxel> | 2004-03-28 11:31:57 +0000 |
commit | e9e9684117719204929821028ba9dbb7915ea119 (patch) | |
tree | 6dd2d71940b33a9f960945335e9124ef4fea9fe7 /idaconfig.c | |
download | fbida-e9e9684117719204929821028ba9dbb7915ea119.tar.gz |
Initial revision
Diffstat (limited to 'idaconfig.c')
-rw-r--r-- | idaconfig.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/idaconfig.c b/idaconfig.c new file mode 100644 index 0000000..56b97d8 --- /dev/null +++ b/idaconfig.c @@ -0,0 +1,51 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <sys/stat.h> + +#include "idaconfig.h" + +char *ida_lists; +static char *ida_config; + +void ida_init_config(void) +{ + char *home; + char *conf; + struct stat st; + + home = getenv("HOME"); + if (NULL == home) + return; + + conf = malloc(strlen(home) + 16); + ida_lists = malloc(strlen(home) + 16); + ida_config = malloc(strlen(home) + 16); + sprintf(conf, "%s/.ida", home); + sprintf(ida_lists, "%s/.ida/lists", home); + sprintf(ida_config,"%s/.ida/config", home); + + if (-1 == stat(ida_lists,&st)) { + if (-1 == stat(conf,&st)) + mkdir(conf,0777); + mkdir(ida_lists,0777); + } + free(conf); +} + +void ida_read_config(void) +{ + int rc; + + rc = cfg_parse_file("config", ida_config); + if (-1 == rc) { + /* set some defaults */ + cfg_set_str(O_BOOKMARKS, "Home", getenv("HOME")); + } +} + +void ida_write_config(void) +{ + cfg_write_file("config", ida_config); +} |