201 |
201 |
202 return 1; |
202 return 1; |
203 } |
203 } |
204 |
204 |
205 // prepare PgRepository |
205 // prepare PgRepository |
206 repo->prop_ext = cxHashMapCreate(a, 8); |
206 repo->prop_ext = cxHashMapCreate(a, CX_STORE_POINTERS, 8); |
207 if(!repo->prop_ext) { |
207 if(!repo->prop_ext) { |
208 log_ereport(LOG_FAILURE, "pg: cannot load config file: OOM"); |
208 log_ereport(LOG_FAILURE, "pg: cannot load config file: OOM"); |
209 return 1; |
209 return 1; |
210 } |
210 } |
211 |
211 |
243 { |
243 { |
244 xmlNode *node = root->children; |
244 xmlNode *node = root->children; |
245 int ret = 0; |
245 int ret = 0; |
246 |
246 |
247 PgExtParser parserData; |
247 PgExtParser parserData; |
248 parserData.table_lookup = cxHashMapCreate(cxDefaultAllocator, 8); |
248 parserData.table_lookup = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 8); |
249 parserData.tables = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_ptr, sizeof(PgExtTable)); |
249 parserData.tables = cxLinkedListCreate(cxDefaultAllocator, NULL, sizeof(PgExtTable)); |
250 |
250 |
251 while(node && !ret) { |
251 while(node && !ret) { |
252 // currently, the only possible config element is <extension> |
252 // currently, the only possible config element is <extension> |
253 if(node->type == XML_ELEMENT_NODE) { |
253 if(node->type == XML_ELEMENT_NODE) { |
254 if(xstreq(node->name, "extension")) { |
254 if(xstreq(node->name, "extension")) { |
263 size_t ntables = parserData.tables->size; |
263 size_t ntables = parserData.tables->size; |
264 repo->ntables = ntables; |
264 repo->ntables = ntables; |
265 repo->tables = pool_calloc(pool, ntables, sizeof(PgExtTable)); |
265 repo->tables = pool_calloc(pool, ntables, sizeof(PgExtTable)); |
266 if(repo->tables) { |
266 if(repo->tables) { |
267 int i = 0; |
267 int i = 0; |
268 CxIterator iter = cxListIterator(parserData.tables, 0); |
268 CxIterator iter = cxListIterator(parserData.tables); |
269 cx_foreach(PgExtTable *, tab, iter) { |
269 cx_foreach(PgExtTable *, tab, iter) { |
270 repo->tables[i++] = *tab; |
270 repo->tables[i++] = *tab; |
271 } |
271 } |
272 } else { |
272 } else { |
273 ret = 1; |
273 ret = 1; |
292 CxAllocator *a = pool_allocator(pool); |
292 CxAllocator *a = pool_allocator(pool); |
293 |
293 |
294 xmlNode *node = ext_node->children; |
294 xmlNode *node = ext_node->children; |
295 |
295 |
296 const char *table = NULL; |
296 const char *table = NULL; |
297 CxList *properties = cxPointerLinkedListCreate(a, cx_cmp_ptr); |
297 CxList *properties = cxLinkedListCreate(a, NULL, CX_STORE_POINTERS); |
298 |
298 |
299 while(node) { |
299 while(node) { |
300 if(node->type == XML_ELEMENT_NODE) { |
300 if(node->type == XML_ELEMENT_NODE) { |
301 if(xstreq(node->name, "table")) { |
301 if(xstreq(node->name, "table")) { |
302 const char *value = pg_util_xml_get_text(node); |
302 const char *value = pg_util_xml_get_text(node); |
362 |
362 |
363 if(cxMapPut(ext->table_lookup, cx_hash_key_str(table), (void*)table)) { |
363 if(cxMapPut(ext->table_lookup, cx_hash_key_str(table), (void*)table)) { |
364 return 1; |
364 return 1; |
365 } |
365 } |
366 |
366 |
367 CxIterator iter = cxListIterator(properties, 0); |
367 CxIterator iter = cxListIterator(properties); |
368 cx_foreach(xmlNode *, ps, iter) { |
368 cx_foreach(xmlNode *, ps, iter) { |
369 const char *value = pg_util_xml_get_text(ps); |
369 const char *value = pg_util_xml_get_text(ps); |
370 |
370 |
371 PgPropertyStoreExt *ext_col = pool_malloc(pool, sizeof(PgPropertyStoreExt)); |
371 PgPropertyStoreExt *ext_col = pool_malloc(pool, sizeof(PgPropertyStoreExt)); |
372 if(!ext_col) { |
372 if(!ext_col) { |