Changeset 217 for branches/branch-1.2/zoo-kernel/zoo_service_loader.c
- Timestamp:
- May 31, 2011, 3:30:49 AM (13 years ago)
- Location:
- branches/branch-1.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1.2
-
branches/branch-1.2/zoo-kernel/zoo_service_loader.c
r109 r217 94 94 } 95 95 96 xmlXPathObjectPtr extractFromDoc(xmlDocPtr doc,c har* search){96 xmlXPathObjectPtr extractFromDoc(xmlDocPtr doc,const char* search){ 97 97 xmlXPathContextPtr xpathCtx; 98 98 xmlXPathObjectPtr xpathObj; … … 110 110 void sig_handler(int sig){ 111 111 char tmp[100]; 112 c har *ssig;112 const char *ssig; 113 113 switch(sig){ 114 114 case SIGSEGV: … … 153 153 map* r_inputs=NULL; 154 154 #ifndef WIN32 155 getcwd(ntmp,1024);155 char* pntmp=getcwd(ntmp,1024); 156 156 #else 157 157 _getcwd(ntmp,1024); … … 203 203 #endif 204 204 if(strncasecmp(r_inputs->value,"C-FORTRAN",9)==0){ 205 #ifdef WIN32206 //Strange return value needed here !207 return 1;208 #endif209 205 r_inputs=getMap(request_inputs,"Identifier"); 210 206 char fname[1024]; … … 284 280 #endif 285 281 } 282 #ifdef WIN32 283 *ioutputs=dupMaps(&request_output_real_format); 284 FreeLibrary(so); 285 #else 286 286 dlclose(so); 287 #endif 287 288 } else { 288 289 /** … … 345 346 } 346 347 *myMap=m; 348 #ifndef WIN32 347 349 *ioutputs=request_output_real_format; 350 #endif 348 351 } 352 353 #ifdef WIN32 354 /** 355 * createProcess function: create a new process after setting some env variables 356 */ 357 void createProcess(maps* m,map* request_inputs,service* s1,char* opts,int cpid, maps* inputs,maps* outputs){ 358 STARTUPINFO si; 359 PROCESS_INFORMATION pi; 360 ZeroMemory( &si, sizeof(si) ); 361 si.cb = sizeof(si); 362 ZeroMemory( &pi, sizeof(pi) ); 363 char *tmp=(char *)malloc((1024+cgiContentLength)*sizeof(char)); 364 char *tmpq=(char *)malloc((1024+cgiContentLength)*sizeof(char)); 365 map *req=getMap(request_inputs,"request"); 366 map *id=getMap(request_inputs,"identifier"); 367 map *di=getMap(request_inputs,"DataInputs"); 368 369 char *dataInputsKVP=getMapsAsKVP(inputs,cgiContentLength,0); 370 char *dataOutputsKVP=getMapsAsKVP(outputs,cgiContentLength,1); 371 fprintf(stderr,"DATAINPUTSKVP %s\n",dataInputsKVP); 372 fprintf(stderr,"DATAOUTPUTSKVP %s\n",dataOutputsKVP); 373 map *sid=getMapFromMaps(m,"lenv","sid"); 374 map* r_inputs=getMapFromMaps(m,"main","tmpPath"); 375 map* r_inputs1=getMap(s1->content,"ServiceProvider"); 376 map* r_inputs2=getMap(s1->content,"ResponseDocument"); 377 if(r_inputs2==NULL) 378 r_inputs2=getMap(s1->content,"RawDataOutput"); 379 map *tmpPath=getMapFromMaps(m,"lenv","cwd"); 380 381 if(r_inputs2!=NULL){ 382 sprintf(tmp,"\"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s\"",req->value,id->value,dataInputsKVP,r_inputs2->name,r_inputs2->value,sid->value); 383 sprintf(tmpq,"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s",req->value,id->value,dataInputsKVP,r_inputs2->name,dataOutputsKVP); 384 } 385 else{ 386 sprintf(tmp,"\"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s\"",req->value,id->value,dataInputsKVP,sid->value); 387 sprintf(tmpq,"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s",req->value,id->value,dataInputsKVP,sid->value); 388 } 389 390 char *tmp1=strdup(tmp); 391 sprintf(tmp,"zoo_loader.cgi %s \"%s\"",tmp1,sid->value); 392 393 free(dataInputsKVP); 394 free(dataOutputsKVP); 395 fprintf(stderr,"REQUEST IS : %s \n",tmp); 396 SetEnvironmentVariable("CGISID",TEXT(sid->value)); 397 SetEnvironmentVariable("QUERY_STRING",TEXT(tmpq)); 398 char clen[1000]; 399 sprintf(clen,"%d",strlen(tmpq)); 400 SetEnvironmentVariable("CONTENT_LENGTH",TEXT(clen)); 401 402 if( !CreateProcess( NULL, // No module name (use command line) 403 TEXT(tmp), // Command line 404 NULL, // Process handle not inheritable 405 NULL, // Thread handle not inheritable 406 FALSE, // Set handle inheritance to FALSE 407 CREATE_NO_WINDOW, // Apache won't wait until the end 408 NULL, // Use parent's environment block 409 NULL, // Use parent's starting directory 410 &si, // Pointer to STARTUPINFO struct 411 &pi ) // Pointer to PROCESS_INFORMATION struct 412 ) 413 { 414 fprintf( stderr, "CreateProcess failed (%d).\n", GetLastError() ); 415 return ; 416 }else{ 417 fprintf( stderr, "CreateProcess successfull (%d).\n\n\n\n", GetLastError() ); 418 } 419 CloseHandle( pi.hProcess ); 420 CloseHandle( pi.hThread ); 421 fprintf(stderr,"CreateProcess finished !\n"); 422 } 423 #endif 349 424 350 425 int runRequest(map* request_inputs) … … 360 435 #endif 361 436 362 map* r_inputs=NULL ,*tmps=NULL;437 map* r_inputs=NULL; 363 438 maps* m=NULL; 364 int argc=count(request_inputs);365 439 366 440 char* REQUEST=NULL; … … 374 448 char ntmp[1024]; 375 449 #ifndef WIN32 376 getcwd(ntmp,1024);450 char *pntmp=getcwd(ntmp,1024); 377 451 #else 378 452 _getcwd(ntmp,1024); … … 470 544 } 471 545 472 map* outputs=NULL;473 546 maps* request_output_real_format=NULL; 474 547 map* tmpm=getMapFromMaps(m,"main","serverAddress"); … … 478 551 SERVICE_URL=strdup(DEFAULT_SERVICE_URL); 479 552 480 service* s[100];481 553 service* s1; 482 554 int scount=0; … … 497 569 498 570 if(strncasecmp(REQUEST,"GetCapabilities",15)==0){ 499 int i=0;500 571 struct dirent *dp; 501 572 #ifdef DEBUG … … 510 581 r_inputs=getMap(request_inputs,"ServiceProvider"); 511 582 xmlNodePtr n; 512 //dumpMap(request_inputs);513 583 if(r_inputs!=NULL) 514 584 n = printGetCapabilitiesHeader(doc,r_inputs->value,m); … … 516 586 n = printGetCapabilitiesHeader(doc,"",m); 517 587 /** 518 * Strange, here we need to close stdout to ensure that no uneeded519 * char will be printed (parser issue ?)588 * Here we need to close stdout to ensure that not supported chars 589 * has been found in the zcfg and then printed on stdout 520 590 */ 521 591 int saved_stdout = dup(fileno(stdout)); … … 595 665 char buff[256]; 596 666 char buff1[1024]; 597 int i=0;598 int j=0;599 int end=-1;600 667 int saved_stdout = dup(fileno(stdout)); 601 668 dup2(fileno(stderr),fileno(stdout)); … … 611 678 memset(buff1,0,1024); 612 679 snprintf(buff1,1024,"%s/%s",conf_dir,dp->d_name); 613 //s1=(service*)malloc(sizeof(service*));614 680 s1=(service*)calloc(1,SERVICE_SIZE); 615 681 if(s1 == NULL){ … … 640 706 free(SERVICE_URL); 641 707 fflush(stdout); 642 //xmlFree(n);643 708 #ifndef LINUX_FREE_ISSUE 644 709 if(s1) … … 654 719 #endif 655 720 closedir(dirp); 656 free(s);657 721 return 0; 658 722 } … … 682 746 #endif 683 747 int saved_stdout = dup(fileno(stdout)); 684 dup2(fileno(stderr),fileno(stdout));748 dup2(fileno(stderr),fileno(stdout)); 685 749 t=getServiceFromFile(tmps1,&s1); 686 750 fflush(stdout); 687 751 dup2(saved_stdout,fileno(stdout)); 688 752 if(t<0){ 689 char tmpMsg[2048+strlen(r_inputs->value)]; 753 char *tmpMsg=(char*)malloc(2048+strlen(r_inputs->value)); 754 690 755 sprintf(tmpMsg,_("The value for <indetifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request."),r_inputs->value); 691 756 errorException(m, tmpMsg, "InvalidParameterValue"); 757 free(tmpMsg); 692 758 freeService(&s1); 693 759 free(s1); … … 698 764 return 0; 699 765 } 700 close(saved_stdout);766 //close(saved_stdout); 701 767 702 768 #ifdef DEBUG 703 769 dumpService(s1); 704 770 #endif 705 map* inputs=NULL;706 elements* c_inputs=s1->inputs;707 771 int j; 708 772 … … 747 811 fprintf(stderr,"OUTPUT Parsing start now ... \n"); 748 812 #endif 749 char current_output_as_string[10240];750 813 char cursor_output[10240]; 751 814 char *cotmp=strdup(r_inputs->value); … … 753 816 free(cotmp); 754 817 j=0; 755 map* request_kvp_outputs=NULL;756 818 757 819 /** … … 834 896 fflush(stderr); 835 897 #endif 836 //tmp_output=tmp_output->next;837 898 free(tmp); 838 899 } … … 848 909 fprintf(stderr,"DATA INPUTS [%s]\n",r_inputs->value); 849 910 #endif 850 char current_input_as_string[40960];851 911 char cursor_input[40960]; 852 912 if(r_inputs!=NULL) … … 864 924 } 865 925 j=0; 866 map* request_kvp_inputs=NULL;867 926 868 927 /** … … 905 964 char tmpn[256]; 906 965 memset(tmpn,0,256); 907 strncpy(tmpn,tmpc,(strlen(tmpc)-strlen(tmpv))*sizeof(char)); 908 tmpn[strlen(tmpc)-strlen(tmpv)]=0; 909 int cnt=0; 966 if(tmpv!=NULL){ 967 strncpy(tmpn,tmpc,(strlen(tmpc)-strlen(tmpv))*sizeof(char)); 968 tmpn[strlen(tmpc)-strlen(tmpv)]=0; 969 } 970 else{ 971 strncpy(tmpn,tmpc,strlen(tmpc)*sizeof(char)); 972 tmpn[strlen(tmpc)]=0; 973 } 910 974 #ifdef DEBUG 911 975 fprintf(stderr,"***\n*** %s = %s ***\n",tmpn,tmpv+1); … … 917 981 } 918 982 tmpmaps->name=strdup(tmpn); 919 tmpmaps->content=createMap("value",tmpv+1); 983 if(tmpv!=NULL) 984 tmpmaps->content=createMap("value",tmpv+1); 985 else 986 tmpmaps->content=createMap("value","Reference"); 920 987 tmpmaps->next=NULL; 921 988 } … … 931 998 char tmpn1[1024]; 932 999 memset(tmpn1,0,1024); 933 strncpy(tmpn1,tmpc,strlen(tmpc)-strlen(tmpv1)); 934 tmpn1[strlen(tmpc)-strlen(tmpv1)]=0; 1000 if(tmpv1!=NULL){ 1001 strncpy(tmpn1,tmpc,strlen(tmpc)-strlen(tmpv1)); 1002 tmpn1[strlen(tmpc)-strlen(tmpv1)]=0; 1003 addToMap(tmpmaps->content,tmpn1,tmpv1+1); 1004 } 1005 else{ 1006 strncpy(tmpn1,tmpc,strlen(tmpc)); 1007 tmpn1[strlen(tmpc)]=0; 1008 map* lmap=getLastMap(tmpmaps->content); 1009 char *tmpValue=(char*)calloc((strlen(lmap->value)+strlen(tmpc)+1),sizeof(char)); 1010 sprintf(tmpValue,"%s@%s",lmap->value,tmpc); 1011 free(lmap->value); 1012 lmap->value=strdup(tmpValue); 1013 free(tmpValue); 1014 dumpMap(tmpmaps->content); 1015 tmpc=strtok(NULL,"@"); 1016 continue; 1017 } 935 1018 #ifdef DEBUG 936 1019 fprintf(stderr,"*** NAME NON URL-ENCODED \n***%s***\n",tmpn1); … … 939 1022 if(strcmp(tmpn1,"xlink:href")!=0) 940 1023 addToMap(tmpmaps->content,tmpn1,tmpv1+1); 941 else{ 942 #ifdef DEBUG 943 fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1); 1024 else 1025 if(tmpv1!=NULL){ 1026 if(strncasecmp(tmpv1+1,"http://",7)!=0 && 1027 strncasecmp(tmpv1+1,"ftp://",6)!=0){ 1028 char emsg[1024]; 1029 sprintf(emsg,_("Unable to find a valid protocol to download the remote file %s"),tmpv1+1); 1030 errorException(m,emsg,"InternalError"); 1031 freeMaps(&m); 1032 free(m); 1033 free(REQUEST); 1034 free(SERVICE_URL); 1035 InternetCloseHandle(hInternet); 1036 freeService(&s1); 1037 free(s1); 1038 return 0; 1039 } 1040 #ifdef DEBUG 1041 fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1); 944 1042 #endif 945 1043 #ifndef WIN32 946 if(CHECK_INET_HANDLE(hInternet)) 947 #endif 948 { 949 res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0, 950 INTERNET_FLAG_NO_CACHE_WRITE,0); 951 #ifdef DEBUG 952 fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n", 953 tmpv1+1,res.nDataAlloc,res.nDataLen); 954 #endif 955 char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char)); 956 if(tmpContent == NULL){ 957 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1044 if(CHECK_INET_HANDLE(hInternet)) 1045 #endif 1046 { 1047 res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0, 1048 INTERNET_FLAG_NO_CACHE_WRITE,0); 1049 #ifdef DEBUG 1050 fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n", 1051 tmpv1+1,res.nDataAlloc,res.nDataLen); 1052 #endif 1053 char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char)); 1054 if(tmpContent == NULL){ 1055 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1056 } 1057 size_t dwRead; 1058 InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead); 1059 map* tmpMap=getMap(tmpmaps->content,"value"); 1060 if(tmpMap!=NULL){ 1061 free(tmpMap->value); 1062 tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char)); 1063 memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char)); 1064 tmpMap->value[res.nDataLen]=0; 1065 if(strlen(tmpContent)!=res.nDataLen){ 1066 char tmp[256]; 1067 sprintf(tmp,"%d",res.nDataLen*sizeof(char)); 1068 addToMap(tmpmaps->content,"size",tmp); 1069 } 1070 } 1071 free(tmpContent); 958 1072 } 959 size_t dwRead; 960 InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead); 961 map* tmpMap=getMap(tmpmaps->content,"value"); 962 if(tmpMap!=NULL){ 963 free(tmpMap->value); 964 tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char)); 965 memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char)); 966 tmpMap->value[res.nDataLen]=0; 967 if(strlen(tmpContent)!=res.nDataLen){ 968 char tmp[256]; 969 sprintf(tmp,"%d",res.nDataLen*sizeof(char)); 970 addToMap(tmpmaps->content,"size",tmp); 971 } 972 } 973 free(tmpContent); 974 } 975 addToMap(tmpmaps->content,tmpn1,tmpv1+1); 976 addToMap(tmpmaps->content,"Reference",tmpv1+1); 977 } 1073 char *tmpx=url_encode(tmpv1+1); 1074 addToMap(tmpmaps->content,tmpn1,tmpx); 1075 free(tmpx); 1076 addToMap(tmpmaps->content,"Reference",tmpv1+1); 1077 dumpMap(tmpmaps->content); 1078 } 978 1079 tmpc=strtok(NULL,"@"); 979 1080 } … … 1010 1111 fflush(stderr); 1011 1112 #endif 1012 xmlNodePtr cur = xmlDocGetRootElement(doc);1013 1113 /** 1014 1114 * Parse every Input in DataInputs node. 1015 1115 */ 1016 maps* tempMaps=NULL;1017 1116 xmlXPathObjectPtr tmpsptr=extractFromDoc(doc,"/*/*/*[local-name()='Input']"); 1018 1117 xmlNodeSet* tmps=tmpsptr->nodesetval; … … 1064 1163 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1065 1164 } 1066 tmpmaps->name= "missingIndetifier";1165 tmpmaps->name=strdup("missingIndetifier"); 1067 1166 tmpmaps->content=createMap((char*)cur2->name,(char*)val); 1068 1167 tmpmaps->next=NULL; … … 1093 1192 fprintf(stderr,"REFERENCE\n"); 1094 1193 #endif 1095 map* referenceMap=NULL; 1096 char *refs[5]; 1194 const char *refs[5]; 1097 1195 refs[0]="mimeType"; 1098 1196 refs[1]="encoding"; … … 1100 1198 refs[3]="method"; 1101 1199 refs[4]="href"; 1102 char*url;1103 1200 for(int l=0;l<5;l++){ 1104 1201 #ifdef DEBUG … … 1141 1238 hInternet.header=NULL; 1142 1239 while(cur3){ 1240 while(cur3!=NULL && cur3->type!=XML_ELEMENT_NODE) 1241 cur2=cur3->next; 1143 1242 if(xmlStrcasecmp(cur3->name,BAD_CAST "Header")==0 ){ 1144 xmlNodePtr cur4=cur3; 1145 char *tmp=new char[cgiContentLength]; 1146 char *ha[2]; 1243 const char *ha[2]; 1147 1244 ha[0]="key"; 1148 1245 ha[1]="value"; … … 1170 1267 } 1171 1268 hInternet.header=curl_slist_append(hInternet.header, has); 1172 //free(has);1269 free(has); 1173 1270 } 1174 1271 else{ … … 1184 1281 xmlNodePtr cur4=cur3->children; 1185 1282 while(cur4!=NULL){ 1283 while(cur4->type!=XML_ELEMENT_NODE) 1284 cur4=cur4->next; 1186 1285 xmlDocPtr bdoc = xmlNewDoc(BAD_CAST "1.0"); 1187 1286 bdoc->encoding = xmlCharStrdup ("UTF-8"); … … 1302 1401 * dataType , uom 1303 1402 */ 1304 char *li ts[2];1305 li ts[0]="dataType";1306 li ts[1]="uom";1403 char *list[2]; 1404 list[0]=strdup("dataType"); 1405 list[1]=strdup("uom"); 1307 1406 for(int l=0;l<2;l++){ 1308 1407 #ifdef DEBUG 1309 fprintf(stderr,"*** LiteralData %s ***",li ts[l]);1310 #endif 1311 xmlChar *val=xmlGetProp(cur4,BAD_CAST li ts[l]);1408 fprintf(stderr,"*** LiteralData %s ***",list[l]); 1409 #endif 1410 xmlChar *val=xmlGetProp(cur4,BAD_CAST list[l]); 1312 1411 if(val!=NULL && strlen((char*)val)>0){ 1313 1412 if(tmpmaps->content!=NULL) 1314 addToMap(tmpmaps->content,li ts[l],(char*)val);1413 addToMap(tmpmaps->content,list[l],(char*)val); 1315 1414 else 1316 tmpmaps->content=createMap(li ts[l],(char*)val);1415 tmpmaps->content=createMap(list[l],(char*)val); 1317 1416 } 1318 1417 #ifdef DEBUG … … 1320 1419 #endif 1321 1420 xmlFree(val); 1421 free(list[l]); 1322 1422 } 1323 1423 } … … 1327 1427 * mimeType, encoding, schema 1328 1428 */ 1329 c har *coms[3];1429 const char *coms[3]; 1330 1430 coms[0]="mimeType"; 1331 1431 coms[1]="encoding"; … … 1368 1468 char *res=NULL; 1369 1469 char *curs=tmpv->value; 1370 int i=0;1371 1470 for(int i=0;i<=strlen(tmpv->value)/64;i++) { 1372 1471 if(res==NULL) … … 1421 1520 #endif 1422 1521 xmlXPathFreeObject(tmpsptr); 1423 //xmlFree(tmps);1424 1522 1425 1523 tmpsptr=extractFromDoc(doc,"/*/*/*[local-name()='ResponseDocument']"); … … 1439 1537 else 1440 1538 addToMap(request_inputs,"ResponseDocument",""); 1441 request_output_real_format;1442 1539 maps *tmpmaps=NULL; 1443 1540 xmlNodePtr cur=tmps->nodeTab[k]; … … 1451 1548 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1452 1549 } 1453 tmpmaps->name= "unknownIdentifier";1550 tmpmaps->name=strdup("unknownIdentifier"); 1454 1551 tmpmaps->next=NULL; 1455 1552 } … … 1458 1555 * storeExecuteResponse, lineage, status 1459 1556 */ 1460 c har *ress[3];1557 const char *ress[3]; 1461 1558 ress[0]="storeExecuteResponse"; 1462 1559 ress[1]="lineage"; … … 1487 1584 * mimeType, encoding, schema, uom, asReference 1488 1585 */ 1489 c har *outs[5];1586 const char *outs[5]; 1490 1587 outs[0]="mimeType"; 1491 1588 outs[1]="encoding"; … … 1543 1640 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1544 1641 } 1545 tmpmaps->name= "missingIndetifier";1642 tmpmaps->name=strdup("missingIndetifier"); 1546 1643 tmpmaps->content=createMap((char*)cur2->name,(char*)val); 1547 1644 tmpmaps->next=NULL; … … 1563 1660 } 1564 1661 } 1565 //xmlFree(cur);1566 1662 if(request_output_real_format==NULL) 1567 1663 request_output_real_format=dupMaps(&tmpmaps); … … 1576 1672 1577 1673 xmlXPathFreeObject(tmpsptr); 1578 //xmlFree(tmps);1579 1674 xmlCleanupParser(); 1580 1675 } … … 1710 1805 _tmpMaps->next=NULL; 1711 1806 addToMap(_tmpMaps->content,"status","0"); 1807 addToMap(_tmpMaps->content,"cwd",ntmp); 1712 1808 if(cgiCookie!=NULL && strlen(cgiCookie)>0){ 1713 1809 addToMap(_tmpMaps->content,"sessid",strstr(cgiCookie,"=")+1); … … 1735 1831 dumpMap(request_inputs); 1736 1832 #endif 1737 1833 #ifdef WIN32 1834 char *cgiSidL=NULL; 1835 if(getenv("CGISID")!=NULL) 1836 addToMap(request_inputs,"cgiSid",getenv("CGISID")); 1837 map* test1=getMap(request_inputs,"cgiSid"); 1838 if(test1!=NULL){ 1839 cgiSid=test1->value; 1840 } 1841 if(cgiSid!=NULL){ 1842 addToMap(request_inputs,"storeExecuteResponse","true"); 1843 addToMap(request_inputs,"status","true"); 1844 status=getMap(request_inputs,"status"); 1845 dumpMap(request_inputs); 1846 fprintf(stderr,"cgiSID : %s",cgiSid); 1847 } 1848 #endif 1738 1849 if(status!=NULL) 1739 1850 if(strcasecmp(status->value,"false")==0) … … 1751 1862 pid = fork (); 1752 1863 #else 1753 pid = 0; 1864 if(cgiSid==NULL){ 1865 addToMap(request_inputs,"cgSid",cgiSid); 1866 createProcess(m,request_inputs,s1,NULL,cpid,request_input_real_format,request_output_real_format); 1867 pid = cpid; 1868 }else{ 1869 pid=0; 1870 cpid=atoi(cgiSid); 1871 } 1872 fflush(stderr); 1754 1873 #endif 1755 1874 if (pid > 0) { … … 1778 1897 fprintf(stderr,"\nFILE TO STORE DATA %s\n",r_inputs->value); 1779 1898 #endif 1899 freopen(flog,"w+",stderr); 1780 1900 freopen(fbkp , "w+", stdout); 1781 1901 fclose(stdin); 1782 freopen(flog,"w+",stderr);1783 1902 free(fbkp); 1784 1903 free(flog); … … 1791 1910 updateStatus(m); 1792 1911 printProcessResponse(m,request_inputs,cpid, 1793 s1,r_inputs1->value,SERVICE_STARTED, 1794 request_input_real_format, 1795 request_output_real_format); 1912 s1,r_inputs1->value,SERVICE_STARTED, 1913 request_input_real_format, 1914 request_output_real_format); 1915 #ifndef WIN32 1796 1916 fflush(stdout); 1797 1917 rewind(stdout); 1918 #endif 1798 1919 1799 1920 loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres); … … 1811 1932 #ifdef DEBUG 1812 1933 dumpMaps(request_output_real_format); 1813 fprintf(stderr,"Function loaded and returned %d\n", eres);1934 fprintf(stderr,"Function loaded and returned %d\n",*eres); 1814 1935 fflush(stderr); 1815 1936 #endif … … 1818 1939 request_output_real_format,request_inputs, 1819 1940 cpid,m,eres); 1941 fflush(stdout); 1820 1942 /** 1821 1943 * Ensure that if error occurs when freeing memory, no signal will return
Note: See TracChangeset
for help on using the changeset viewer.