00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "config.h"
00021
00022 #include <stdlib.h>
00023 #include <stdio.h>
00024 #include <string.h>
00025
00026
00027 #include "conf.h"
00028
00029
00030 config_t *config = NULL;
00031
00032 config_t *config_new(void)
00033 {
00034 config_t *newconfig = calloc(1, sizeof(config_t));
00035 if(!newconfig) {
00036 fprintf(stderr, "malloc failure: could not allocate %zd bytes\n",
00037 sizeof(config_t));
00038 return(NULL);
00039 }
00040
00041 newconfig->op = PM_OP_MAIN;
00042 newconfig->logmask = PM_LOG_ERROR | PM_LOG_WARNING;
00043
00044 newconfig->configfile = strdup(CONFFILE);
00045 newconfig->rootdir = NULL;
00046 newconfig->dbpath = NULL;
00047 newconfig->logfile = NULL;
00048
00049 return(newconfig);
00050 }
00051
00052 int config_free(config_t *oldconfig)
00053 {
00054 if(oldconfig == NULL) {
00055 return(-1);
00056 }
00057
00058 free(oldconfig->configfile);
00059 free(oldconfig->rootdir);
00060 free(oldconfig->dbpath);
00061 free(oldconfig->logfile);
00062 free(oldconfig);
00063 oldconfig = NULL;
00064
00065 return(0);
00066 }
00067
00068