Changeset 745 for trunk/zoo-project/zoo-kernel/request_parser.c
- Timestamp:
- Dec 12, 2015, 5:39:48 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/request_parser.c
r725 r745 483 483 484 484 /** 485 * Create a "missingIdentifier" maps in case it is NULL. 486 * 487 * @param main_conf the conf maps containing the main.cfg settings 488 * @param mymaps the maps to update 489 * @return 0 on success, 4 on failure 490 */ 491 int defineMissingIdentifier(maps** main_conf,maps** mymaps){ 492 if (*mymaps == NULL){ 493 *mymaps = (maps *) malloc (MAPS_SIZE); 494 if (*mymaps == NULL){ 495 return errorException (*main_conf, 496 _("Unable to allocate memory"), 497 "InternalError", NULL); 498 } 499 (*mymaps)->name = zStrdup ("missingIndetifier"); 500 (*mymaps)->content = NULL; 501 (*mymaps)->next = NULL; 502 } 503 return 0; 504 } 505 506 /** 485 507 * Parse inputs from XML nodes and store them in a maps. 486 508 * … … 528 550 xmlChar *val = 529 551 xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1); 530 if (tmpmaps == NULL )552 if (tmpmaps == NULL && val!=NULL) 531 553 { 532 554 tmpmaps = (maps *) malloc (MAPS_SIZE); … … 541 563 tmpmaps->content = NULL; 542 564 tmpmaps->next = NULL; 565 xmlFree (val); 543 566 } 544 xmlFree (val);545 567 } 546 568 // Title, Asbtract … … 553 575 xmlChar *val = 554 576 xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1); 555 if (tmpmaps == NULL) 556 { 557 tmpmaps = (maps *) malloc (MAPS_SIZE); 558 if (tmpmaps == NULL) 559 { 560 return errorException (*main_conf, 561 _ 562 ("Unable to allocate memory"), 563 "InternalError", NULL); 564 } 565 tmpmaps->name = zStrdup ("missingIndetifier"); 577 defineMissingIdentifier(main_conf,&tmpmaps); 578 if(val!=NULL){ 579 if (tmpmaps->content != NULL) 580 addToMap (tmpmaps->content, 581 (char *) cur2->name, (char *) val); 582 else 566 583 tmpmaps->content = 567 584 createMap ((char *) cur2->name, (char *) val); 568 tmpmaps->next = NULL; 569 } 570 else 571 { 572 if (tmpmaps->content != NULL) 573 addToMap (tmpmaps->content, 574 (char *) cur2->name, (char *) val); 575 else 576 tmpmaps->content = 577 createMap ((char *) cur2->name, (char *) val); 578 } 579 xmlFree (val); 585 xmlFree (val); 586 } 580 587 } 581 588 // InputDataFormChoice (Reference or Data ?) 582 589 if (xmlStrcasecmp (cur2->name, BAD_CAST "Reference") == 0) 583 590 { 591 defineMissingIdentifier(main_conf,&tmpmaps); 584 592 // Get every attribute from a Reference node 585 593 // mimeType, encoding, schema, href, method … … 721 729 722 730 sprintf (tmp, "%s", (char*) btmps); 723 724 xmlFreeDoc (bdoc);731 732 //xmlFreeDoc (bdoc); 725 733 726 734 map *btmp = … … 815 823 else if (xmlStrcasecmp (cur2->name, BAD_CAST "Data") == 0) 816 824 { 825 defineMissingIdentifier(main_conf,&tmpmaps); 817 826 xmlNodePtr cur4 = cur2->children; 818 827 if(vid==1){ … … 946 955 && cur5->type != XML_CDATA_SECTION_NODE) 947 956 cur5 = cur5->next; 957 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 958 fflush(stderr); 948 959 if (cur5 != NULL 949 960 && cur5->type != XML_CDATA_SECTION_NODE) … … 953 964 &buffersize, 954 965 "utf-8", 0); 955 addIntToMap (tmpmaps->content, "size",956 buffersize);957 xmlFreeDoc (doc1);958 966 } 959 967 else … … 961 969 if (cur5 != NULL 962 970 && cur5->type == XML_CDATA_SECTION_NODE){ 963 xmlDocPtr doc2 = xml ParseMemory((const char*)cur5->content,xmlStrlen(cur5->content));964 xmlDocSetRootElement (doc1,xmlDocGetRootElement(doc2));965 xmlDocDumpFormatMemoryEnc (doc 1, &mv,971 xmlDocPtr doc2 = xmlReadMemory((const char*)cur5->content,xmlStrlen(cur5->content), 972 "input_content.xml", NULL, XML_PARSE_RECOVER); 973 xmlDocDumpFormatMemoryEnc (doc2, &mv, 966 974 &buffersize, 967 975 "utf-8", 0); 968 addIntToMap(tmpmaps->content, "size",buffersize);969 976 xmlFreeDoc (doc2); 970 xmlFreeDoc (doc1);971 977 } 972 978 } 979 addIntToMap (tmpmaps->content, "size", 980 buffersize); 981 xmlFreeDoc (doc1); 973 982 }else{ 974 983 xmlNodePtr cur5 = cur4->children; … … 1008 1017 } 1009 1018 { 1019 map* test=getMap(tmpmaps->content,"value"); 1020 if(test==NULL) 1021 addToMap(tmpmaps->content,"value",""); 1010 1022 maps *testPresence = 1011 1023 getMaps (*request_output, tmpmaps->name); … … 1324 1336 1325 1337 xmlInitParser (); 1326 xmlDocPtr doc = xml ParseMemory (post, cgiContentLength);1338 xmlDocPtr doc = xmlReadMemory (post, cgiContentLength, "input_request.xml", NULL, XML_PARSE_RECOVER); 1327 1339 1328 1340 /**
Note: See TracChangeset
for help on using the changeset viewer.