src/server/config/conf.c

changeset 576
5c31cc844c68
parent 453
4586d534f9b5
child 579
e10457d74fe1
equal deleted inserted replaced
575:bbca8e94fa67 576:5c31cc844c68
34 int cfg_parse_basic_file(ConfigParser *parser, FILE *in) { 34 int cfg_parse_basic_file(ConfigParser *parser, FILE *in) {
35 parser->lines_begin = NULL; 35 parser->lines_begin = NULL;
36 parser->lines_end = NULL; 36 parser->lines_end = NULL;
37 CxMempool *mp = cxBasicMempoolCreate(512); 37 CxMempool *mp = cxBasicMempoolCreate(512);
38 CxAllocator *a = (CxAllocator*)mp->allocator; 38 CxAllocator *a = (CxAllocator*)mp->allocator;
39 parser->mp = a; 39 parser->a = a;
40 parser->mp = mp;
40 41
41 // one logical line over many lines 42 // one logical line over many lines
42 cxmutstr mline; 43 cxmutstr mline;
43 mline.ptr = NULL; 44 mline.ptr = NULL;
44 mline.length = 0; 45 mline.length = 0;
49 cxmutstr l; 50 cxmutstr l;
50 while((l = cfg_readln(in)).ptr != NULL) { 51 while((l = cfg_readln(in)).ptr != NULL) {
51 void *org_ptr = l.ptr; 52 void *org_ptr = l.ptr;
52 53
53 // put the line to the list 54 // put the line to the list
54 ConfigLine *line = OBJ_NEW(parser->mp, ConfigLine); 55 ConfigLine *line = OBJ_NEW(parser->a, ConfigLine);
55 line->line = cx_strdup_a(parser->mp, cx_strcast(l)); // TODO: check for 0-len str 56 line->line = cx_strdup_a(parser->a, cx_strcast(l)); // TODO: check for 0-len str
56 line->object = NULL; 57 line->object = NULL;
57 line->type = LINE_OTHER; 58 line->type = LINE_OTHER;
58 CFG_LINE_ADD(&parser->lines_begin, &parser->lines_end, line); 59 CFG_LINE_ADD(&parser->lines_begin, &parser->lines_end, line);
59 60
60 // check if the line contains something 61 // check if the line contains something
78 79
79 line->type = LINE_MULTI; 80 line->type = LINE_MULTI;
80 } 81 }
81 if(l.ptr[l.length - 1] == '\\') { 82 if(l.ptr[l.length - 1] == '\\') {
82 if(mline.ptr == NULL) { 83 if(mline.ptr == NULL) {
83 mline = cx_strdup_a(parser->mp, cx_strcast(l)); 84 mline = cx_strdup_a(parser->a, cx_strcast(l));
84 start_line = line; 85 start_line = line;
85 } 86 }
86 } else { 87 } else {
87 // this line is complete so we can parse it 88 // this line is complete so we can parse it
88 cxmutstr ll; // we parse this line 89 cxmutstr ll; // we parse this line

mercurial