src/server/config/objconf.c

changeset 91
fac51f87def0
parent 88
73b3485e96f1
child 115
51d9a15eac98
equal deleted inserted replaced
90:279f343bbf6c 91:fac51f87def0
64 } 64 }
65 65
66 void free_object_config(ObjectConfig *conf) { 66 void free_object_config(ObjectConfig *conf) {
67 // free other lists 67 // free other lists
68 if(conf->levels) { 68 if(conf->levels) {
69 ucx_list_free(conf->levels); 69 //ucx_list_free(conf->levels);
70 } 70 }
71 71
72 // free mempool 72 // free mempool
73 ucx_mempool_destroy(conf->parser.mp); 73 ucx_mempool_destroy(conf->parser.mp->pool);
74 free(conf); 74 free(conf);
75 } 75 }
76 76
77 77
78 78
120 } 120 }
121 return 0; 121 return 0;
122 } 122 }
123 123
124 int objconf_on_begin_tag(ObjectConfig *conf, ConfigTag *tag) { 124 int objconf_on_begin_tag(ObjectConfig *conf, ConfigTag *tag) {
125 UcxMempool *mp = conf->parser.mp; 125 UcxAllocator *mp = conf->parser.mp;
126 if(tag->type_num != TAG_OBJECT) { 126 if(tag->type_num != TAG_OBJECT) {
127 ConfigParserLevel *l = conf->levels->data; 127 ConfigParserLevel *l = conf->levels->data;
128 if(l->tag->type_num != TAG_OBJECT) { 128 if(l->tag->type_num != TAG_OBJECT) {
129 tag->parent = l->tag; 129 tag->parent = l->tag;
130 } 130 }
139 139
140 obj->name = cfg_param_get(tag->param, sstr("name")); 140 obj->name = cfg_param_get(tag->param, sstr("name"));
141 obj->ppath = cfg_param_get(tag->param, sstr("ppath")); 141 obj->ppath = cfg_param_get(tag->param, sstr("ppath"));
142 142
143 conf->obj = obj; 143 conf->obj = obj;
144 conf->objects = cfg_dlist_append(mp, conf->objects, obj); 144 conf->objects = ucx_list_append_a(mp, conf->objects, obj);
145 145
146 // create tree level object 146 // create tree level object
147 ConfigParserLevel *lvl = OBJ_NEW(mp, ConfigParserLevel); 147 ConfigParserLevel *lvl = OBJ_NEW(mp, ConfigParserLevel);
148 lvl->iftag = NULL; 148 lvl->iftag = NULL;
149 lvl->levelnum = 1; 149 lvl->levelnum = 1;
150 lvl->tag = tag; 150 lvl->tag = tag;
151 conf->levels = ucx_list_prepend(conf->levels, lvl); 151 conf->levels = ucx_list_prepend_a(mp, conf->levels, lvl);
152 152
153 break; 153 break;
154 } 154 }
155 case TAG_IF: { 155 case TAG_IF: {
156 // create tree level object 156 // create tree level object
159 ConfigParserLevel *lvl = OBJ_NEW(mp, ConfigParserLevel); 159 ConfigParserLevel *lvl = OBJ_NEW(mp, ConfigParserLevel);
160 160
161 lvl->iftag = NULL; 161 lvl->iftag = NULL;
162 lvl->levelnum = last_lvl->levelnum + 1; 162 lvl->levelnum = last_lvl->levelnum + 1;
163 lvl->tag = tag; 163 lvl->tag = tag;
164 conf->levels = ucx_list_prepend(conf->levels, lvl); 164 conf->levels = ucx_list_prepend_a(mp, conf->levels, lvl);
165 last_lvl->iftag = tag; 165 last_lvl->iftag = tag;
166 166
167 break; 167 break;
168 } 168 }
169 case TAG_ELSEIF: { 169 case TAG_ELSEIF: {
209 if(type == TAG_OBJECT) { 209 if(type == TAG_OBJECT) {
210 conf->obj = NULL; 210 conf->obj = NULL;
211 } 211 }
212 212
213 // remove level 213 // remove level
214 conf->levels = ucx_list_remove(conf->levels, conf->levels); 214 conf->levels = ucx_list_remove_a(
215 conf->parser.mp,
216 conf->levels,
217 conf->levels);
215 } 218 }
216 219
217 return 0; 220 return 0;
218 } 221 }
219 222
225 if(lvl->tag->type_num != TAG_OBJECT) { 228 if(lvl->tag->type_num != TAG_OBJECT) {
226 dir->condition = lvl->tag; 229 dir->condition = lvl->tag;
227 } 230 }
228 231
229 // add directive to current object 232 // add directive to current object
230 conf->obj->directives[dir->type_num] = cfg_dlist_append( 233 conf->obj->directives[dir->type_num] = ucx_list_append_a(
231 conf->parser.mp, 234 conf->parser.mp,
232 conf->obj->directives[dir->type_num], 235 conf->obj->directives[dir->type_num],
233 dir); 236 dir);
234 237
235 return 0; 238 return 0;

mercurial