Changeset 458 for trunk/zoo-project/zoo-kernel
- Timestamp:
- Mar 31, 2014, 10:50:26 PM (11 years ago)
- Location:
- trunk/zoo-project/zoo-kernel
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service.h
r454 r458 254 254 } 255 255 256 static char* getMapsAsKVP(maps* m,int length,int type){257 char *dataInputsKVP=(char*) malloc(length*sizeof(char));258 maps* curs=m;259 int i=0;260 while(curs!=NULL){261 map *inRequest=getMap(curs->content,"inRequest");262 if(strncasecmp(inRequest->value,"true",4)==0){263 if(i==0)264 if(type==0)265 sprintf(dataInputsKVP,"%s=",curs->name);266 else267 sprintf(dataInputsKVP,"%s",curs->name);268 else{269 char *temp=zStrdup(dataInputsKVP);270 if(type==0)271 sprintf(dataInputsKVP,"%s;%s=",temp,curs->name);272 else273 sprintf(dataInputsKVP,"%s;%s",temp,curs->name);274 free(temp);275 }276 map* icurs=curs->content;277 if(type==0){278 char *temp=zStrdup(dataInputsKVP);279 if(getMap(m->content,"xlink:href")!=NULL)280 sprintf(dataInputsKVP,"%sReference",temp);281 else282 sprintf(dataInputsKVP,"%s%s",temp,icurs->value);283 free(temp);284 }285 while(icurs!=NULL){286 if(strcasecmp(icurs->name,"value")!=0 &&287 strcasecmp(icurs->name,"Reference")!=0 &&288 strcasecmp(icurs->name,"minOccurs")!=0 &&289 strcasecmp(icurs->name,"maxOccurs")!=0 &&290 strcasecmp(icurs->name,"inRequest")!=0){291 char *itemp=zStrdup(dataInputsKVP);292 sprintf(dataInputsKVP,"%s@%s=%s",itemp,icurs->name,icurs->value);293 free(itemp);294 }295 icurs=icurs->next;296 }297 }298 curs=curs->next;299 i++;300 }301 return dataInputsKVP;302 }303 304 256 305 257 static void freeMap(map** mo){ … … 909 861 } 910 862 863 #ifdef WIN32 864 extern char *url_encode(char *); 865 866 static char* getMapsAsKVP(maps* m,int length,int type){ 867 char *dataInputsKVP=(char*) malloc(length*sizeof(char)); 868 char *dataInputsKVPi=NULL; 869 maps* curs=m; 870 int i=0; 871 while(curs!=NULL){ 872 map *inRequest=getMap(curs->content,"inRequest"); 873 map *hasLength=getMap(curs->content,"length"); 874 if((inRequest!=NULL && strncasecmp(inRequest->value,"true",4)==0) || 875 inRequest==NULL){ 876 if(i==0) 877 if(type==0){ 878 sprintf(dataInputsKVP,"%s=",curs->name); 879 if(hasLength!=NULL){ 880 dataInputsKVPi=(char*)malloc((strlen(curs->name)+2)*sizeof(char)); 881 sprintf(dataInputsKVPi,"%s=",curs->name); 882 } 883 } 884 else 885 sprintf(dataInputsKVP,"%s",curs->name); 886 else{ 887 char *temp=zStrdup(dataInputsKVP); 888 if(type==0) 889 sprintf(dataInputsKVP,"%s;%s=",temp,curs->name); 890 else 891 sprintf(dataInputsKVP,"%s;%s",temp,curs->name); 892 } 893 map* icurs=curs->content; 894 if(type==0){ 895 char *temp=zStrdup(dataInputsKVP); 896 if(getMap(curs->content,"xlink:href")!=NULL) 897 sprintf(dataInputsKVP,"%sReference",temp); 898 else{ 899 if(hasLength!=NULL){ 900 for(int j=0;j<atoi(hasLength->value);j++){ 901 map* tmp0=getMapArray(curs->content,"value",j); 902 if(j==0) 903 free(temp); 904 temp=zStrdup(dataInputsKVP); 905 if(j==0) 906 sprintf(dataInputsKVP,"%s%s",temp,tmp0->value); 907 else 908 sprintf(dataInputsKVP,"%s;%s%s",temp,dataInputsKVPi,tmp0->value); 909 } 910 } 911 else 912 sprintf(dataInputsKVP,"%s%s",temp,icurs->value); 913 } 914 free(temp); 915 } 916 while(icurs!=NULL){ 917 if(strncasecmp(icurs->name,"value",5)!=0 && 918 strncasecmp(icurs->name,"mimeType_",9)!=0 && 919 strncasecmp(icurs->name,"dataType_",9)!=0 && 920 strncasecmp(icurs->name,"size",4)!=0 && 921 strncasecmp(icurs->name,"length",4)!=0 && 922 strncasecmp(icurs->name,"isArray",7)!=0 && 923 strcasecmp(icurs->name,"Reference")!=0 && 924 strcasecmp(icurs->name,"minOccurs")!=0 && 925 strcasecmp(icurs->name,"maxOccurs")!=0 && 926 strncasecmp(icurs->name,"fmimeType",9)!=0 && 927 strcasecmp(icurs->name,"inRequest")!=0){ 928 char *itemp=zStrdup(dataInputsKVP); 929 if(strcasecmp(icurs->name,"xlink:href")!=0) 930 sprintf(dataInputsKVP,"%s@%s=%s",itemp,icurs->name,icurs->value); 931 else 932 sprintf(dataInputsKVP,"%s@%s=%s",itemp,icurs->name,url_encode(icurs->value)); 933 free(itemp); 934 } 935 icurs=icurs->next; 936 } 937 } 938 curs=curs->next; 939 i++; 940 } 941 return dataInputsKVP; 942 } 943 #endif 944 911 945 #ifdef __cplusplus 912 946 } -
trunk/zoo-project/zoo-kernel/service_internal.c
r453 r458 287 287 } 288 288 if(getMapFromMaps(conf,"lenv","status")!=NULL){ 289 fprintf(stderr,"STATUS RETURNED : %s\n",status);290 289 if(status!=NULL){ 291 290 setMapInMaps(conf,"lenv","status",status); … … 1641 1640 (strncmp(tmp2->value,"application/",12)==0) && 1642 1641 strncmp(tmp2->value,"application/json",16)!=0&& 1642 strncmp(tmp2->value,"application/x-javascript",24)!=0&& 1643 1643 strncmp(tmp2->value,"application/vnd.google-earth.kml",32)!=0) 1644 1644 )) { … … 2004 2004 map *tmp3=getMapFromMaps(m,"main","serverAddress"); 2005 2005 char *file_url; 2006 if(strncasecmp(tmp2->value,"http://",7)==0){ 2007 file_url=(char*)malloc((strlen(tmp2->value)+strlen(file_name))*sizeof(char)); 2006 if(strncasecmp(tmp2->value,"http://",7)==0 || 2007 strncasecmp(tmp2->value,"https://",8)==0){ 2008 file_url=(char*)malloc((strlen(tmp2->value)+strlen(file_name)+2)*sizeof(char)); 2008 2009 sprintf(file_url,"%s/%s",tmp2->value,file_name); 2009 2010 }else{ 2010 file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(file_name) )*sizeof(char));2011 file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(file_name)+3)*sizeof(char)); 2011 2012 sprintf(file_url,"%s/%s/%s",tmp3->value,tmp2->value,file_name); 2012 2013 } -
trunk/zoo-project/zoo-kernel/service_internal_ms.c
r453 r458 923 923 if(strncasecmp(mime->value,"application/json",16)==0) 924 924 ext="json"; 925 925 926 926 map* tmpMap=getMapFromMaps(conf,"main","dataPath"); 927 927 map* sidMap=getMapFromMaps(conf,"lenv","usid"); 928 928 char *pszDataSource=(char*)malloc((strlen(tmpMap->value)+strlen(sidMap->value)+strlen(outputs->name)+17)*sizeof(char)); 929 sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext); 930 int f= open(pszDataSource,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);929 sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext); 930 int f=zOpen(pszDataSource,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); 931 931 map* sizeMap=getMap(outputs->content,"size"); 932 932 map* vData=getMap(outputs->content,"value"); 933 933 if(sizeMap!=NULL){ 934 write(f,vData->value,atoi(sizeMap->value)*sizeof(char));934 zWrite(f,vData->value,atoi(sizeMap->value)*sizeof(char)); 935 935 } 936 936 else{ 937 write(f,vData->value,strlen(vData->value)*sizeof(char));937 zWrite(f,vData->value,(strlen(vData->value)+1)*sizeof(char)); 938 938 } 939 939 close(f); 940 //exit(-1);941 940 addToMap(outputs->content,"storage",pszDataSource); 942 941 … … 1090 1089 map* sid=getMapFromMaps(conf,"lenv","usid"); 1091 1090 char *mapPath= 1092 (char*)malloc(( 16+strlen(outputs->name)+strlen(tmp1->value))*sizeof(char));1091 (char*)malloc((7+strlen(sid->value)+strlen(outputs->name)+strlen(tmp1->value))*sizeof(char)); 1093 1092 sprintf(mapPath,"%s/%s_%s.map",tmp1->value,outputs->name,sid->value); 1094 1093 msSaveMap(myMap,mapPath); -
trunk/zoo-project/zoo-kernel/service_internal_python.c
r453 r458 544 544 conf = mapsFromPyDict((PyDictObject*)confdict); 545 545 if (getMapFromMaps(conf,"lenv","status") != NULL){ 546 fprintf(stderr,"STATUS RETURNED : %s\n",status);547 546 if(status!=NULL){ 548 547 setMapInMaps(conf,"lenv","status",status); -
trunk/zoo-project/zoo-kernel/zoo_loader.c
r453 r458 114 114 if(strQuery==NULL || strlen(strQuery)==0) 115 115 tmpMap=createMap("request",res); 116 }116 } 117 117 }else{ 118 118 char *buffer=new char[cgiContentLength+1]; … … 177 177 } 178 178 179 #ifdef WIN32 180 map *tmpReq=getMap(tmpMap,"rfile"); 181 if(tmpReq!=NULL){ 182 FILE *lf=fopen(tmpReq->value,"r"); 183 fseek(lf,0,SEEK_END); 184 long flen=ftell(lf); 185 fseek(lf,0,SEEK_SET); 186 char *buffer=(char*)malloc((flen+1)*sizeof(char)); 187 fread(buffer,flen,1,lf); 188 fclose(lf); 189 addToMap(tmpMap,"request",buffer); 190 free(buffer); 191 cgiContentLength=flen+9; 192 } 193 #endif 179 194 /** 180 195 * In case that the POST method was used, then check if params came in XML … … 183 198 */ 184 199 if(strncasecmp(cgiRequestMethod,"post",4)==0 || 185 (count(tmpMap)==1 && strncmp(tmpMap->value,"<",1)==0)){ 200 (count(tmpMap)==1 && strncmp(tmpMap->value,"<",1)==0) 201 #ifdef WIN32 202 ||tmpReq!=NULL 203 #endif 204 ){ 186 205 /** 187 206 * First include the MetaPath and the ServiceProvider default parameters -
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r454 r458 478 478 map *tmpPath=getMapFromMaps(m,"lenv","cwd"); 479 479 480 map *tmpReq=getMap(request_inputs,"xrequest"); 480 481 if(r_inputs2!=NULL){ 481 482 sprintf(tmp,"\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s\"",r_inputs1->value,req->value,id->value,dataInputsKVP,r_inputs2->name,dataOutputsKVP,sid->value); 482 483 sprintf(tmpq,"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s",r_inputs1->value,req->value,id->value,dataInputsKVP,r_inputs2->name,dataOutputsKVP); 483 484 } 484 485 else{ 485 486 sprintf(tmp,"\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s\"",r_inputs1->value,req->value,id->value,dataInputsKVP,sid->value); … … 492 493 } 493 494 char *tmp1=zStrdup(tmp); 494 sprintf(tmp," zoo_loader.cgi%s \"%s\"",tmp1,sid->value);495 sprintf(tmp,"\"zoo_loader.cgi\" %s \"%s\"",tmp1,sid->value); 495 496 496 497 free(dataInputsKVP); … … 504 505 sprintf(clen,"%d",strlen(tmpq)); 505 506 SetEnvironmentVariable("CONTENT_LENGTH",TEXT(clen)); 506 507 507 508 if( !CreateProcess( NULL, // No module name (use command line) 508 509 TEXT(tmp), // Command line … … 517 518 ) 518 519 { 519 //printf("CreateProcess failed (%d).\n",GetLastError() );520 520 #ifdef DEBUG 521 521 fprintf( stderr, "CreateProcess failed (%d).\n", GetLastError() ); … … 523 523 return ; 524 524 }else{ 525 //printf("CreateProcess successfull (%d).\n",GetLastError() );526 525 #ifdef DEBUG 527 526 fprintf( stderr, "CreateProcess successfull (%d).\n\n\n\n", GetLastError() ); … … 530 529 CloseHandle( pi.hProcess ); 531 530 CloseHandle( pi.hThread ); 532 //printf("CreateProcess finished !\n");533 531 #ifdef DEBUG 534 532 fprintf(stderr,"CreateProcess finished !\n"); … … 600 598 map* fstdem=getMapFromMaps(m,"main","logPath"); 601 599 if(fstdem!=NULL) 602 600 fstde = freopen(fstdem->value, "a+", stderr) ; 603 601 604 602 r_inputs=getMap(request_inputs,"language"); … … 2247 2245 setMapInMaps(m,"lenv","sid",test1->value); 2248 2246 status=getMap(request_inputs,"status"); 2249 printf("cgiSid %s\n",cgiSid);2250 2247 } 2251 2248 #endif … … 2274 2271 pid=0; 2275 2272 cpid=atoi(cgiSid); 2276 printf("cgiSid %s\n",cgiSid); 2277 } 2278 //printf("pid cpid %d %d\n",pid,cpid); 2279 //fflush(stderr); 2273 } 2280 2274 #endif 2281 2275 if (pid > 0) { … … 2304 2298 fprintf(stderr,"\nFILE TO STORE DATA %s\n",r_inputs->value); 2305 2299 #endif 2306 freopen(flog, "w+",stderr);2300 freopen(flog, "w+", stderr); 2307 2301 f0=freopen(fbkp , "w+", stdout); 2302 #ifndef WIN32 2308 2303 fclose(stdin); 2304 #endif 2309 2305 free(flog); 2310 2306 /** … … 2359 2355 #endif 2360 2356 2361 if(((int)getpid())!=cpid ){2357 if(((int)getpid())!=cpid || cgiSid!=NULL){ 2362 2358 fclose(stdout); 2363 2359 fclose(stderr); … … 2376 2372 char *tmps1=(char*)malloc((flen+1)*sizeof(char)); 2377 2373 fread(tmps1,flen,1,f2); 2378 fwrite(tmps1,1,flen +1,f3);2374 fwrite(tmps1,1,flen,f3); 2379 2375 fclose(f2); 2380 2376 fclose(f3);
Note: See TracChangeset
for help on using the changeset viewer.