~ubuntu-branches/debian/jessie/debfoster/jessie

« back to all changes in this revision

Viewing changes to src/conffile.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Weimer
  • Date: 2008-04-19 17:14:49 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080419171449-mhjgd507macjerdh
Tags: 2.7-1
New upstream version.  Closes: #448501.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
static AVLTree *options = NULL;
31
31
 
32
 
static void set_string(const char **holder, const char *val) {
33
 
        if(*holder) free((char *)*holder);
34
 
        *holder = xstrdup(val);
35
 
}
36
 
 
37
32
#define StringConfigVal(s) const char *s = NULL; \
38
 
        static void set_##s(const char *str) { set_string(&s, str); }
 
33
        static void set_##s(const char *str) { s = xstrdup(str); }
39
34
 
40
35
static void set_bool(int *holder, const char *val) {
41
36
        if(!strcasecmp(val, "y") || !strcasecmp(val, "yes")
101
96
                perror_exit(ERROR_CONFIG, key);
102
97
}
103
98
 
104
 
static void free_option(option_t opt) {
105
 
        if(opt) {
106
 
                if(opt->key)
107
 
                        free((char *)opt->key);
108
 
                free(opt);
109
 
        }
110
 
}
111
 
 
112
99
void readconfig(const char *config) {
113
100
        FILE *f;
114
101
        char buf[READBUF];
119
106
        if(!config)
120
107
                config = CONFIG_FILE;
121
108
 
122
 
        if(options)
123
 
                AVLFreeNodes(options);
124
 
        else
125
 
                options = AVLAllocTree((AVLCompare)optcmp, (AVLFreeItem)free_option);
 
109
        options = AVLAllocTree((AVLCompare)optcmp);
126
110
 
127
111
        /* Seed tree with defaults for all options */
128
112
        add_option("KeeperFile",    set_KeeperFile,    KEEPERS);