1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#include <stdio.h>
#include <stdlib.h>
#include <stddef.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);
}
|