Changeset 790 for trunk/zoo-project/zoo-kernel/request_parser.c
- Timestamp:
- Dec 19, 2016, 6:01:06 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/request_parser.c
r781 r790 60 60 map *tmap = getMapType (tmpMaps->content); 61 61 elements *el = getElements (elem, mi->name); 62 elements *cursor = elem; 63 while(cursor!=NULL && el==NULL){ 64 if(cursor->child!=NULL) 65 el = getElements (cursor->child, mi->name); 66 cursor=cursor->next; 67 } 62 68 int hasEl = 1; 63 69 if (el == NULL) 64 70 hasEl = -1; 71 65 72 if (tmap == NULL) 66 73 { … … 178 185 } 179 186 } 187 if(cursor->child!=NULL) 188 ensureDecodedBase64(&cursor->child); 180 189 cursor=cursor->next; 181 190 } … … 255 264 if (tmpmaps == NULL) 256 265 { 257 tmpmaps = (maps *) malloc (MAPS_SIZE);266 tmpmaps = createMaps(tmpn); 258 267 if (tmpmaps == NULL) 259 268 { … … 263 272 "InternalError", NULL); 264 273 } 265 tmpmaps->name = zStrdup (tmpn);266 274 if (tmpv != NULL) 267 275 { … … 433 441 if (tmp_output == NULL) 434 442 { 435 tmp_output = (maps *) malloc (MAPS_SIZE);443 tmp_output = createMaps(tmpc); 436 444 if (tmp_output == NULL) 437 445 { … … 442 450 "InternalError", NULL); 443 451 } 444 tmp_output->name = zStrdup (tmpc);445 tmp_output->content = NULL;446 tmp_output->next = NULL;447 452 } 448 453 } … … 491 496 int defineMissingIdentifier(maps** main_conf,maps** mymaps){ 492 497 if (*mymaps == NULL){ 493 *mymaps = (maps *) malloc (MAPS_SIZE);498 *mymaps = createMaps("missingIndetifier"); 494 499 if (*mymaps == NULL){ 495 500 return errorException (*main_conf, … … 497 502 "InternalError", NULL); 498 503 } 499 (*mymaps)->name = zStrdup ("missingIndetifier");500 (*mymaps)->content = NULL;501 (*mymaps)->next = NULL;502 504 } 503 505 return 0; … … 529 531 // A specific Input node. 530 532 if(vid==1){ 531 tmpmaps = (maps *) malloc (MAPS_SIZE);532 533 xmlChar *val = xmlGetProp (cur, BAD_CAST "id"); 533 tmpmaps->name = zStrdup ((char *) val); 534 tmpmaps->content = NULL; 535 tmpmaps->next = NULL; 534 tmpmaps = createMaps((char *) val); 536 535 } 537 536 … … 552 551 if (tmpmaps == NULL && val!=NULL) 553 552 { 554 tmpmaps = (maps *) malloc (MAPS_SIZE);553 tmpmaps = createMaps((char*)val); 555 554 if (tmpmaps == NULL) 556 555 { … … 560 559 "InternalError", NULL); 561 560 } 562 tmpmaps->name = zStrdup ((char *) val);563 tmpmaps->content = NULL;564 tmpmaps->next = NULL;565 561 xmlFree (val); 566 562 } … … 586 582 } 587 583 } 588 // InputDataFormChoice (Reference or Data ?) 589 if (xmlStrcasecmp (cur2->name, BAD_CAST "Reference") == 0) 584 // InputDataFormChoice (Reference or Data ?) / 2.0.0 DataInputType / Input 585 if (xmlStrcasecmp (cur2->name, BAD_CAST "Input") == 0) 586 { 587 char *xpathExpr=(char*)malloc(61+strlen(tmpmaps->name)); 588 sprintf(xpathExpr,"/*/*[local-name()='Input' and @id='%s']/*[local-name()='Input']",tmpmaps->name); 589 xmlXPathObjectPtr tmpsptr = extractFromDoc (doc, xpathExpr); 590 xmlNodeSet *tmps = tmpsptr->nodesetval; 591 if(tmps!=NULL){ 592 maps* request_output1=NULL; 593 if(xmlParseInputs(main_conf,s,&request_output1,doc,tmps,hInternet)<0) 594 return -1; 595 if(tmpmaps->child==NULL) 596 tmpmaps->child=dupMaps(&request_output1); 597 else 598 addMapsToMaps(&tmpmaps->child,request_output1); 599 freeMaps(&request_output1); 600 free(request_output1); 601 } 602 while(cur2->next!=NULL) 603 cur2=cur2->next; 604 } 605 else if (xmlStrcasecmp (cur2->name, BAD_CAST "Reference") == 0) 590 606 { 591 607 defineMissingIdentifier(main_conf,&tmpmaps); … … 848 864 cur4=cur4->next; 849 865 if(cur4!=NULL){ 850 if(cur4->content!=NULL) 866 if(cur4->content!=NULL){ 851 867 if (tmpmaps->content != NULL) 852 868 addToMap (tmpmaps->content, "value", … … 855 871 tmpmaps->content = 856 872 createMap ("value", (char *) cur4->content); 873 } 857 874 cur4=cur4->next; 858 875 } … … 955 972 && cur5->type != XML_CDATA_SECTION_NODE) 956 973 cur5 = cur5->next; 957 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);958 fflush(stderr);959 974 if (cur5 != NULL 960 975 && cur5->type != XML_CDATA_SECTION_NODE) … … 1018 1033 { 1019 1034 map* test=getMap(tmpmaps->content,"value"); 1020 if(test==NULL )1035 if(test==NULL && tmpmaps->child==NULL) 1021 1036 addToMap(tmpmaps->content,"value",""); 1022 maps *testPresence = 1023 getMaps (*request_output, tmpmaps->name); 1037 maps *testPresence = getMaps (*request_output, tmpmaps->name); 1038 maps *cursor=*request_output; 1039 while(testPresence == NULL && cursor!=NULL){ 1040 if(cursor->child!=NULL){ 1041 testPresence = getMaps (cursor->child, tmpmaps->name); 1042 } 1043 cursor=cursor->next; 1044 } 1024 1045 if (testPresence != NULL) 1025 1046 { 1026 1047 elements *elem = getElements (s->inputs, tmpmaps->name); 1048 elements *cursor=s->inputs; 1049 while(elem == NULL && cursor!=NULL){ 1050 if(cursor->child!=NULL){ 1051 elem = getElements (cursor->child, tmpmaps->name); 1052 } 1053 cursor=cursor->next; 1054 } 1027 1055 if (elem != NULL) 1028 1056 { 1029 1057 if (appendMapsToMaps 1030 (*main_conf, *request_output, tmpmaps, elem) < 0)1058 (*main_conf, testPresence, tmpmaps, elem) < 0) 1031 1059 { 1032 1060 return errorException (*main_conf, … … 1066 1094 xmlNodePtr cur = nodes->nodeTab[k]; 1067 1095 if (cur->type == XML_ELEMENT_NODE){ 1068 maps *tmpmaps = (maps *) malloc (MAPS_SIZE);1096 maps *tmpmaps = NULL; 1069 1097 xmlChar *val = xmlGetProp (cur, BAD_CAST "id"); 1070 1098 if(val!=NULL) 1071 tmpmaps ->name = zStrdup ((char*)val);1099 tmpmaps = createMaps((char *)val); 1072 1100 else 1073 tmpmaps->name = zStrdup ("unknownIdentifier"); 1074 tmpmaps->content = NULL; 1075 tmpmaps->next = NULL; 1101 tmpmaps = createMaps("unknownIdentifier"); 1076 1102 const char ress[4][13] = 1077 1103 { "mimeType", "encoding", "schema", "transmission" }; … … 1091 1117 xmlFree (val); 1092 1118 } 1093 if (*request_output == NULL) 1119 if(cur->children!=NULL){ 1120 xmlNodePtr ccur = cur->children; 1121 while (ccur != NULL){ 1122 if(ccur->type == XML_ELEMENT_NODE){ 1123 char *xpathExpr=(char*)malloc(65+strlen(tmpmaps->name)); 1124 sprintf(xpathExpr,"/*/*[local-name()='Output' and @id='%s']/*[local-name()='Output']",tmpmaps->name); 1125 xmlXPathObjectPtr tmpsptr = extractFromDoc (doc, xpathExpr); 1126 xmlNodeSet* cnodes = tmpsptr->nodesetval; 1127 xmlParseOutputs2(main_conf,request_inputs,&tmpmaps->child,doc,cnodes); 1128 break; 1129 } 1130 ccur = ccur->next; 1131 } 1132 } 1133 if (*request_output == NULL){ 1094 1134 *request_output = dupMaps(&tmpmaps); 1095 else 1135 } 1136 else{ 1096 1137 addMapsToMaps(request_output,tmpmaps); 1138 } 1139 freeMaps(&tmpmaps); 1140 free(tmpmaps); 1097 1141 } 1098 1142 } … … 1119 1163 { 1120 1164 1121 maps *tmpmaps = (maps *) malloc (MAPS_SIZE);1165 maps *tmpmaps = createMaps("unknownIdentifier"); 1122 1166 if (tmpmaps == NULL) 1123 1167 { … … 1125 1169 "InternalError", NULL); 1126 1170 } 1127 tmpmaps->name = zStrdup ("unknownIdentifier");1128 tmpmaps->content = NULL;1129 tmpmaps->next = NULL;1130 1171 1131 1172 // Get every attribute from a RawDataOutput node … … 1210 1251 } 1211 1252 1212 maps *tmpmaps = (maps *) malloc (MAPS_SIZE); // one per Output node1253 maps *tmpmaps = createMaps("unknownIdentifier"); // one per Output node 1213 1254 if (tmpmaps == NULL) { 1214 1255 return errorException (*main_conf, … … 1217 1258 "InternalError", NULL); 1218 1259 } 1219 tmpmaps->name = zStrdup ("unknownIdentifier");1220 tmpmaps->content = NULL;1221 tmpmaps->next = NULL;1222 1260 1223 1261 xmlNodePtr elems = cur1->children; … … 1513 1551 char *dfv1 = 1514 1552 addDefaultValues (request_outputs, s->outputs, *main_conf, 1,&errO); 1553 1515 1554 if (strcmp (dfv1, "") != 0 || strcmp (dfv, "") != 0) 1516 1555 {
Note: See TracChangeset
for help on using the changeset viewer.