Changeset 790 for trunk/zoo-project/zoo-kernel
- Timestamp:
- Dec 19, 2016, 6:01:06 PM (8 years ago)
- Location:
- trunk/zoo-project/zoo-kernel
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/caching.c
r781 r790 148 148 149 149 /** 150 * Read the downloaded file for a specific input 151 * 152 * @param m the maps containing the settings of the main.cfg file 153 * @param in the input 154 * @param index the input index 155 * @param hInternet the internet connection 156 * @return 0 in case of success, 4 in case of failure 157 */ 158 int readCurrentInput(maps** m,maps** in,int* index,HINTERNET* hInternet){ 159 map* tmp1; 160 char sindex[5]; 161 maps* content=*in; 162 map* length=getMap(content->content,"length"); 163 int shouldClean=-1; 164 if(length==NULL){ 165 length=createMap("length","1"); 166 shouldClean=1; 167 } 168 for(int i=0;i<atoi(length->value);i++){ 169 char* fcontent; 170 char *mimeType=NULL; 171 int fsize=0; 172 char cname[15]; 173 char vname[11]; 174 char vname1[11]; 175 char sname[9]; 176 char mname[15]; 177 char icname[14]; 178 char xname[16]; 179 char oname[12]; 180 if(*index>0) 181 sprintf(vname1,"value_%d",*index); 182 else 183 sprintf(vname1,"value"); 184 185 if(i>0){ 186 tmp1=getMap(content->content,cname); 187 sprintf(cname,"cache_file_%d",i); 188 sprintf(vname,"value_%d",i); 189 sprintf(sname,"size_%d",i); 190 sprintf(mname,"mimeType_%d",i); 191 sprintf(icname,"isCached_%d",i); 192 sprintf(xname,"Reference_%d",i); 193 sprintf(oname,"Order_%d",i); 194 }else{ 195 sprintf(cname,"cache_file"); 196 sprintf(vname,"value"); 197 sprintf(sname,"size"); 198 sprintf(mname,"mimeType"); 199 sprintf(icname,"isCached"); 200 sprintf(xname,"Reference"); 201 sprintf(oname,"Order"); 202 } 203 204 map* tmap=getMap(content->content,oname); 205 sprintf(sindex,"%d",*index+1); 206 if((tmp1=getMap(content->content,xname))!=NULL && tmap!=NULL && strcasecmp(tmap->value,sindex)==0){ 207 208 if(getMap(content->content,icname)==NULL){ 209 210 fcontent=(char*)malloc((hInternet->ihandle[*index].nDataLen+1)*sizeof(char)); 211 if(fcontent == NULL){ 212 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 213 } 214 size_t dwRead; 215 InternetReadFile(hInternet->ihandle[*index], 216 (LPVOID)fcontent, 217 hInternet->ihandle[*index].nDataLen, 218 &dwRead); 219 fcontent[hInternet->ihandle[*index].nDataLen]=0; 220 fsize=hInternet->ihandle[*index].nDataLen; 221 if(hInternet->ihandle[*index].mimeType==NULL) 222 mimeType=zStrdup("none"); 223 else 224 mimeType=zStrdup(hInternet->ihandle[*index].mimeType); 225 226 map* tmpMap=getMapOrFill(&(*in)->content,vname,""); 227 free(tmpMap->value); 228 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 229 if(tmpMap->value==NULL){ 230 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 231 } 232 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); 233 234 char ltmp1[256]; 235 sprintf(ltmp1,"%d",fsize); 236 map* tmp=getMapFromMaps(*m,"main","cacheDir"); 237 if(tmp!=NULL){ 238 char* md5str=getMd5(tmp1->value); 239 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6)); 240 sprintf(fname,"%s/%s.zca",tmp->value,md5str); 241 addToMap((*in)->content,cname,fname); 242 free(fname); 243 } 244 addToMap((*in)->content,sname,ltmp1); 245 addToMap((*in)->content,mname,mimeType); 246 addToCache(*m,tmp1->value,fcontent,mimeType,fsize, NULL, 0); 247 free(fcontent); 248 free(mimeType); 249 *index++; 250 251 } 252 } 253 } 254 if(shouldClean>0){ 255 freeMap(&length); 256 free(length); 257 } 258 return 0; 259 } 260 261 /** 150 262 * Effectively run all the HTTP requests in the queue 151 263 * … … 157 269 */ 158 270 int runHttpRequests(maps** m,maps** inputs,HINTERNET* hInternet){ 159 if(hInternet ->nb>0){271 if(hInternet!=NULL && hInternet->nb>0){ 160 272 processDownloads(hInternet); 161 273 maps* content=*inputs; 162 map* tmp1;163 274 int index=0; 164 char sindex[5];165 275 while(content!=NULL){ 166 167 map* length=getMap(content->content,"length"); 168 int shouldClean=-1; 169 if(length==NULL){ 170 length=createMap("length","1"); 171 shouldClean=1; 172 } 173 for(int i=0;i<atoi(length->value);i++){ 174 char* fcontent; 175 char *mimeType=NULL; 176 int fsize=0; 177 char cname[15]; 178 char vname[11]; 179 char vname1[11]; 180 char sname[9]; 181 char mname[15]; 182 char icname[14]; 183 char xname[16]; 184 char oname[12]; 185 if(index>0) 186 sprintf(vname1,"value_%d",index); 187 else 188 sprintf(vname1,"value"); 189 190 if(i>0){ 191 tmp1=getMap(content->content,cname); 192 sprintf(cname,"cache_file_%d",i); 193 sprintf(vname,"value_%d",i); 194 sprintf(sname,"size_%d",i); 195 sprintf(mname,"mimeType_%d",i); 196 sprintf(icname,"isCached_%d",i); 197 sprintf(xname,"Reference_%d",i); 198 sprintf(oname,"Order_%d",i); 199 }else{ 200 sprintf(cname,"cache_file"); 201 sprintf(vname,"value"); 202 sprintf(sname,"size"); 203 sprintf(mname,"mimeType"); 204 sprintf(icname,"isCached"); 205 sprintf(xname,"Reference"); 206 sprintf(oname,"Order"); 207 } 208 209 map* tmap=getMap(content->content,oname); 210 sprintf(sindex,"%d",index+1); 211 if((tmp1=getMap(content->content,xname))!=NULL && tmap!=NULL && strcasecmp(tmap->value,sindex)==0){ 212 213 if(getMap(content->content,icname)==NULL){ 214 215 fcontent=(char*)malloc((hInternet->ihandle[index].nDataLen+1)*sizeof(char)); 216 if(fcontent == NULL){ 217 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 218 } 219 size_t dwRead; 220 InternetReadFile(hInternet->ihandle[index], 221 (LPVOID)fcontent, 222 hInternet->ihandle[index].nDataLen, 223 &dwRead); 224 fcontent[hInternet->ihandle[index].nDataLen]=0; 225 fsize=hInternet->ihandle[index].nDataLen; 226 if(hInternet->ihandle[index].mimeType==NULL) 227 mimeType=strdup("none"); 228 else 229 mimeType=strdup(hInternet->ihandle[index].mimeType); 230 231 map* tmpMap=getMapOrFill(&content->content,vname,""); 232 free(tmpMap->value); 233 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 234 if(tmpMap->value==NULL){ 235 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 236 } 237 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); 238 239 char ltmp1[256]; 240 sprintf(ltmp1,"%d",fsize); 241 map* tmp=getMapFromMaps(*m,"main","cacheDir"); 242 if(tmp!=NULL){ 243 char* md5str=getMd5(tmp1->value); 244 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6)); 245 sprintf(fname,"%s/%s.zca",tmp->value,md5str); 246 addToMap(content->content,cname,fname); 247 free(fname); 248 } 249 addToMap(content->content,sname,ltmp1); 250 addToMap(content->content,mname,mimeType); 251 addToCache(*m,tmp1->value,fcontent,mimeType,fsize, NULL, 0); 252 free(fcontent); 253 free(mimeType); 254 index++; 255 256 } 276 if(content->child!=NULL){ 277 maps* cursor=content->child; 278 while(cursor!=NULL){ 279 readCurrentInput(m,&cursor,&index,hInternet); 280 cursor=cursor->next; 257 281 } 258 282 } 259 if(shouldClean>0){ 260 freeMap(&length); 261 free(length); 262 } 263 283 else 284 readCurrentInput(m,&content,&index,hInternet); 264 285 content=content->next; 265 } 266 286 } 267 287 } 268 288 return 0; … … 281 301 maps *oreq=getMaps(*m,"orequests"); 282 302 if(oreq==NULL){ 283 oreq=(maps*)malloc(MAPS_SIZE); 284 oreq->name=zStrdup("orequests"); 303 oreq=createMaps("orequests"); 285 304 oreq->content=createMap("value",url); 286 oreq->next=NULL;287 305 addMapsToMaps(m,oreq); 288 306 freeMaps(&oreq); … … 351 369 352 370 free(tmpMap->value); 353 354 371 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 355 372 if(tmpMap->value==NULL || fcontent == NULL) -
trunk/zoo-project/zoo-kernel/main_conf_read.y
r781 r790 111 111 free(current_content); 112 112 current_maps->next=NULL; 113 current_maps->next=(maps*)malloc(MAPS_SIZE); 114 current_maps->next->name=zStrdup($1); 115 current_maps->next->content=NULL; 116 current_maps->next->next=NULL; 113 current_maps->next=createMaps($1); 117 114 current_maps=current_maps->next; 118 115 current_content=current_maps->content; -
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 { -
trunk/zoo-project/zoo-kernel/response_print.c
r788 r790 1489 1489 1490 1490 xmlAddChild(nc2,nc3); 1491 }else{ 1492 if(e->child!=NULL && vid!=0){ 1493 printFullDescription(in,e->child,type,ns,ns_ows,nc2,vid); 1494 } 1491 1495 } 1492 1496 1493 xmlAddChild(nc1,nc2); 1497 if(e->child!=NULL && vid==0){ 1498 elements* children=dupElements(e->child); 1499 elements* cursor=children; 1500 while(cursor!=NULL){ 1501 char* tmp=strdup(cursor->name); 1502 free(cursor->name); 1503 cursor->name=(char*)malloc((strlen(cursor->name)+strlen(e->name)+2)*sizeof(char)); 1504 sprintf(cursor->name,"%s.%s",e->name,tmp); 1505 cursor=cursor->next; 1506 } 1507 printFullDescription(in,children,type,ns,ns_ows,nc2,vid); 1508 xmlAddChild(nc1,nc2); 1509 freeElements(&children); 1510 free(children); 1511 }else 1512 xmlAddChild(nc1,nc2); 1494 1513 1495 1514 e=e->next; … … 1958 1977 } 1959 1978 1960 /** 1961 * IO type Reference or full Data ? 1962 */ 1963 map *tmpMap=getMap(m->content,"Reference"); 1964 if(tmpMap==NULL){ 1965 nc2=xmlNewNode(ns_wps, BAD_CAST "Data"); 1966 if(e!=NULL && e->format!=NULL){ 1967 if(strncasecmp(e->format,"LiteralOutput",strlen(e->format))==0) 1968 nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData"); 1979 // IO type nested outputs 1980 if(m->child!=NULL){ 1981 maps* curs=m->child; 1982 elements* ecurs=getElements(e,(e!=NULL?e->name:m->name)); 1983 ecurs=ecurs->child; 1984 while(curs!=NULL && ecurs!=NULL){ 1985 map* inRequest=getMap(curs->content,"inRequest"); 1986 if(inRequest!=NULL && strncasecmp(inRequest->value,"true",4)==0) 1987 printIOType(doc,nc1,ns_wps,ns_ows,ns_xlink,ecurs,curs,type,vid); 1988 curs=curs->next; 1989 ecurs=ecurs->next; 1990 } 1991 } 1992 else{ 1993 map *tmpMap=getMap(m->content,"Reference"); 1994 if(tmpMap==NULL){ 1995 nc2=xmlNewNode(ns_wps, BAD_CAST "Data"); 1996 if(e!=NULL && e->format!=NULL){ 1997 if(strncasecmp(e->format,"LiteralOutput",strlen(e->format))==0) 1998 nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData"); 1999 else 2000 if(strncasecmp(e->format,"ComplexOutput",strlen(e->format))==0) 2001 nc3=xmlNewNode(ns_wps, BAD_CAST "ComplexData"); 2002 else if(strncasecmp(e->format,"BoundingBoxOutput",strlen(e->format))==0) 2003 nc3=xmlNewNode(ns_wps, BAD_CAST "BoundingBoxData"); 2004 else 2005 nc3=xmlNewNode(ns_wps, BAD_CAST e->format); 2006 } 2007 else { 2008 map* tmpV=getMapFromMaps(m,"format","value"); 2009 if(tmpV!=NULL) 2010 nc3=xmlNewNode(ns_wps, BAD_CAST tmpV->value); 2011 else 2012 nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData"); 2013 } 2014 tmp=m->content; 2015 2016 while(tmp!=NULL){ 2017 if(strcasecmp(tmp->name,"mimeType")==0 || 2018 strcasecmp(tmp->name,"encoding")==0 || 2019 strcasecmp(tmp->name,"schema")==0 || 2020 strcasecmp(tmp->name,"datatype")==0 || 2021 strcasecmp(tmp->name,"uom")==0) { 2022 2023 if(vid==0) 2024 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 2025 else{ 2026 if(strcasecmp(tmp->name,"datatype")==0) 2027 xmlNewProp(nc2,BAD_CAST "mimeType",BAD_CAST "text/plain"); 2028 else 2029 if(strcasecmp(tmp->name,"uom")!=0) 2030 xmlNewProp(nc2,BAD_CAST tmp->name,BAD_CAST tmp->value); 2031 } 2032 } 2033 if(vid==0) 2034 xmlAddChild(nc2,nc3); 2035 tmp=tmp->next; 2036 } 2037 if(e!=NULL && e->format!=NULL && strcasecmp(e->format,"BoundingBoxData")==0) { 2038 map* bb=getMap(m->content,"value"); 2039 if(bb!=NULL) { 2040 map* tmpRes=parseBoundingBox(bb->value); 2041 printBoundingBox(ns_ows,nc3,tmpRes); 2042 freeMap(&tmpRes); 2043 free(tmpRes); 2044 } 2045 } 2046 else { 2047 if(e!=NULL) 2048 tmp=getMap(e->defaults->content,"mimeType"); 2049 else 2050 tmp=NULL; 2051 2052 map* tmp1=getMap(m->content,"encoding"); 2053 map* tmp2=getMap(m->content,"mimeType"); 2054 map* tmp3=getMap(m->content,"value"); 2055 int hasValue=1; 2056 if(tmp3==NULL){ 2057 tmp3=createMap("value",""); 2058 hasValue=-1; 2059 } 2060 2061 if( ( tmp1 != NULL && strncmp(tmp1->value,"base64",6) == 0 ) // if encoding is base64 2062 || // or if 2063 ( tmp2 != NULL && ( strstr(tmp2->value,"text") == NULL // mime type is not text 2064 && // nor 2065 strstr(tmp2->value,"xml") == NULL // xml 2066 && // nor 2067 strstr(tmp2->value,"javascript") == NULL // javascript 2068 && 2069 strstr(tmp2->value,"json") == NULL 2070 && 2071 strstr(tmp2->value,"ecmascript") == NULL 2072 && 2073 // include for backwards compatibility, 2074 // although correct mime type is ...kml+xml: 2075 strstr(tmp2->value,"google-earth.kml") == NULL ) 2076 ) 2077 ) { // then 2078 map* rs=getMap(m->content,"size"); // obtain size 2079 bool isSized=true; 2080 if(rs==NULL){ 2081 char tmp1[1024]; 2082 sprintf(tmp1,"%ld",strlen(tmp3->value)); 2083 rs=createMap("size",tmp1); 2084 isSized=false; 2085 } 2086 2087 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value)))); // base 64 encode in XML 2088 2089 if(tmp1==NULL || (tmp1!=NULL && strncmp(tmp1->value,"base64",6)!=0)) { 2090 xmlAttrPtr ap = xmlHasProp((vid==0?nc3:nc2), BAD_CAST "encoding"); 2091 if (ap != NULL) { 2092 xmlRemoveProp(ap); 2093 } 2094 xmlNewProp((vid==0?nc3:nc2),BAD_CAST "encoding",BAD_CAST "base64"); 2095 } 2096 2097 if(!isSized){ 2098 freeMap(&rs); 2099 free(rs); 2100 } 2101 } 2102 else if (tmp2!=NULL) { // else (text-based format) 2103 if(strstr(tmp2->value, "javascript") != NULL || // if javascript put code in CDATA block 2104 strstr(tmp2->value, "json") != NULL || // (will not be parsed by XML reader) 2105 strstr(tmp2->value, "ecmascript") != NULL 2106 ) { 2107 xmlAddChild((vid==0?nc3:nc2),xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value))); 2108 } 2109 else { // else 2110 if (strstr(tmp2->value, "xml") != NULL || // if XML-based format 2111 // include for backwards compatibility, 2112 // although correct mime type is ...kml+xml: 2113 strstr(tmp2->value, "google-earth.kml") != NULL 2114 ) { 2115 2116 int li=zooXmlAddDoc(tmp3->value); 2117 xmlDocPtr doc = iDocs[li]; 2118 xmlNodePtr ir = xmlDocGetRootElement(doc); 2119 xmlAddChild((vid==0?nc3:nc2),ir); 2120 } 2121 else // else 2122 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value)); // add text node 2123 } 2124 xmlAddChild(nc2,nc3); 2125 } 2126 else { 2127 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value)); 2128 } 2129 2130 if(hasValue<0) { 2131 freeMap(&tmp3); 2132 free(tmp3); 2133 } 2134 } 2135 } 2136 else { // Reference 2137 tmpMap=getMap(m->content,"Reference"); 2138 nc3=nc2=xmlNewNode(ns_wps, BAD_CAST "Reference"); 2139 /* Special case to avoid failing to validate against the WPS 2.0 schema */ 2140 if(strcasecmp(type,"Output")==0 && vid==0) 2141 xmlNewProp(nc3,BAD_CAST "href",BAD_CAST tmpMap->value); 1969 2142 else 1970 if(strncasecmp(e->format,"ComplexOutput",strlen(e->format))==0) 1971 nc3=xmlNewNode(ns_wps, BAD_CAST "ComplexData"); 1972 else if(strncasecmp(e->format,"BoundingBoxOutput",strlen(e->format))==0) 1973 nc3=xmlNewNode(ns_wps, BAD_CAST "BoundingBoxData"); 1974 else 1975 nc3=xmlNewNode(ns_wps, BAD_CAST e->format); 1976 } 1977 else { 1978 map* tmpV=getMapFromMaps(m,"format","value"); 1979 if(tmpV!=NULL) 1980 nc3=xmlNewNode(ns_wps, BAD_CAST tmpV->value); 1981 else 1982 nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData"); 1983 } 1984 tmp=m->content; 1985 1986 while(tmp!=NULL){ 1987 if(strcasecmp(tmp->name,"mimeType")==0 || 1988 strcasecmp(tmp->name,"encoding")==0 || 1989 strcasecmp(tmp->name,"schema")==0 || 1990 strcasecmp(tmp->name,"datatype")==0 || 1991 strcasecmp(tmp->name,"uom")==0) { 1992 1993 if(vid==0) 1994 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 1995 else{ 2143 xmlNewNsProp(nc3,ns_xlink,BAD_CAST "href",BAD_CAST tmpMap->value); 2144 2145 tmp=m->content; 2146 while(tmp!=NULL) { 2147 if(strcasecmp(tmp->name,"mimeType")==0 || 2148 strcasecmp(tmp->name,"encoding")==0 || 2149 strcasecmp(tmp->name,"schema")==0 || 2150 strcasecmp(tmp->name,"datatype")==0 || 2151 strcasecmp(tmp->name,"uom")==0){ 2152 1996 2153 if(strcasecmp(tmp->name,"datatype")==0) 1997 xmlNewProp(nc 2,BAD_CAST "mimeType",BAD_CAST "text/plain");2154 xmlNewProp(nc3,BAD_CAST "mimeType",BAD_CAST "text/plain"); 1998 2155 else 1999 if(strcasecmp(tmp->name,"uom")!=0) 2000 xmlNewProp(nc2,BAD_CAST tmp->name,BAD_CAST tmp->value); 2001 } 2002 } 2003 if(vid==0) 2156 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 2157 } 2158 tmp=tmp->next; 2004 2159 xmlAddChild(nc2,nc3); 2005 tmp=tmp->next; 2006 } 2007 if(e!=NULL && e->format!=NULL && strcasecmp(e->format,"BoundingBoxData")==0) { 2008 map* bb=getMap(m->content,"value"); 2009 if(bb!=NULL) { 2010 map* tmpRes=parseBoundingBox(bb->value); 2011 printBoundingBox(ns_ows,nc3,tmpRes); 2012 freeMap(&tmpRes); 2013 free(tmpRes); 2014 } 2015 } 2016 else { 2017 if(e!=NULL) 2018 tmp=getMap(e->defaults->content,"mimeType"); 2019 else 2020 tmp=NULL; 2021 2022 map* tmp1=getMap(m->content,"encoding"); 2023 map* tmp2=getMap(m->content,"mimeType"); 2024 map* tmp3=getMap(m->content,"value"); 2025 int hasValue=1; 2026 if(tmp3==NULL){ 2027 tmp3=createMap("value",""); 2028 hasValue=-1; 2029 } 2030 2031 if( ( tmp1 != NULL && strncmp(tmp1->value,"base64",6) == 0 ) // if encoding is base64 2032 || // or if 2033 ( tmp2 != NULL && ( strstr(tmp2->value,"text") == NULL // mime type is not text 2034 && // nor 2035 strstr(tmp2->value,"xml") == NULL // xml 2036 && // nor 2037 strstr(tmp2->value,"javascript") == NULL // javascript 2038 && 2039 strstr(tmp2->value,"json") == NULL 2040 && 2041 strstr(tmp2->value,"ecmascript") == NULL 2042 && 2043 // include for backwards compatibility, 2044 // although correct mime type is ...kml+xml: 2045 strstr(tmp2->value,"google-earth.kml") == NULL ) 2046 ) 2047 ) { // then 2048 map* rs=getMap(m->content,"size"); // obtain size 2049 bool isSized=true; 2050 if(rs==NULL){ 2051 char tmp1[1024]; 2052 sprintf(tmp1,"%ld",strlen(tmp3->value)); 2053 rs=createMap("size",tmp1); 2054 isSized=false; 2055 } 2056 2057 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value)))); // base 64 encode in XML 2058 2059 if(tmp1==NULL || (tmp1!=NULL && strncmp(tmp1->value,"base64",6)!=0)) { 2060 xmlAttrPtr ap = xmlHasProp((vid==0?nc3:nc2), BAD_CAST "encoding"); 2061 if (ap != NULL) { 2062 xmlRemoveProp(ap); 2063 } 2064 xmlNewProp((vid==0?nc3:nc2),BAD_CAST "encoding",BAD_CAST "base64"); 2065 } 2066 2067 if(!isSized){ 2068 freeMap(&rs); 2069 free(rs); 2070 } 2071 } 2072 else if (tmp2!=NULL) { // else (text-based format) 2073 if(strstr(tmp2->value, "javascript") != NULL || // if javascript put code in CDATA block 2074 strstr(tmp2->value, "json") != NULL || // (will not be parsed by XML reader) 2075 strstr(tmp2->value, "ecmascript") != NULL 2076 ) { 2077 xmlAddChild((vid==0?nc3:nc2),xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value))); 2078 } 2079 else { // else 2080 if (strstr(tmp2->value, "xml") != NULL || // if XML-based format 2081 // include for backwards compatibility, 2082 // although correct mime type is ...kml+xml: 2083 strstr(tmp2->value, "google-earth.kml") != NULL 2084 ) { 2085 2086 int li=zooXmlAddDoc(tmp3->value); 2087 xmlDocPtr doc = iDocs[li]; 2088 xmlNodePtr ir = xmlDocGetRootElement(doc); 2089 xmlAddChild((vid==0?nc3:nc2),ir); 2090 } 2091 else // else 2092 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value)); // add text node 2093 } 2094 xmlAddChild(nc2,nc3); 2095 } 2096 else { 2097 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value)); 2098 } 2099 2100 if(hasValue<0) { 2101 freeMap(&tmp3); 2102 free(tmp3); 2103 } 2104 } 2105 } 2106 else { // Reference 2107 tmpMap=getMap(m->content,"Reference"); 2108 nc3=nc2=xmlNewNode(ns_wps, BAD_CAST "Reference"); 2109 if(strcasecmp(type,"Output")==0) 2110 xmlNewProp(nc3,BAD_CAST "href",BAD_CAST tmpMap->value); 2111 else 2112 xmlNewNsProp(nc3,ns_xlink,BAD_CAST "href",BAD_CAST tmpMap->value); 2113 2114 tmp=m->content; 2115 while(tmp!=NULL) { 2116 if(strcasecmp(tmp->name,"mimeType")==0 || 2117 strcasecmp(tmp->name,"encoding")==0 || 2118 strcasecmp(tmp->name,"schema")==0 || 2119 strcasecmp(tmp->name,"datatype")==0 || 2120 strcasecmp(tmp->name,"uom")==0){ 2121 2122 if(strcasecmp(tmp->name,"datatype")==0) 2123 xmlNewProp(nc3,BAD_CAST "mimeType",BAD_CAST "text/plain"); 2124 else 2125 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 2126 } 2127 tmp=tmp->next; 2128 xmlAddChild(nc2,nc3); 2129 } 2130 } 2131 xmlAddChild(nc1,nc2); 2160 } 2161 } 2162 xmlAddChild(nc1,nc2); 2163 } 2132 2164 xmlAddChild(nc,nc1); 2133 2165 } … … 2394 2426 sprintf(tmpMsg,_("Unable to create the file \"%s\" for storing the session maps."),session_file_path); 2395 2427 errorException(m,tmpMsg,"InternalError",NULL); 2396 2397 2428 return; 2398 2429 } … … 2437 2468 #endif 2438 2469 maps* tmpI=request_outputs; 2470 maps* stmpI=NULL; 2439 2471 map* usid=getMapFromMaps(m,"lenv","usid"); 2440 2472 int itn=0; 2473 NESTED0: 2441 2474 while(tmpI!=NULL){ 2475 if(tmpI->child!=NULL){ 2476 stmpI=tmpI; 2477 tmpI=tmpI->child; 2478 } 2442 2479 #ifdef USE_MS 2443 2480 map* testMap=getMap(tmpI->content,"useMapserver"); … … 2462 2499 { 2463 2500 elements* in=getElements(s->outputs,tmpI->name); 2501 if(in==NULL && s->outputs->child!=NULL){ 2502 in=getElements(s->outputs->child,tmpI->name); 2503 } 2464 2504 char *format=NULL; 2465 2505 if(in!=NULL && in->format!=NULL){ … … 2545 2585 #endif 2546 2586 tmpI=tmpI->next; 2587 } 2588 if(stmpI!=NULL){ 2589 tmpI=stmpI->next; 2590 stmpI=NULL; 2591 if(tmpI!=NULL) 2592 goto NESTED0; 2547 2593 } 2548 2594 #ifdef DEBUG -
trunk/zoo-project/zoo-kernel/server_internal.c
r789 r790 583 583 map *res=*err; 584 584 elements* tmpInputs=in; 585 elements* tmpInputss=NULL; 585 586 maps* out1=*out; 587 maps* out1s=NULL; 586 588 char *result=NULL; 587 589 int nb=0; 590 int inb=0; 591 loopOnInputs: 588 592 if(type==1){ 589 593 while(out1!=NULL){ … … 597 601 result=out1->name; 598 602 } 603 inb++; 599 604 out1=out1->next; 600 605 } 601 606 if(res!=NULL){ 607 fflush(stderr); 602 608 *err=res; 603 609 return result; 604 610 } 605 out1=*out; 611 if(out1==NULL && inb>=1) 612 out1=*out; 606 613 } 607 614 while(tmpInputs!=NULL){ 608 615 maps *tmpMaps=getMaps(out1,tmpInputs->name); 609 616 if(tmpMaps==NULL){ 610 maps* tmpMaps2=(maps*)malloc(MAPS_SIZE); 611 tmpMaps2->name=strdup(tmpInputs->name); 612 tmpMaps2->content=NULL; 613 tmpMaps2->next=NULL; 614 617 maps* tmpMaps2=createMaps(tmpInputs->name); 615 618 if(type==0){ 616 619 map* tmpMapMinO=getMap(tmpInputs->content,"minOccurs"); … … 651 654 } 652 655 } 653 656 654 657 if(res==NULL){ 655 658 iotype* tmpIoType=tmpInputs->defaults; … … 685 688 } 686 689 else{ 687 iotype* tmpIoType=getIoTypeFromElement(tmpInputs,tmpInputs->name, 688 tmpMaps->content); 689 if(type==0) { 690 /** 691 * In case of an Input maps, then add the minOccurs and maxOccurs to the 692 * content map. 693 */ 694 map* tmpMap1=getMap(tmpInputs->content,"minOccurs"); 695 if(tmpMap1!=NULL){ 696 if(tmpMaps->content==NULL) 697 tmpMaps->content=createMap("minOccurs",tmpMap1->value); 698 else 699 addToMap(tmpMaps->content,"minOccurs",tmpMap1->value); 700 } 701 map* tmpMaxO=getMap(tmpInputs->content,"maxOccurs"); 702 if(tmpMaxO!=NULL){ 703 if(tmpMaps->content==NULL) 704 tmpMaps->content=createMap("maxOccurs",tmpMaxO->value); 705 else 706 addToMap(tmpMaps->content,"maxOccurs",tmpMaxO->value); 707 } 708 map* tmpMaxMB=getMap(tmpInputs->content,"maximumMegabytes"); 709 if(tmpMaxMB!=NULL){ 710 if(tmpMaps->content==NULL) 711 tmpMaps->content=createMap("maximumMegabytes",tmpMaxMB->value); 712 else 713 addToMap(tmpMaps->content,"maximumMegabytes",tmpMaxMB->value); 714 } 715 /** 716 * Parsing BoundingBoxData, fill the following map and then add it to 717 * the content map of the Input maps: 718 * lowerCorner, upperCorner, srs and dimensions 719 * cf. parseBoundingBox 720 */ 721 if(tmpInputs->format!=NULL && strcasecmp(tmpInputs->format,"BoundingBoxData")==0){ 722 maps* tmpI=getMaps(*out,tmpInputs->name); 723 if(tmpI!=NULL){ 724 map* tmpV=getMap(tmpI->content,"value"); 725 if(tmpV!=NULL){ 726 char *tmpVS=strdup(tmpV->value); 727 map* tmp=parseBoundingBox(tmpVS); 728 free(tmpVS); 729 map* tmpC=tmp; 730 while(tmpC!=NULL){ 731 addToMap(tmpMaps->content,tmpC->name,tmpC->value); 732 tmpC=tmpC->next; 690 iotype* tmpIoType=NULL; 691 if(tmpMaps->content!=NULL){ 692 tmpIoType=getIoTypeFromElement(tmpInputs,tmpInputs->name, 693 tmpMaps->content); 694 if(type==0) { 695 /** 696 * In case of an Input maps, then add the minOccurs and maxOccurs to the 697 * content map. 698 */ 699 map* tmpMap1=getMap(tmpInputs->content,"minOccurs"); 700 if(tmpMap1!=NULL){ 701 if(tmpMaps->content==NULL) 702 tmpMaps->content=createMap("minOccurs",tmpMap1->value); 703 else 704 addToMap(tmpMaps->content,"minOccurs",tmpMap1->value); 705 } 706 map* tmpMaxO=getMap(tmpInputs->content,"maxOccurs"); 707 if(tmpMaxO!=NULL){ 708 if(tmpMaps->content==NULL) 709 tmpMaps->content=createMap("maxOccurs",tmpMaxO->value); 710 else 711 addToMap(tmpMaps->content,"maxOccurs",tmpMaxO->value); 712 } 713 map* tmpMaxMB=getMap(tmpInputs->content,"maximumMegabytes"); 714 if(tmpMaxMB!=NULL){ 715 if(tmpMaps->content==NULL) 716 tmpMaps->content=createMap("maximumMegabytes",tmpMaxMB->value); 717 else 718 addToMap(tmpMaps->content,"maximumMegabytes",tmpMaxMB->value); 719 } 720 /** 721 * Parsing BoundingBoxData, fill the following map and then add it to 722 * the content map of the Input maps: 723 * lowerCorner, upperCorner, srs and dimensions 724 * cf. parseBoundingBox 725 */ 726 if(tmpInputs->format!=NULL && strcasecmp(tmpInputs->format,"BoundingBoxData")==0){ 727 maps* tmpI=getMaps(*out,tmpInputs->name); 728 if(tmpI!=NULL){ 729 map* tmpV=getMap(tmpI->content,"value"); 730 if(tmpV!=NULL){ 731 char *tmpVS=strdup(tmpV->value); 732 map* tmp=parseBoundingBox(tmpVS); 733 free(tmpVS); 734 map* tmpC=tmp; 735 while(tmpC!=NULL){ 736 addToMap(tmpMaps->content,tmpC->name,tmpC->value); 737 tmpC=tmpC->next; 738 } 739 freeMap(&tmp); 740 free(tmp); 733 741 } 734 freeMap(&tmp);735 free(tmp);736 742 } 737 743 } 744 } 745 }else{ 746 if(tmpInputs!=NULL){ 747 tmpIoType=tmpInputs->defaults; 738 748 } 739 749 } … … 807 817 else 808 818 addToMap(tmpMaps->content,"inRequest","true"); 809 810 } 811 tmpInputs=tmpInputs->next; 819 elements* tmpElements=getElements(in,tmpMaps->name); 820 if(tmpMaps->child!=NULL and tmpElements!=NULL and tmpElements->child!=NULL){ 821 char *res=addDefaultValues(&tmpMaps->child,tmpElements->child,m,type,err); 822 if(strlen(res)>0){ 823 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 824 return res; 825 } 826 } 827 } 828 if(tmpInputs->child!=NULL){ 829 tmpInputss=tmpInputs->next; 830 tmpInputs=tmpInputs->child; 831 if(tmpMaps!=NULL){ 832 out1=tmpMaps->child; 833 out1s=tmpMaps; 834 } 835 }else 836 tmpInputs=tmpInputs->next; 837 } 838 if(tmpInputss!=NULL){ 839 out1=out1s; 840 tmpInputs=tmpInputss; 841 tmpInputss=NULL; 842 out1s=NULL; 843 goto loopOnInputs; 812 844 } 813 845 if(res!=NULL){ … … 879 911 maps *res = (maps *) malloc (MAPS_SIZE); 880 912 conf_read (fbkpid, res); 913 res->child=NULL; 881 914 map* status=getMapFromMaps(res,"status","status"); 882 915 addToMap(statusInfo,"Status",status->value); -
trunk/zoo-project/zoo-kernel/service.c
r757 r790 74 74 75 75 /** 76 * Dump a map to a file 76 * Dump a map to a file 77 77 * 78 78 * @param t the map to dump to file 79 * @param file the file to store the map79 * @param file the file pointer to store the map 80 80 */ 81 81 void dumpMapToFile(map* t,FILE* file){ … … 96 96 while(tmp!=NULL){ 97 97 fprintf(stderr,"MAP => [%s] \n",tmp->name); 98 fprintf(stderr," * CONTENT [%s] \n",tmp->name); 98 99 dumpMap(tmp->content); 100 fprintf(stderr," * CHILD [%s] \n",tmp->name); 101 dumpMaps(tmp->child); 99 102 tmp=tmp->next; 100 103 } … … 105 108 * 106 109 * @param m the map to dump 107 * @param file_path the full path to the file name to store the map 108 */ 109 void dumpMapsToFile(maps* m,char* file_path,int limit){ 110 FILE* file=fopen(file_path,"w+"); 110 * @param file the the file pointer to store the map 111 */ 112 void _dumpMapsToFile(maps* m,FILE* file,int limit){ 111 113 maps* tmp=m; 112 114 int cnt=0; 113 115 while(tmp!=NULL){ 114 116 fprintf(file,"[%s]\n",tmp->name); 115 dumpMapToFile(tmp->content,file); 117 if(tmp->child!=NULL){ 118 _dumpMapsToFile(tmp->child,file,limit); 119 }else 120 dumpMapToFile(tmp->content,file); 116 121 fflush(file); 117 122 tmp=tmp->next; … … 121 126 } 122 127 fflush(file); 128 } 129 130 /** 131 * Dump a maps to a file, see _dumpMapsToFile(). 132 * 133 * @param m the map to dump 134 * @param file_path the full path to the file name to store the map 135 * @param limit the number limiting the maps to be dumped 136 */ 137 void dumpMapsToFile(maps* m,char* file_path,int limit){ 138 FILE* file=fopen(file_path,"w+"); 139 _dumpMapsToFile(m,file,limit); 140 fflush(file); 123 141 fclose(file); 124 142 } … … 129 147 * @param name the key to add to the map 130 148 * @param value the corresponding value to add to the map 131 * @return the allocated map149 * @return a pointer to the allocated map 132 150 */ 133 151 map* createMap(const char* name,const char* value){ … … 136 154 tmp->value=zStrdup(value); 137 155 tmp->next=NULL; 156 return tmp; 157 } 158 159 /** 160 * Create a new maps with the given name 161 * 162 * @param name of the maps 163 * @return the allocated map 164 */ 165 maps* createMaps(const char* name){ 166 maps* tmp = (maps *) malloc (MAPS_SIZE); 167 tmp->name = zStrdup (name); 168 tmp->content = NULL; 169 tmp->child = NULL; 170 tmp->next = NULL; 138 171 return tmp; 139 172 } … … 283 316 freeMap(&_cursor->content); 284 317 free(_cursor->content); 318 } 319 if(_cursor->child!=NULL){ 320 freeMaps(&_cursor->child); 321 free(_cursor->child); 285 322 } 286 323 if(_cursor->next!=NULL){ … … 362 399 if(tmp->format!=NULL) 363 400 free(tmp->format); 401 if(tmp->child!=NULL){ 402 freeElements(&tmp->child); 403 free(tmp->child); 404 } 364 405 freeIOType(&tmp->defaults); 365 406 if(tmp->defaults!=NULL) … … 593 634 iotype* getIoTypeFromElement(elements* e,char *name, map* values){ 594 635 elements* cursor=e; 595 while(cursor!=NULL){ 596 if(strcasecmp(cursor->name,name)==0){ 597 if(contains(cursor->defaults->content,values)==true) 598 return cursor->defaults; 599 else{ 600 iotype* tmp=cursor->supported; 601 while(tmp!=NULL){ 602 if(contains(tmp->content,values)==true) 603 return tmp; 604 tmp=tmp->next; 636 if(values!=NULL) 637 while(cursor!=NULL){ 638 if(strcasecmp(cursor->name,name)==0 && (cursor->defaults!=NULL || cursor->supported!=NULL)){ 639 if(contains(cursor->defaults->content,values)==true) 640 return cursor->defaults; 641 else{ 642 iotype* tmp=cursor->supported; 643 while(tmp!=NULL){ 644 if(contains(tmp->content,values)==true) 645 return tmp; 646 tmp=tmp->next; 647 } 605 648 } 606 649 } 607 } 608 cursor=cursor->next; 609 } 650 cursor=cursor->next; 651 } 610 652 return NULL; 611 653 } … … 677 719 maps* res=NULL; 678 720 if(_cursor!=NULL){ 679 res=(maps*)malloc(MAPS_SIZE); 680 res->name=zStrdup(_cursor->name); 681 res->content=NULL; 682 res->next=NULL; 721 res=createMaps(_cursor->name); 683 722 map* mc=_cursor->content; 684 723 if(mc!=NULL){ 685 724 addMapToMap(&res->content,mc); 686 725 loadMapBinaries(&res->content,mc); 726 } 727 maps* mcs=_cursor->child; 728 if(mcs!=NULL){ 729 res->child=dupMaps(&mcs); 687 730 } 688 731 res->next=dupMaps(&_cursor->next); … … 709 752 _cursor=_cursor->next; 710 753 maps* tmp1=getMaps(*mo,tmp->name); 711 if(tmp1==NULL) 754 if(tmp1==NULL){ 712 755 _cursor->next=dupMaps(&tmp); 713 else 756 if(tmp->child!=NULL) 757 _cursor->next->child=dupMaps(&tmp->child); 758 else 759 _cursor->next->child=NULL; 760 } 761 else{ 714 762 addMapToMap(&tmp1->content,tmp->content); 763 if(tmp->child!=NULL) 764 tmp1->child=dupMaps(&tmp->child); 765 else 766 tmp1->child=NULL; 767 } 715 768 _cursor=*mo; 716 769 } … … 872 925 _ztmpm->value=zStrdup(value); 873 926 }else{ 874 maps *tmp=(maps*)malloc(MAPS_SIZE); 875 tmp->name=zStrdup(key); 927 maps *tmp=createMaps(key); 876 928 tmp->content=createMap(subkey,value); 877 tmp->next=NULL;878 929 addMapsToMaps(&_tmpm,tmp); 879 930 freeMaps(&tmp); … … 881 932 } 882 933 }else{ 883 maps *tmp=(maps*)malloc(MAPS_SIZE); 884 tmp->name=zStrdup(key); 934 maps *tmp=createMaps(key); 885 935 tmp->content=createMap(subkey,value); 886 tmp->next=NULL;887 936 addMapsToMaps(&m,tmp); 888 937 freeMaps(&tmp); 889 938 free(tmp); 890 939 } 940 } 941 942 /** 943 * Create an empty elements 944 * 945 * @return a pointer to the allocated elements 946 */ 947 elements* createEmptyElements(){ 948 elements* res=(elements*)malloc(ELEMENTS_SIZE); 949 res->name=NULL; 950 res->content=NULL; 951 res->metadata=NULL; 952 res->format=NULL; 953 res->defaults=NULL; 954 res->supported=NULL; 955 res->child=NULL; 956 res->next=NULL; 957 return res; 958 } 959 960 /** 961 * Create a named elements 962 * 963 * @param name the elements name 964 * @return a pointer to the allocated elements 965 */ 966 elements* createElements(char* name){ 967 elements* res=(elements*)malloc(ELEMENTS_SIZE); 968 res->name=zStrdup(name); 969 res->content=NULL; 970 res->metadata=NULL; 971 res->format=NULL; 972 res->defaults=NULL; 973 res->supported=NULL; 974 res->child=NULL; 975 res->next=NULL; 976 return res; 977 } 978 979 /** 980 * Set the name of an elements 981 * 982 * @param name the elements name 983 * @return a pointer to the allocated elements 984 */ 985 void setElementsName(elements** elem,char* name){ 986 elements* res=*elem; 987 res->name=zStrdup(name); 988 res->content=NULL; 989 res->metadata=NULL; 990 res->format=NULL; 991 res->defaults=NULL; 992 res->supported=NULL; 993 res->child=NULL; 994 res->next=NULL; 891 995 } 892 996 … … 921 1025 ioc++; 922 1026 } 1027 if(tmp->child!=NULL){ 1028 fprintf(stderr," > CHILD \n"); 1029 dumpElements(tmp->child); 1030 } 923 1031 fprintf(stderr,"------------------\n"); 924 1032 tmp=tmp->next; … … 931 1039 * @param e the elements to dump 932 1040 */ 933 void dumpElementsAsYAML(elements* e ){1041 void dumpElementsAsYAML(elements* e,int level){ 934 1042 elements* tmp=e; 935 1043 int i; 936 1044 while(tmp!=NULL){ 937 for(i=0;i<2 ;i++)1045 for(i=0;i<2+(4*level);i++) 938 1046 fprintf(stderr," "); 939 1047 fprintf(stderr,"%s:\n",tmp->name); 940 1048 map* mcurs=tmp->content; 941 1049 while(mcurs!=NULL){ 942 for(i=0;i<4 ;i++)1050 for(i=0;i<4+(4*level);i++) 943 1051 fprintf(stderr," "); 944 1052 _dumpMap(mcurs); … … 947 1055 mcurs=tmp->metadata; 948 1056 if(mcurs!=NULL){ 949 for(i=0;i<4 ;i++)1057 for(i=0;i<4+(4*level);i++) 950 1058 fprintf(stderr," "); 951 1059 fprintf(stderr,"MetaData:\n"); 952 1060 while(mcurs!=NULL){ 953 for(i=0;i<6 ;i++)1061 for(i=0;i<6+(4*level);i++) 954 1062 fprintf(stderr," "); 955 1063 _dumpMap(mcurs); … … 957 1065 } 958 1066 } 959 for(i=0;i<4 ;i++)1067 for(i=0;i<4+(4*level);i++) 960 1068 fprintf(stderr," "); 961 fprintf(stderr,"%s:\n",tmp->format); 1069 if(tmp->format!=NULL) 1070 fprintf(stderr,"%s:\n",tmp->format); 1071 else{ 1072 fprintf(stderr,"Child:\n"); 1073 if(tmp->child!=NULL) 1074 dumpElementsAsYAML(tmp->child,level+1); 1075 } 962 1076 iotype* tmpio=tmp->defaults; 963 1077 int ioc=0; 964 1078 while(tmpio!=NULL){ 965 for(i=0;i<6 ;i++)1079 for(i=0;i<6+(4*level);i++) 966 1080 fprintf(stderr," "); 967 1081 fprintf(stderr,"default:\n"); 968 1082 mcurs=tmpio->content; 969 1083 while(mcurs!=NULL){ 970 for(i=0;i<8 ;i++)1084 for(i=0;i<8+(4*level);i++) 971 1085 fprintf(stderr," "); 972 1086 if(strcasecmp(mcurs->name,"range")==0){ … … 982 1096 ioc=0; 983 1097 while(tmpio!=NULL){ 984 for(i=0;i<6 ;i++)1098 for(i=0;i<6+(4*level);i++) 985 1099 fprintf(stderr," "); 986 1100 fprintf(stderr,"supported:\n"); 987 1101 mcurs=tmpio->content; 988 1102 while(mcurs!=NULL){ 989 for(i=0;i<8 ;i++)1103 for(i=0;i<8+(4*level);i++) 990 1104 fprintf(stderr," "); 991 1105 if(strcasecmp(mcurs->name,"range")==0){ … … 1055 1169 else 1056 1170 tmp->supported=NULL; 1171 if(cursor->child!=NULL) 1172 tmp->child=dupElements(cursor->child); 1173 else 1174 tmp->child=NULL; 1057 1175 tmp->next=dupElements(cursor->next); 1058 1176 } … … 1075 1193 } 1076 1194 } 1077 1195 1196 /** 1197 * Set the name of a service 1198 * 1199 * @param name the service name 1200 */ 1201 void setServiceName(service** serv,char* name){ 1202 service* res=*serv; 1203 res->name=zStrdup(name); 1204 res->content=NULL; 1205 res->metadata=NULL; 1206 res->inputs=NULL; 1207 res->outputs=NULL; 1208 } 1209 1078 1210 /** 1079 1211 * Dump a service on stderr … … 1126 1258 if(s->inputs!=NULL){ 1127 1259 fprintf(stderr,"\ninputs:\n"); 1128 dumpElementsAsYAML(s->inputs );1260 dumpElementsAsYAML(s->inputs,0); 1129 1261 } 1130 1262 if(s->outputs!=NULL){ 1131 1263 fprintf(stderr,"\noutputs:\n"); 1132 dumpElementsAsYAML(s->outputs );1264 dumpElementsAsYAML(s->outputs,0); 1133 1265 } 1134 1266 } -
trunk/zoo-project/zoo-kernel/service.h
r788 r790 154 154 */ 155 155 //#define MAPS_SIZE (2*sizeof(char*))+sizeof(map*)+MAP_SIZE 156 #define MAPS_SIZE sizeof(char*)+sizeof(map*)+ sizeof(maps*)156 #define MAPS_SIZE sizeof(char*)+sizeof(map*)+(2*sizeof(maps*)) 157 157 /** 158 158 * The memory size to create a service … … 205 205 char* name; //!< the maps name 206 206 struct map* content; //!< the content map 207 struct maps* child; //!< the child maps 207 208 struct maps* next; //!< the pointer to the next maps if any or NULL 208 209 } maps; … … 268 269 ZOO_DLL_EXPORT void dumpMapsToFile(maps*,char*,int); 269 270 ZOO_DLL_EXPORT map* createMap(const char*,const char*); 271 ZOO_DLL_EXPORT maps* createMaps(const char*); 270 272 ZOO_DLL_EXPORT int count(map*); 271 273 ZOO_DLL_EXPORT bool hasKey(map*,const char*); … … 278 280 279 281 282 ZOO_DLL_EXPORT elements* createEmptyElements(); 283 ZOO_DLL_EXPORT elements* createElements(char*); 284 ZOO_DLL_EXPORT void setElementsName(elements**,char*); 280 285 ZOO_DLL_EXPORT bool hasElement(elements*,const char*); 281 286 ZOO_DLL_EXPORT elements* getElements(elements*,char*); 282 287 ZOO_DLL_EXPORT void freeIOType(iotype**); 283 288 ZOO_DLL_EXPORT void freeElements(elements**); 289 ZOO_DLL_EXPORT void setServiceName(service**,char*); 284 290 ZOO_DLL_EXPORT void freeService(service**); 285 291 ZOO_DLL_EXPORT void addToMap(map*,const char*,const char*); … … 301 307 ZOO_DLL_EXPORT void setMapInMaps(maps*,const char*,const char*,const char*); 302 308 ZOO_DLL_EXPORT void dumpElements(elements*); 303 ZOO_DLL_EXPORT void dumpElementsAsYAML(elements* );309 ZOO_DLL_EXPORT void dumpElementsAsYAML(elements*,int); 304 310 ZOO_DLL_EXPORT elements* dupElements(elements*); 305 311 ZOO_DLL_EXPORT void addToElements(elements**,elements*); -
trunk/zoo-project/zoo-kernel/service_conf.y
r788 r790 34 34 static bool wait_mainmetadata=false; 35 35 static bool wait_metadata=false; 36 static bool wait_nested=false; 36 37 static bool wait_inputs=false; 37 38 static bool wait_defaults=false; … … 47 48 static int previous_data=0; 48 49 static int current_data=0; 50 static int nested_level=0; 49 51 // namespace 50 52 using namespace std; … … 145 147 dumpMap(current_content); 146 148 #endif 147 if(my_service->content==NULL ){149 if(my_service->content==NULL && current_content!=NULL){ 148 150 #ifdef DEBUG_SERVICE_CONF 149 151 fprintf(stderr,"NO CONTENT\n"); … … 156 158 wait_maincontent=false; 157 159 } 160 if(strncasecmp($2,"EndNested",9)==0){ 161 #ifdef DEBUG_SERVICE_CONF 162 fprintf(stderr,"(ENDNESTED - %d) \n",__LINE__); 163 fflush(stderr); 164 #endif 165 nested_level-=1; 166 if(nested_level==0){ 167 wait_nested=false; 168 } 169 } 170 158 171 if(strncasecmp($2,"DataInputs",10)==0){ 159 172 if(current_element==NULL){ … … 167 180 #endif 168 181 current_element=NULL; 169 current_element=(elements*)malloc(ELEMENTS_SIZE); 170 current_element->name=NULL; 171 current_element->content=NULL; 172 current_element->metadata=NULL; 173 current_element->format=NULL; 174 current_element->defaults=NULL; 175 current_element->supported=NULL; 176 current_element->child=NULL; 177 current_element->next=NULL; 182 current_element=createEmptyElements(); 178 183 } 179 184 wait_inputs=true; … … 217 222 fflush(stderr); 218 223 #endif 219 current_element=(elements*)malloc(ELEMENTS_SIZE); 220 current_element->name=NULL; 221 current_element->content=NULL; 222 current_element->metadata=NULL; 223 current_element->format=NULL; 224 current_element->defaults=NULL; 225 current_element->supported=NULL; 226 current_element->child=NULL; 227 current_element->next=NULL; 224 current_element=createEmptyElements(); 228 225 } 229 226 wait_outputs=1; … … 269 266 current_element->defaults=NULL; 270 267 current_element->supported=NULL; 268 current_element->child=NULL; 271 269 current_content=NULL; 272 270 } … … 285 283 } 286 284 #ifdef DEBUG_SERVICE_CONF 287 printf("* Identifiant : %s\n",$2);288 fflush(std out);285 fprintf(stderr,"* Identifiant : %s\n",$2); 286 fflush(stderr); 289 287 #endif 290 288 } … … 340 338 current_content=NULL; 341 339 current_element->supported=NULL; 340 current_element->child=NULL; 342 341 current_element->next=NULL; 342 } 343 if(strncasecmp($2,"EndNested",9)==0){ 344 if(current_data==1){ 345 elements* cursor=my_service->inputs; 346 while(cursor->next!=NULL) 347 cursor=cursor->next; 348 if(nested_level>1){ 349 for(int j=0;j<nested_level-1;j++){ 350 cursor=cursor->child; 351 while(cursor->next!=NULL) 352 cursor=cursor->next; 353 } 354 } 355 if(cursor->child==NULL){ 356 cursor->child=dupElements(current_element); 357 }else{ 358 addToElements(&cursor->child,current_element); 359 } 360 }else{ 361 if(current_element->name!=NULL){ 362 elements* cursor=my_service->outputs; 363 while(cursor->next!=NULL) 364 cursor=cursor->next; 365 if(nested_level>1){ 366 for(int j=0;j<nested_level-1;j++){ 367 cursor=cursor->child; 368 while(cursor->next!=NULL) 369 cursor=cursor->next; 370 } 371 } 372 if(cursor->child==NULL){ 373 cursor->child=dupElements(current_element); 374 }else 375 addToElements(&cursor->child,current_element); 376 } 377 } 378 freeElements(¤t_element); 379 free(current_element); 380 current_element=NULL; 381 current_element=createEmptyElements(); 382 nested_level-=1; 383 if(nested_level==0){ 384 wait_nested=false; 385 } 343 386 } 344 387 } … … 395 438 current_element->defaults=NULL; 396 439 current_element->supported=NULL; 440 current_element->child=NULL; 397 441 }else{ 398 442 if(wait_mainmetadata){ … … 428 472 current_content=NULL; 429 473 current_element->supported=NULL; 474 current_element->child=NULL; 430 475 current_element->next=NULL; 431 476 } … … 443 488 }else{ 444 489 current_element->supported=NULL; 490 current_element->child=NULL; 445 491 current_element->next=NULL; 446 492 } … … 553 599 fprintf(stderr,"processid (%s %d) %s\n",__FILE__,__LINE__,$1); 554 600 #endif 555 // if(data==-1){556 // data=1;557 601 if(::data==-1){ // knut: add namespace to avoid ambiguous symbol 558 602 ::data=1; 559 603 if($1!=NULL){ 560 604 char *cen=zStrdup($1); 561 my_service->name=(char*)malloc((strlen(cen)-1)*sizeof(char*));562 605 cen[strlen(cen)-1]=0; 563 606 cen+=1; 564 s printf(my_service->name,"%s",cen);607 setServiceName(&my_service,cen); 565 608 cen-=1; 566 609 free(cen); 567 my_service->content=NULL;568 my_service->metadata=NULL;569 my_service->inputs=NULL;570 my_service->outputs=NULL;571 610 } 572 611 } else { … … 579 618 } 580 619 else{ 581 addToElements(&my_service->inputs,current_element); 620 if(wait_nested){ 621 elements* cursor=my_service->inputs; 622 while(cursor->next!=NULL) 623 cursor=cursor->next; 624 if(nested_level>1){ 625 for(int j=0;j<nested_level-1;j++){ 626 cursor=cursor->child; 627 while(cursor->next!=NULL) 628 cursor=cursor->next; 629 } 630 } 631 if(cursor->child==NULL){ 632 cursor->child=dupElements(current_element); 633 }else{ 634 addToElements(&cursor->child,current_element); 635 } 636 }else 637 addToElements(&my_service->inputs,current_element); 638 } 639 if(current_element->format==NULL){ 640 wait_nested=true; 641 nested_level+=1; 642 if(current_content!=NULL){ 643 elements* cursor=my_service->inputs; 644 while(cursor->next!=NULL) 645 cursor=cursor->next; 646 if(nested_level>1){ 647 for(int j=0;j<nested_level-1;j++){ 648 cursor=cursor->child; 649 while(cursor->next!=NULL) 650 cursor=cursor->next; 651 } 652 } 653 addMapToMap(&cursor->content,current_content); 654 freeMap(¤t_content); 655 free(current_content); 656 current_content=NULL; 657 } 582 658 } 583 659 #ifdef DEBUG_SERVICE_CONF … … 593 669 fprintf(stderr,"(DATAINPUTS - 489) ALLOCATE current_element\n"); 594 670 #endif 595 current_element=(elements*)malloc(ELEMENTS_SIZE); 596 current_element->name=NULL; 597 current_element->content=NULL; 598 current_element->metadata=NULL; 599 current_element->format=NULL; 600 current_element->defaults=NULL; 601 current_element->supported=NULL; 602 current_element->next=NULL; 671 current_element=createEmptyElements(); 603 672 } 604 673 if(current_element->name==NULL){ … … 613 682 if($1!=NULL){ 614 683 char *cen=zStrdup($1); 615 current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char*));616 684 cen[strlen(cen)-1]=0; 617 685 cen+=1; 618 s printf(current_element->name,"%s",cen);686 setElementsName(¤t_element,cen); 619 687 cen-=1; 620 688 free(cen); … … 622 690 fprintf(stderr,"NAME IN %s (current - %s)\n",$1,current_element->name); 623 691 #endif 624 current_element->content=NULL;625 current_element->metadata=NULL;626 current_element->format=NULL;627 current_element->defaults=NULL;628 current_element->supported=NULL;629 current_element->next=NULL;630 692 #ifdef DEBUG_SERVICE_CONF 631 693 fprintf(stderr,"NAME IN %s (current - %s)\n",$1,current_element->name); … … 659 721 fprintf(stderr,"(DATAOUTPUTS -%d) ALLOCATE current_element %s \n",__LINE__,__FILE__); 660 722 #endif 661 current_element=(elements*)malloc(ELEMENTS_SIZE); 662 current_element->name=NULL; 663 current_element->content=NULL; 664 current_element->metadata=NULL; 665 current_element->format=NULL; 666 current_element->defaults=NULL; 667 current_element->supported=NULL; 668 current_element->next=NULL; 723 current_element=createEmptyElements(); 669 724 } 670 725 if(current_element->name==NULL){ … … 675 730 if($1!=NULL){ 676 731 char *cen=zStrdup($1); 677 current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char));678 732 cen[strlen(cen)-1]=0; 679 733 cen+=1; 680 s printf(current_element->name,"%s",cen);734 setElementsName(¤t_element,cen); 681 735 cen-=1; 682 736 free(cen); 683 current_element->content=NULL;684 current_element->metadata=NULL;685 current_element->format=NULL;686 current_element->defaults=NULL;687 current_element->supported=NULL;688 current_element->next=NULL;689 737 } 690 738 } … … 696 744 if(my_service->outputs==NULL) 697 745 my_service->outputs=dupElements(current_element); 698 else 699 addToElements(&my_service->outputs,current_element); 746 else{ 747 if(wait_nested){ 748 elements* cursor=my_service->outputs; 749 while(cursor->next!=NULL) 750 cursor=cursor->next; 751 if(nested_level>1){ 752 for(int j=0;j<nested_level-1;j++){ 753 cursor=cursor->child; 754 while(cursor->next!=NULL) 755 cursor=cursor->next; 756 } 757 } 758 if(cursor->child==NULL){ 759 cursor->child=dupElements(current_element); 760 }else 761 addToElements(&cursor->child,current_element); 762 }else 763 addToElements(&my_service->outputs,current_element); 764 } 765 if(current_element->format==NULL){ 766 wait_nested=true; 767 nested_level+=1; 768 if(current_content!=NULL){ 769 elements* cursor=my_service->outputs; 770 while(cursor->next!=NULL) 771 cursor=cursor->next; 772 if(nested_level>1){ 773 for(int j=0;j<nested_level-1;j++){ 774 cursor=cursor->child; 775 while(cursor->next!=NULL) 776 cursor=cursor->next; 777 } 778 } 779 addMapToMap(&cursor->content,current_content); 780 freeMap(¤t_content); 781 free(current_content); 782 current_content=NULL; 783 } 784 } 785 700 786 #ifdef DEBUG_SERVICE_CONF 701 787 fprintf(stderr,"ADD TO OUTPUTS Elements\n"); … … 705 791 free(current_element); 706 792 current_element=NULL; 707 current_element=(elements*)malloc(ELEMENTS_SIZE);793 708 794 char *cen=zStrdup($1); 709 current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char));710 795 cen[strlen(cen)-1]=0; 711 796 cen+=1; 712 sprintf(current_element->name,"%s",cen);797 current_element=createElements(cen); 713 798 cen-=1; 714 799 free(cen); 715 current_element->content=NULL;716 current_element->metadata=NULL;717 current_element->format=NULL;718 current_element->defaults=NULL;719 current_element->supported=NULL;720 current_element->next=NULL;721 800 } 722 801 else{ … … 727 806 if($1!=NULL){ 728 807 char *cen=zStrdup($1); 729 current_element->name=(char*)malloc((strlen(cen))*sizeof(char*));730 808 cen[strlen(cen)-1]=0; 731 809 #ifdef DEBUG … … 733 811 #endif 734 812 cen+=1; 735 s printf(current_element->name,"%s",cen);813 setElementsName(¤t_element,cen); 736 814 cen-=1; 737 815 free(cen); 738 current_element->content=NULL;739 current_element->metadata=NULL;740 current_element->format=NULL;741 current_element->defaults=NULL;742 current_element->supported=NULL;743 current_element->next=NULL;744 816 } 745 817 } … … 780 852 } 781 853 #ifdef DEBUG_SERVICE_CONF 782 fprintf(stderr,"(STARTING)FREE current_element\n"); 783 #endif 854 fprintf(stderr,"(STARTING)FREE current_element %s\n",file); 855 #endif 856 fflush(stderr); 857 fflush(stdout); 784 858 if(current_element!=NULL){ 785 859 freeElements(¤t_element); … … 797 871 wait_outputs=-1; 798 872 wait_data=false; 873 wait_nested=false; 799 874 //data=-1; 800 875 ::data=-1; // knut: add namespace to avoid ambiguous symbol … … 831 906 fprintf(stderr,"(DATAOUTPUTS - %d) COPY current_element\n",__LINE__); 832 907 #endif 833 addToElements(&my_service->outputs,current_element); 908 if(wait_nested){ 909 elements* cursor=my_service->outputs; 910 while(cursor->next!=NULL) 911 cursor=cursor->next; 912 if(nested_level>1){ 913 for(int j=0;j<nested_level-1;j++){ 914 cursor=cursor->child; 915 while(cursor->next!=NULL) 916 cursor=cursor->next; 917 } 918 } 919 if(cursor->child==NULL){ 920 cursor->child=dupElements(current_element); 921 }else 922 addToElements(&cursor->child,current_element); 923 }else 924 addToElements(&my_service->outputs,current_element); 834 925 } 835 926 #ifdef DEBUG_SERVICE_CONF -
trunk/zoo-project/zoo-kernel/service_internal_java.c
r781 r790 251 251 if (pValue != (jint)NULL){ 252 252 res=pValue; 253 m=mapsFromHashMap(env,arg1,scHashMapClass); 254 *main_conf=m; 255 outputs=mapsFromHashMap(env,arg3,scHashMapClass); 256 *real_outputs=outputs; 257 253 freeMaps(real_outputs); 254 free(*real_outputs); 255 freeMaps(main_conf); 256 free(*main_conf); 257 *main_conf=mapsFromHashMap(env,arg1,scHashMapClass); 258 *real_outputs=mapsFromHashMap(env,arg3,scHashMapClass); 258 259 #ifdef DEBUG 259 260 fprintf(stderr,"Result of call: %i\n", pValue); … … 757 758 jobject jk=(*env)->CallObjectMethod(env,tmp,getKey_mid); 758 759 #endif 759 maps* cmap=(maps*)malloc(sizeof(maps)); 760 #ifdef JAVA7 761 cmap->name=(char*)(*env).GetStringUTFChars((jstring)jk, NULL); 762 #else 763 cmap->name=(*env)->GetStringUTFChars(env, jk, NULL); 764 #endif 760 maps* cmap=createMaps( 761 #ifdef JAVA7 762 (char*)(*env).GetStringUTFChars((jstring)jk, NULL) 763 #else 764 (*env)->GetStringUTFChars(env, jk, NULL) 765 #endif 766 ); 765 767 #ifdef DEBUG 766 768 fprintf(stderr," / %s \n",cmap->name); 767 769 #endif 768 770 cmap->content=res; 769 cmap->next=NULL;770 771 if(final_res==NULL) 771 772 final_res=dupMaps(&cmap); … … 780 781 fprintf(stderr,"mapsFromHashMap end\n"); 781 782 #endif 782 783 783 return final_res; 784 784 } -
trunk/zoo-project/zoo-kernel/service_internal_js.c
r784 r790 425 425 while(tmp!=NULL){ 426 426 JSObject *pval=JSObject_FromMap(cx,tmp->content); 427 if(tmp->child!=NULL){ 428 JSObject *pvalc=JSObject_FromMaps(cx,tmp->child); 429 jsval pvaljc=OBJECT_TO_JSVAL(pvalc); 430 JS_SetProperty(cx, pval, "child", &pvaljc); 431 } 427 432 jsval pvalj=OBJECT_TO_JSVAL(pval); 428 433 JS_SetProperty(cx, res, tmp->name, &pvalj); … … 548 553 549 554 tmp=JS_EncodeString(cx,jsmsg); 550 tres=(maps*)malloc(MAPS_SIZE); 551 tres->name=zStrdup(tmp); 552 tres->content=NULL; 553 tres->next=NULL; 555 tres=createMaps(tmp); 554 556 555 557 jsval nvp=JSVAL_NULL; … … 567 569 } 568 570 571 jsval nvp0=JSVAL_NULL; 572 JSObject *nvp01=JSVAL_TO_OBJECT(JSVAL_NULL); 573 if((JS_GetProperty(cx, nvp1, "child", &nvp0)==JS_FALSE)){ 574 #ifdef JS_DEBUG 575 fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,tmp); 576 #endif 577 } 578 JS_ValueToObject(cx,nvp0,&nvp01); 579 jsval nvp01j=OBJECT_TO_JSVAL(nvp01); 580 if(!JSVAL_IS_NULL(nvp01j)){ 581 tres->child=mapsFromJSObject(cx,nvp01j); 582 } 583 569 584 if(res==NULL) 570 585 res=dupMaps(&tres); … … 574 589 free(tres); 575 590 tres=NULL; 576 577 591 } 578 592 JS_DestroyIdArray(cx,idp); … … 725 739 fprintf(stderr,"Enumerate id : %d [ %s => %s ]\n",index,tmp,tmp1); 726 740 #endif 727 if(res!=NULL){ 728 #ifdef JS_DEBUG 729 fprintf(stderr,"%s - %s\n",tmp,tmp1); 730 #endif 731 addToMap(res,tmp,tmp1); 732 } 733 else{ 734 res=createMap(tmp,tmp1); 735 res->next=NULL; 741 if(strcasecmp(tmp,"child")!=0){ 742 if(res!=NULL){ 743 #ifdef JS_DEBUG 744 fprintf(stderr,"%s - %s\n",tmp,tmp1); 745 #endif 746 addToMap(res,tmp,tmp1); 747 } 748 else{ 749 res=createMap(tmp,tmp1); 750 res->next=NULL; 751 } 736 752 } 737 753 free(tmp); -
trunk/zoo-project/zoo-kernel/service_internal_perl.c
r348 r790 105 105 int hash_to_maps(HV * hh,maps** m){ 106 106 hv_iterinit(hh); 107 *m = (maps *)malloc(MAPS_SIZE);108 107 maps * tmp = *m; 109 108 HE * he = hv_iternext(hh); … … 111 110 while (he != NULL) { 112 111 //fprintf(stderr,"key ===> %s \n",HeKEY(he)); 113 tmp ->name = HeKEY(he);112 tmp=createMaps(HeKEY(he)); 114 113 hash_to_map((HV *) SvRV(HeVAL(he)),&mm); 115 114 tmp->content = mm; 115 if(*m==NULL) 116 *m=tmp; 116 117 he = hv_iternext(hh); 117 118 if (he != NULL){ 118 tmp->next = (maps *)malloc(MAPS_SIZE);119 119 tmp= tmp->next; 120 120 } -
trunk/zoo-project/zoo-kernel/service_internal_php.c
r784 r790 306 306 while(tmp!=NULL){ 307 307 map* sMap=getMapArray(tmp,"size",0); 308 308 if(strncmp(tmp->name,"value",5)==0 && sMap!=NULL && tmp->value != NULL){ 309 309 tres=add_assoc_stringl(mapArray,tmp->name,tmp->value,atoi(sMap->value),1); 310 311 310 } 311 else if (tmp->value != NULL) { 312 312 tres=add_assoc_string(mapArray,tmp->name,tmp->value,1); 313 313 } 314 314 tmp=tmp->next; 315 315 } … … 362 362 * String Key / Associative 363 363 */ 364 cursor=(maps*)malloc(MAPS_SIZE); 365 cursor->name=strdup(key); 366 } 364 cursor=createMaps(key); 367 365 #ifdef DEBUG 368 fprintf(stderr,"key : %s\n",key);366 fprintf(stderr,"key : %s\n",key); 369 367 #endif 370 HashTable* t=HASH_OF(*ppzval); 371 #ifdef DEBUG 372 fprintf(stderr,"key : %s\n",key); 373 #endif 374 cursor->content=php_map_from_HasTable(t); 375 cursor->next=NULL; 376 if(final_res==NULL) 377 final_res=cursor; 378 else{ 379 addMapsToMaps(&final_res,cursor); 368 HashTable* t=HASH_OF(*ppzval); 369 #ifdef DEBUG 370 fprintf(stderr,"key : %s\n",key); 371 #endif 372 cursor->content=php_map_from_HasTable(t); 373 cursor->next=NULL; 374 if(final_res==NULL) 375 final_res=dupMaps(&cursor); 376 else{ 377 addMapsToMaps(&final_res,cursor); 378 } 380 379 freeMaps(&cursor); 381 380 free(cursor); -
trunk/zoo-project/zoo-kernel/service_internal_php7.c
r789 r790 355 355 HashTable* tab = HASH_OF(©); 356 356 357 maps* node = (maps*) malloc(MAPS_SIZE); 358 node->name = strdup(ZSTR_VAL(key)); 357 maps* node = createMaps(ZSTR_VAL(key)); 359 358 node->content = php_hashtable_to_map(tab); 360 node->next = NULL;361 359 362 360 if(res == NULL) { -
trunk/zoo-project/zoo-kernel/service_internal_python.c
r784 r790 356 356 if(pbt!=NULL) 357 357 free(pbt); 358 pbt=(char*)malloc((90+strlen(tpbt)+strlen(PyString_AsString(trace))+1)*sizeof(char)); 359 sprintf(pbt,_("%s\nUnable to run your python process properly. Please check the following messages : %s"),tpbt,PyString_AsString(trace)); 358 char* format=_("%s\nUnable to run your python process properly. Please check the following messages : %s"); 359 pbt=(char*)malloc((strlen(format)+strlen(tpbt)+strlen(PyString_AsString(trace))+1)*sizeof(char)); 360 sprintf(pbt,format,tpbt,PyString_AsString(trace)); 360 361 } 361 362 else{ 362 363 if(pbt!=NULL) 363 364 free(pbt); 364 pbt=(char*)malloc((90+strlen(tpbt)+strlen(PyString_AsString(trace))+1)*sizeof(char)); 365 sprintf(pbt,_("%s \n Unable to run your python process properly. Unable to provide any further information."),tpbt); 365 char* format=_("%s \n Unable to run your python process properly. Unable to provide any further information."); 366 pbt=(char*)malloc((strlen(format)+strlen(tpbt)+strlen(PyString_AsString(trace))+1)*sizeof(char)); 367 sprintf(pbt,format,tpbt); 366 368 } 367 369 free(tpbt); … … 390 392 while(tmp!=NULL){ 391 393 PyObject* value=(PyObject*)PyDict_FromMap(tmp->content); 394 if(tmp->child!=NULL){ 395 PyObject* cname=PyString_FromString("child"); 396 PyObject* childs=(PyObject*)PyDict_FromMaps(tmp->child); 397 if(PyDict_SetItem(value,cname,childs)<0){ 398 fprintf(stderr,"Unable to set map value ..."); 399 return NULL; 400 } 401 Py_DECREF(cname); 402 } 392 403 PyObject* name=PyString_FromString(tmp->name); 393 404 if(PyDict_SetItem(res,name,value)<0){ … … 543 554 PyString_AsString(key),PyString_AsString(value)); 544 555 #endif 545 cursor=(maps*)malloc(MAPS_SIZE); 546 cursor->name=zStrdup(PyString_AsString(key)); 556 cursor=createMaps(PyString_AsString(key)); 547 557 cursor->content=mapFromPyDict((PyDictObject*)value); 558 PyObject* cname=PyString_FromString("child"); 559 PyObject* childs=PyDict_GetItem((PyObject*)value,cname); 560 if(childs!=NULL) 561 cursor->child=mapsFromPyDict((PyDictObject*)childs); 562 Py_DECREF(cname); 548 563 #ifdef DEBUG 549 564 dumpMap(cursor->content); … … 626 641 PyString_AsString(key),PyString_AsString(value)); 627 642 #endif 628 629 if(strncmp(PyString_AsString(key),"value",5)==0){630 631 643 if(strncmp(PyString_AsString(key),"child",5)!=0){ 644 if(strncmp(PyString_AsString(key),"value",5)==0){ 645 char *buffer=NULL; 646 Py_ssize_t size; 632 647 #if PY_MAJOR_VERSION >= 3 633 if(PyBytes_Check(value)){ 634 size=PyBytes_Size(value); 635 buffer=PyBytes_AsString(value); 636 } 637 else 638 if(PyUnicode_Check(value) && PyUnicode_READY(value) == 0){ 639 buffer=PyUnicode_AsUTF8AndSize(value,&size); 648 if(PyBytes_Check(value)){ 649 size=PyBytes_Size(value); 650 buffer=PyBytes_AsString(value); 651 } 652 else 653 if(PyUnicode_Check(value) && PyUnicode_READY(value) == 0){ 654 buffer=PyUnicode_AsUTF8AndSize(value,&size); 655 } 656 else{ 657 #ifdef DEBUG 658 fprintf(stderr,"Unsupported return value."); 659 #endif 660 return NULL; 661 } 662 #else 663 PyString_AsStringAndSize(value,&buffer,&size); 664 #endif 665 res = addToMapWithSize(res,PyString_AsString(key),buffer,size); 666 }else{ 667 char* lkey=PyString_AsString(key); 668 char* lvalue=PyString_AsString(value); 669 if(res!=NULL){ 670 if(PyString_Size(value)>0) 671 addToMap(res,lkey,lvalue); 640 672 } 641 673 else{ 642 #ifdef DEBUG 643 fprintf(stderr,"Unsupported return value."); 644 #endif 645 return NULL; 646 } 647 #else 648 PyString_AsStringAndSize(value,&buffer,&size); 649 #endif 650 res = addToMapWithSize(res,PyString_AsString(key),buffer,size); 651 }else{ 652 char* lkey=PyString_AsString(key); 653 char* lvalue=PyString_AsString(value); 654 if(res!=NULL){ 655 if(PyString_Size(value)>0) 656 addToMap(res,lkey,lvalue); 657 } 658 else{ 659 if(PyString_Size(value)>0) 660 res=createMap(lkey,lvalue); 674 if(PyString_Size(value)>0) 675 res=createMap(lkey,lvalue); 676 } 661 677 } 662 678 } -
trunk/zoo-project/zoo-kernel/service_internal_ruby.c
r631 r790 354 354 StringValueCStr(key),StringValueCStr(value)); 355 355 #endif 356 cursor=(maps*)malloc(MAPS_SIZE); 357 cursor->name=StringValueCStr(key); 356 cursor=createMaps(StringValueCStr(key)); 358 357 cursor->content=mapFromRubyHash(value); 359 cursor->next=NULL;360 358 if(res==NULL) 361 359 res=dupMaps(&cursor); 362 360 else 363 361 addMapsToMaps(&res,cursor); 364 freeMap(&cursor->content); 365 free(cursor->content); 362 freeMaps(&cursor); 366 363 free(cursor); 367 364 } -
trunk/zoo-project/zoo-kernel/service_internal_saga.c
r760 r790 690 690 tmpName[strlen(fext)+(strlen(gfile->value)+strlen(tmpSubName)-4)]=0; 691 691 692 maps* louts=(maps*)malloc(MAPS_SIZE); 693 louts->name=zStrdup(tinOut[i]); 692 maps* louts=createMaps(tinOut[i]); 694 693 louts->content=createMap("mimeType","UNKOWN"); 695 louts->next=NULL;696 694 697 695 addToMap(arg,tinOut[i],tmpName); … … 741 739 addToMap(arg,"GRIDS",""); 742 740 743 maps* louts=(maps*)malloc(MAPS_SIZE); 744 louts->name=zStrdup("GRIDS"); 741 maps* louts=createMaps("GRIDS"); 745 742 louts->content=createMap("mimeType","UNKOWN"); 746 louts->next=NULL;747 743 748 744 sagaExecuteCmd(conf,"io_gdal","0",arg,&louts); … … 786 782 addToMap(arg,"FILES",v->value); 787 783 788 maps* louts=(maps*)malloc(MAPS_SIZE); 789 louts->name=zStrdup("SHAPES"); 784 maps* louts=createMaps("SHAPES"); 790 785 louts->content=createMap("mimeType","UNKOWN"); 791 louts->next=NULL;792 786 793 787 sagaExecuteCmd(conf,"io_gdal","3",arg,&louts); … … 832 826 if(v!=NULL) 833 827 addToMap(arg,"SHAPES",v->value); 834 maps* louts=(maps*)malloc(MAPS_SIZE); 835 louts->name=zStrdup("TIN"); 828 maps* louts=createMaps("TIN"); 836 829 louts->content=createMap("mimeType","UNKOWN"); 837 louts->next=NULL;838 830 sagaExecuteCmd(conf,"tin_tools","2",arg,&louts); 839 831 map* tmp=getMapFromMaps(louts,"TIN","generated_file"); … … 887 879 888 880 // Create the output maps 889 maps* louts=(maps*)malloc(MAPS_SIZE); 890 louts->name=zStrdup("TABLE"); 881 maps* louts=createMaps("TABLE"); 891 882 louts->content=createMap("mimeType","UNKOWN"); 892 louts->next=NULL;893 883 894 884 // Execute the saga command … … 940 930 941 931 // Create the output maps 942 maps* louts=(maps*)malloc(MAPS_SIZE); 943 louts->name=zStrdup("POINTS"); 932 maps* louts=createMaps("POINTS"); 944 933 louts->content=createMap("mimeType","UNKOWN"); 945 louts->next=NULL;946 934 947 935 // Execute the saga command -
trunk/zoo-project/zoo-kernel/service_yaml.c
r781 r790 84 84 yaml_parser_set_input_file(&parser, fh); 85 85 /* BEGIN new code */ 86 int nleveld=-1; 86 87 int level=0; 87 88 int plevel=level; 89 int nlevel=0; 90 int pnlevel=0; 88 91 int ilevel=-1; 89 92 int blevel=-1; 90 93 int ttype=0; 94 int outputs=-1; 95 int noutputs=-1; 91 96 int wait_metadata=-1; 92 97 char *cur_key; … … 145 150 blevel++; 146 151 break; 147 case YAML_SCALAR_TOKEN: 152 case YAML_SCALAR_TOKEN: 153 if((blevel-1)/2<nlevel){ 154 pnlevel=nlevel; 155 nlevel=(blevel-1)/2; 156 nleveld=1; 157 }else 158 nleveld=-1; 148 159 if(ttype==0){ 149 160 cur_key=zStrdup((char *)token.data.scalar.value); … … 180 191 current_content=NULL; 181 192 wait_metadata=1; 193 } 194 if(strcasecmp((char *)token.data.scalar.value,"Child")==0){ 195 elements* cursor=my_service->inputs; 196 if(outputs==1) 197 cursor=my_service->outputs; 198 for(int i=0;(blevel/2)>1 && i<(blevel/2)-1 && cursor!=NULL;i++){ 199 while(cursor->next!=NULL) 200 cursor=cursor->next; 201 if(cursor->child!=NULL){ 202 cursor=cursor->child; 203 } 204 } 205 if(current_content!=NULL){ 206 addMapToMap(¤t_element->content,current_content); 207 freeMap(¤t_content); 208 free(current_content); 209 current_content=NULL; 210 } 211 if(current_element!=NULL){ 212 if(blevel/2>1 && cursor!=NULL){ 213 if(cursor->child==NULL) 214 cursor->child=dupElements(current_element); 215 else 216 addToElements(&cursor->child,current_element); 217 } 218 else{ 219 if(outputs<0) 220 if(my_service->inputs==NULL) 221 my_service->inputs=dupElements(current_element); 222 else 223 addToElements(&my_service->inputs,current_element); 224 else 225 if(my_service->inputs==NULL) 226 my_service->outputs=dupElements(current_element); 227 else 228 addToElements(&my_service->outputs,current_element); 229 } 230 freeElements(¤t_element); 231 free(current_element); 232 current_element=NULL; 233 } 234 nlevel+=1; 182 235 } 183 236 if(ttype==0 && strcasecmp((char *)token.data.scalar.value,"inputs")==0 && blevel==0){ … … 200 253 } 201 254 if(ttype==0 && strcasecmp((char *)token.data.scalar.value,"outputs")==0 && blevel==1){ 255 outputs=1; 202 256 level++; 203 257 #ifdef DEBUG_YAML … … 303 357 } 304 358 359 if(strcasecmp(token.data.scalar.value,"default")!=0 && strcasecmp(token.data.scalar.value,"supported")!=0 && level==1 && (blevel-1)%2==0 && blevel!=1 && (blevel-1)/2==nlevel){ 360 if(current_element==NULL) 361 current_element=createElements((char *)token.data.scalar.value); 362 else{ 363 if(current_content!=NULL){ 364 if(current_element->defaults==NULL){ 365 current_element->defaults=(iotype*)malloc(IOTYPE_SIZE); 366 current_element->defaults->content=NULL; 367 current_element->defaults->next=NULL; 368 addMapToMap(¤t_element->defaults->content,current_content); 369 }else{ 370 if(current_element->supported==NULL){ 371 current_element->supported=(iotype*)malloc(IOTYPE_SIZE); 372 current_element->supported->content=NULL; 373 current_element->supported->next=NULL; 374 addMapToMap(¤t_element->supported->content,current_content); 375 }else 376 addMapToIoType(¤t_element->supported,current_content); 377 } 378 freeMap(¤t_content); 379 free(current_content); 380 current_content=NULL; 381 } 382 383 elements* cursor=my_service->inputs; 384 if(outputs==1) 385 cursor=my_service->outputs; 386 int llevel=((blevel-1)/2); 387 if(nleveld>0) 388 llevel=((blevel-1)/2)+1; 389 for(int i=0;llevel>1 && i<llevel-1 && cursor!=NULL;i++){ 390 while(cursor->next!=NULL) 391 cursor=cursor->next; 392 if(cursor->child!=NULL){ 393 cursor=cursor->child; 394 } 395 } 396 if(llevel>1) 397 if(cursor->child==NULL) 398 cursor->child=dupElements(current_element); 399 else 400 addToElements(&cursor->child,current_element); 401 else 402 if(cursor==NULL) 403 cursor=dupElements(current_element); 404 else 405 addToElements(&cursor,current_element); 406 freeElements(¤t_element); 407 free(current_element); 408 current_element=NULL; 409 current_element=createElements((char *)token.data.scalar.value); 410 } 411 } 305 412 if(blevel==1 && level==1){ 306 413 if(current_element!=NULL && current_content!=NULL){ … … 319 426 addMapToIoType(¤t_element->supported,current_content); 320 427 } 321 } 322 if(current_element!=NULL){ 323 if(my_service->inputs==NULL) 324 my_service->inputs=dupElements(current_element); 325 else 326 addToElements(&my_service->inputs,current_element); 327 freeElements(¤t_element); 328 free(current_element); 329 } 428 freeMap(¤t_content); 429 free(current_content); 430 current_content=NULL; 431 } 432 if(nleveld<0){ 433 if(current_element!=NULL){ 434 if(outputs<0) 435 if(my_service->inputs==NULL) 436 my_service->inputs=dupElements(current_element); 437 else 438 addToElements(&my_service->inputs,current_element); 439 else 440 if(my_service->outputs==NULL) 441 my_service->outputs=dupElements(current_element); 442 else 443 addToElements(&my_service->outputs,current_element); 444 freeElements(¤t_element); 445 free(current_element); 446 } 447 } 448 else{ 449 if(current_element!=NULL){ 450 elements* cursor=my_service->inputs; 451 if(outputs==1) 452 cursor=my_service->outputs; 453 while(cursor->next!=NULL) 454 cursor=cursor->next; 455 for(int i=0;pnlevel>1 && i<pnlevel-1 && cursor!=NULL;i++){ 456 while(cursor->next!=NULL) 457 cursor=cursor->next; 458 if(cursor->child!=NULL){ 459 cursor=cursor->child; 460 } 461 } 462 if(cursor->child==NULL) 463 cursor->child=dupElements(current_element); 464 else 465 addToElements(&cursor->child,current_element); 466 freeElements(¤t_element); 467 free(current_element); 468 } 469 } 330 470 plevel=level; 331 current_element=(elements*)malloc(ELEMENTS_SIZE); 332 current_element->name=zStrdup((char *)token.data.scalar.value); 333 current_element->content=NULL; 334 current_element->metadata=NULL; 335 current_element->format=NULL; 336 current_element->defaults=NULL; 337 current_element->supported=NULL; 338 current_element->next=NULL; 339 471 current_element=createElements((char *)token.data.scalar.value); 340 472 } 341 473 if(blevel==1 && level==2){ … … 355 487 addMapToIoType(¤t_element->supported,current_content); 356 488 } 489 freeMaps(¤t_content); 490 free(current_content); 491 current_content=NULL; 357 492 } 358 493 if(current_element!=NULL){ … … 372 507 } 373 508 plevel=level; 374 current_element=(elements*)malloc(ELEMENTS_SIZE); 375 current_element->name=zStrdup((char *)token.data.scalar.value); 376 current_element->content=NULL; 377 current_element->metadata=NULL; 378 current_element->format=NULL; 379 current_element->defaults=NULL; 380 current_element->supported=NULL; 381 current_element->next=NULL; 509 current_element=createElements((char *)token.data.scalar.value); 382 510 383 511 } 512 513 if(noutputs>0) 514 outputs=1; 515 if(strcasecmp((char *)token.data.scalar.value,"outputs")==0 && ttype==0 && blevel==0){ 516 noutputs=1; 517 } 518 384 519 385 520 … … 433 568 current_content=NULL; 434 569 } 570 435 571 if(current_element!=NULL){ 436 if(my_service->outputs==NULL) 437 my_service->outputs=dupElements(current_element); 438 else 439 addToElements(&my_service->outputs,current_element); 572 if(nlevel>0){ 573 elements* cursor=my_service->inputs; 574 if(outputs==1) 575 cursor=my_service->outputs; 576 for(int i=0;nlevel>1 && i<nlevel-1 && cursor!=NULL;i++){ 577 while(cursor->next!=NULL) 578 cursor=cursor->next; 579 if(cursor->child!=NULL){ 580 cursor=cursor->child; 581 } 582 } 583 if(cursor->child==NULL) 584 cursor->child=dupElements(current_element); 585 else 586 addToElements(&cursor->child,current_element); 587 }else{ 588 if(my_service->outputs==NULL) 589 my_service->outputs=dupElements(current_element); 590 else 591 addToElements(&my_service->outputs,current_element); 592 } 440 593 freeElements(¤t_element); 441 594 free(current_element); -
trunk/zoo-project/zoo-kernel/zoo_loader.c
r745 r790 95 95 strncasecmp(cgiRequestMethod,"post",4)==0){ 96 96 if(cgiContentLength==0){ 97 97 98 char *buffer=new char[2]; 98 99 char *res=NULL; … … 387 388 token=strtok_r(NULL,"&",&saveptr); 388 389 } 389 390 390 } 391 391 … … 393 393 map* tmp=getMap(tmpMap,"dataInputs"); 394 394 if(tmp!=NULL){ 395 addToMap(tmpMap,"dataInputs",strstr(strQuery,"dataInputs=")+11); 395 if(strcasestr(strQuery,"dataInputs=")!=NULL) 396 addToMap(tmpMap,"dataInputs",strcasestr(strQuery,"dataInputs=")+11); 397 else 398 addToMap(tmpMap,"dataInputs","None"); 396 399 } 397 400 } -
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r789 r790 770 770 771 771 map *tmpReq = getMap (request_inputs, "xrequest"); 772 772 773 773 if(r_inputs2 != NULL && tmpReq != NULL) { 774 774 const char key[] = "rfile="; … … 922 922 if (m == NULL) 923 923 { 924 return errorException ( m, _("Unable to allocate memory"),924 return errorException (NULL, _("Unable to allocate memory"), 925 925 "InternalError", NULL); 926 926 } 927 m->child=NULL; 927 928 char ntmp[1024]; 928 929 #ifndef ETC_DIR … … 1537 1538 NULL); 1538 1539 } 1539 #ifdef DEBUG 1540 printf1541 ( "#################\n(%s) %s\n#################\n",1540 #ifdef DEBUG_SERVICE_CONF 1541 fprintf 1542 (stderr,"#################\n(%s) %s\n#################\n", 1542 1543 r_inputs->value, buff1); 1543 1544 #endif … … 1703 1704 map *postRequest = NULL; 1704 1705 postRequest = getMap (request_inputs, "xrequest"); 1705 1706 1706 1707 if(vid==1 && postRequest==NULL){ 1707 1708 errorException (m,_("Unable to run Execute request using the GET HTTP method"),"InvalidParameterValue", "request"); … … 1817 1818 maps *tmpmaps = request_input_real_format; 1818 1819 1819 1820 1820 if(parseRequest(&m,&request_inputs,s1,&request_input_real_format,&request_output_real_format,&hInternet)<0){ 1821 1821 freeMaps (&m); … … 1828 1828 return 0; 1829 1829 } 1830 1831 1830 1832 1831 // Define each env variable in runing environment … … 1989 1988 * 1990 1989 */ 1991 maps *_tmpMaps = (maps *) malloc (MAPS_SIZE); 1992 _tmpMaps->name = zStrdup ("lenv"); 1990 maps *_tmpMaps = createMaps("lenv"); 1993 1991 char tmpBuff[100]; 1994 1992 struct ztimeval tp; … … 1998 1996 sprintf (tmpBuff, "%i", (cpid + (int) time (NULL))); 1999 1997 _tmpMaps->content = createMap ("osid", tmpBuff); 2000 _tmpMaps->next = NULL;2001 1998 sprintf (tmpBuff, "%i", cpid); 2002 1999 addToMap (_tmpMaps->content, "sid", tmpBuff); … … 2081 2078 free (tcook); 2082 2079 maps *tmpSess = (maps *) malloc (MAPS_SIZE); 2080 tmpSess->child=NULL; 2083 2081 struct stat file_status; 2084 2082 int istat = stat (session_file_path, &file_status); … … 2106 2104 *environ; 2107 2105 #endif 2108 _tmpMaps = (maps *) malloc (MAPS_SIZE); 2109 _tmpMaps->name = zStrdup ("renv"); 2110 _tmpMaps->content = NULL; 2111 _tmpMaps->next = NULL; 2106 _tmpMaps = createMaps("renv"); 2112 2107 for (; s; ei++) { 2113 2108 char* tmpName=zStrdup(s); … … 2229 2224 strlen (usid->value) + 7) * sizeof (char)); 2230 2225 sprintf (fbkpres, "%s/%s.res", r_inputs->value, usid->value); 2231 bmap = (maps *) malloc (MAPS_SIZE); 2232 bmap->name=zStrdup("status"); 2226 bmap = createMaps("status"); 2233 2227 bmap->content=createMap("usid",usid->value); 2234 bmap->next=NULL;2235 2228 addToMap(bmap->content,"sid",tmpm->value); 2236 2229 addIntToMap(bmap->content,"pid",getpid());
Note: See TracChangeset
for help on using the changeset viewer.