207 ObjectConfig *conf = p; |
207 ObjectConfig *conf = p; |
208 |
208 |
209 begin->type = cfg_get_line_type(line); |
209 begin->type = cfg_get_line_type(line); |
210 switch(begin->type) { |
210 switch(begin->type) { |
211 case LINE_BEGIN_TAG: { |
211 case LINE_BEGIN_TAG: { |
212 ConfigTag *tag = cfg_parse_begin_tag(line, conf->parser.mp); |
212 ConfigTag *tag = cfg_parse_begin_tag(line, conf->parser.a); |
213 if(tag == NULL) { |
213 if(tag == NULL) { |
214 ws_cfg_log(LOG_FAILURE, "Parse error in %s", conf->file); |
214 ws_cfg_log(LOG_FAILURE, "Parse error in %s", conf->file); |
215 exit(-1); // TODO: better error handling |
215 exit(-1); // TODO: better error handling |
216 } |
216 } |
217 tag->begin = begin; |
217 tag->begin = begin; |
234 break; |
234 break; |
235 } |
235 } |
236 case LINE_DIRECTIVE: { |
236 case LINE_DIRECTIVE: { |
237 ConfigDirective *dir = cfg_parse_directive( |
237 ConfigDirective *dir = cfg_parse_directive( |
238 line, |
238 line, |
239 conf->parser.mp); |
239 conf->parser.a); |
240 dir->begin = begin; |
240 dir->begin = begin; |
241 dir->end = end; |
241 dir->end = end; |
242 if(objconf_on_directive(conf, dir) != 0) { |
242 if(objconf_on_directive(conf, dir) != 0) { |
243 fprintf(stderr, "3error\n"); |
243 fprintf(stderr, "3error\n"); |
244 exit(-1); |
244 exit(-1); |
247 } |
247 } |
248 return 0; |
248 return 0; |
249 } |
249 } |
250 |
250 |
251 int objconf_on_begin_tag(ObjectConfig *conf, ConfigTag *tag) { |
251 int objconf_on_begin_tag(ObjectConfig *conf, ConfigTag *tag) { |
252 CxAllocator *mp = conf->parser.mp; |
252 CxAllocator *mp = conf->parser.a; |
253 if(tag->type_num != TAG_OBJECT) { |
253 if(tag->type_num != TAG_OBJECT) { |
254 ConfigParserLevel *l = conf->levels; |
254 ConfigParserLevel *l = conf->levels; |
255 if(l->tag->type_num != TAG_OBJECT) { |
255 if(l->tag->type_num != TAG_OBJECT) { |
256 tag->parent = l->tag; |
256 tag->parent = l->tag; |
257 } |
257 } |
303 // create tree level object |
303 // create tree level object |
304 ConfigParserLevel *last_lvl = conf->levels; |
304 ConfigParserLevel *last_lvl = conf->levels; |
305 tag->iftag = last_lvl->iftag; |
305 tag->iftag = last_lvl->iftag; |
306 |
306 |
307 ConfigParserLevel *lvl = OBJ_NEW( |
307 ConfigParserLevel *lvl = OBJ_NEW( |
308 conf->parser.mp, |
308 conf->parser.a, |
309 ConfigParserLevel); |
309 ConfigParserLevel); |
310 |
310 |
311 lvl->iftag = last_lvl->tag; |
311 lvl->iftag = last_lvl->tag; |
312 lvl->levelnum = last_lvl->levelnum + 1; |
312 lvl->levelnum = last_lvl->levelnum + 1; |
313 lvl->tag = tag; |
313 lvl->tag = tag; |
370 conf->parser.mp, |
370 conf->parser.mp, |
371 conf->obj->directives[dir->type_num], |
371 conf->obj->directives[dir->type_num], |
372 dir); |
372 dir); |
373 */ |
373 */ |
374 |
374 |
375 ConfigDirectiveList *dir_entry = cxMalloc(conf->parser.mp, sizeof(ConfigDirectiveList)); |
375 ConfigDirectiveList *dir_entry = cxMalloc(conf->parser.a, sizeof(ConfigDirectiveList)); |
376 dir_entry->directive = dir; |
376 dir_entry->directive = dir; |
377 dir_entry->next = NULL; |
377 dir_entry->next = NULL; |
378 CFG_DIRECTIVES_ADD(&conf->obj->directives[dir->type_num], dir_entry); |
378 CFG_DIRECTIVES_ADD(&conf->obj->directives[dir->type_num], dir_entry); |
379 |
379 |
380 return 0; |
380 return 0; |