src/server/config/initconf.c

changeset 91
fac51f87def0
parent 88
73b3485e96f1
child 95
74a81d9e19d0
equal deleted inserted replaced
90:279f343bbf6c 91:fac51f87def0
42 conf->parser.parse = initconf_parse; 42 conf->parser.parse = initconf_parse;
43 conf->file = file; 43 conf->file = file;
44 conf->directives = NULL; 44 conf->directives = NULL;
45 45
46 int r = cfg_parse_basic_file((ConfigParser*)conf, in); 46 int r = cfg_parse_basic_file((ConfigParser*)conf, in);
47 cfg_dlist_destr(conf->parser.mp, conf->directives);
48 if(r != 0) { 47 if(r != 0) {
49 free_init_config(conf); 48 free_init_config(conf);
50 return NULL; 49 return NULL;
51 } 50 }
52 fclose(in); 51 fclose(in);
53 52
54 return conf; 53 return conf;
55 } 54 }
56 55
57 void free_init_config(InitConfig *conf) { 56 void free_init_config(InitConfig *conf) {
58 ucx_mempool_destroy(conf->parser.mp); 57 ucx_mempool_destroy(conf->parser.mp->pool);
59 free(conf); 58 free(conf);
60 } 59 }
61 60
62 int initconf_parse(void *p, ConfigLine *begin, ConfigLine *end, sstr_t line) { 61 int initconf_parse(void *p, ConfigLine *begin, ConfigLine *end, sstr_t line) {
63 InitConfig *conf = p; 62 InitConfig *conf = p;
69 return 0; 68 return 0;
70 } 69 }
71 d->begin = begin; 70 d->begin = begin;
72 d->end = end; 71 d->end = end;
73 if(d->type_num == 6) { 72 if(d->type_num == 6) {
74 conf->directives = ucx_dlist_append(conf->directives, d); 73 conf->directives = ucx_list_append(conf->directives, d);
75 } else { 74 } else {
76 fprintf(stderr, "Warning: Non Init directive in init.conf\n"); 75 fprintf(stderr, "Warning: Non Init directive in init.conf\n");
77 } 76 }
78 77
79 return 0; 78 return 0;

mercurial