From e9e9684117719204929821028ba9dbb7915ea119 Mon Sep 17 00:00:00 2001 From: kraxel Date: Sun, 28 Mar 2004 11:31:57 +0000 Subject: Initial revision --- idaconfig.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 idaconfig.c (limited to 'idaconfig.c') 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 +#include +#include +#include +#include + +#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); +} -- cgit