Changeset 587 for trunk/zoo-project/zoo-kernel
- Timestamp:
- Feb 18, 2015, 1:31:59 PM (10 years ago)
- Location:
- trunk/zoo-project/zoo-kernel
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_internal.c
r585 r587 3511 3511 * @param mimeType the content mimeType 3512 3512 * @param length the content size 3513 */ 3514 void addToCache(maps* conf,char* request,char* content,char* mimeType,int length){ 3513 * @param filepath a buffer for storing the path of the cached file; may be NULL 3514 * @param max_path the size of the allocated filepath buffer 3515 */ 3516 void addToCache(maps* conf,char* request,char* content,char* mimeType,int length, 3517 char* filepath, size_t max_path){ 3515 3518 map* tmp=getMapFromMaps(conf,"main","cacheDir"); 3516 3519 if(tmp!=NULL){ … … 3524 3527 FILE* fo=fopen(fname,"w+"); 3525 3528 if(fo==NULL){ 3526 fprintf (stderr, "Failed to open %s for writting: %s\n",fname, strerror(errno)); 3529 #ifdef DEBUG 3530 fprintf (stderr, "Failed to open %s for writing: %s\n",fname, strerror(errno)); 3531 #endif 3532 filepath = NULL; 3527 3533 return; 3528 3534 } 3529 3535 fwrite(content,sizeof(char),length,fo); 3530 3536 fclose(fo); 3537 3538 if (filepath != NULL) { 3539 strncpy(filepath, fname, max_path); 3540 } 3531 3541 3532 3542 sprintf(fname,"%s/%s.zcm",tmp->value,md5str); … … 3541 3551 free(fname); 3542 3552 } 3553 else { 3554 filepath = NULL; 3555 } 3543 3556 } 3544 3557 … … 3665 3678 } 3666 3679 addToMap(content->content,sname,ltmp1); 3667 addToCache(*m,tmp1->value,fcontent,mimeType,fsize );3680 addToCache(*m,tmp1->value,fcontent,mimeType,fsize, NULL, 0); 3668 3681 free(fcontent); 3669 3682 free(mimeType); … … 3767 3780 addToMap(*content,"size",ltmp1); 3768 3781 if(cached==NULL){ 3769 addToCache(*m,url,fcontent,mimeType,fsize );3782 addToCache(*m,url,fcontent,mimeType,fsize, NULL, 0); 3770 3783 } 3771 3784 else{ -
trunk/zoo-project/zoo-kernel/service_internal.h
r580 r587 212 212 xmlNodePtr soapEnvelope(maps*,xmlNodePtr); 213 213 int checkForSoapEnvelope(xmlDocPtr); 214 215 void addToCache(maps*,char*,char*,char*,int );214 215 void addToCache(maps*,char*,char*,char*,int,char*,size_t); 216 216 char* isInCache(maps*,char*); 217 217 int runHttpRequests(maps**,maps**,HINTERNET*); -
trunk/zoo-project/zoo-kernel/service_internal_php.c
r586 r587 26 26 #define NO_FCGI_DEFINES 27 27 #endif 28 29 #ifndef ZEND_DEBUG 30 #define ZEND_DEBUG 0 31 #endif 28 32 29 33 #include "service_internal_php.h" -
trunk/zoo-project/zoo-kernel/zoo_loader.c
r554 r587 173 173 fprintf(stderr,"(( \n %s \n %s \n ))",*arrayStep,value); 174 174 #endif 175 #ifdef WIN32 176 char* tmp = url_decode(value); 177 if(tmpMap!=NULL) 178 addToMap(tmpMap,*arrayStep,tmp); 179 else 180 tmpMap=createMap(*arrayStep,tmp); 181 free(tmp); 182 #else 175 183 if(tmpMap!=NULL) 176 184 addToMap(tmpMap,*arrayStep,value); 177 185 else 178 tmpMap=createMap(*arrayStep,value); 186 tmpMap=createMap(*arrayStep,value); 187 #endif 179 188 arrayStep++; 180 189 delete[]value; … … 330 339 token1=strtok_r(token,"=",&saveptr1); 331 340 while(token1!=NULL){ 332 if(name==NULL) 333 name=zStrdup(token1); 334 else 335 value=zStrdup(token1); 336 token1=strtok_r(NULL,"=",&saveptr1); 337 } 338 addToMap(tmpMap,name,value); 341 if(name==NULL) 342 name=zStrdup(token1); 343 else 344 value=zStrdup(token1); 345 token1=strtok_r(NULL,"=",&saveptr1); 346 } 347 //addToMap(tmpMap,name,value); 348 /* knut: strtok(_r) ignores delimiter bytes at start and end of string; 349 * it will return non-empty string or NULL, e.g. "metapath=" yields value=NULL. 350 * This modification sets value="" instead of NULL. 351 */ 352 addToMap(tmpMap,name, value != NULL ? value : ""); 353 339 354 free(name); 340 355 free(value); -
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r584 r587 751 751 752 752 map *tmpReq = getMap (request_inputs, "xrequest"); 753 if (r_inputs2 != NULL) 753 754 if(r_inputs2 != NULL && tmpReq != NULL) { 755 const char key[] = "rfile="; 756 char* kvp = (char*) malloc((FILENAME_MAX + strlen(key))*sizeof(char)); 757 char* filepath = kvp + strlen(key); 758 strncpy(kvp, key, strlen(key)); 759 addToCache(m, tmpReq->value, tmpReq->value, "text/xml", strlen(tmpReq->value), 760 filepath, FILENAME_MAX); 761 if (filepath == NULL) { 762 errorException( m, _("Unable to cache HTTP POST Execute request."), "InternalError", NULL); 763 return; 764 } 765 sprintf(tmp,"\"metapath=%s&%s&cgiSid=%s", 766 r_inputs1->value,kvp,sid->value); 767 sprintf(tmpq,"metapath=%s&%s", 768 r_inputs1->value,kvp); 769 free(kvp); 770 } 771 else if (r_inputs2 != NULL) 754 772 { 755 773 sprintf (tmp, 756 "\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s \"",774 "\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s", 757 775 r_inputs1->value, req->value, id->value, dataInputsKVP, 758 776 r_inputs2->name, dataOutputsKVP, sid->value); … … 760 778 "metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s", 761 779 r_inputs1->value, req->value, id->value, dataInputsKVP, 762 r_inputs2->name, dataOutputsKVP); 780 r_inputs2->name, dataOutputsKVP); 763 781 } 764 782 else 765 783 { 766 784 sprintf (tmp, 767 "\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s \"",785 "\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s", 768 786 r_inputs1->value, req->value, id->value, dataInputsKVP, 769 787 sid->value); … … 771 789 "metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s", 772 790 r_inputs1->value, req->value, id->value, dataInputsKVP, 773 sid->value); 791 sid->value); 774 792 } 775 793 … … 780 798 } 781 799 char *tmp1 = zStrdup (tmp); 782 sprintf (tmp, "\"%s\" %s \"%s\"", PROGRAMNAME, tmp1, sid->value); 800 sprintf (tmp, "\"%s\" %s \"%s\"", PROGRAMNAME, tmp1, sid->value); 783 801 free (dataInputsKVP); 784 802 free (dataOutputsKVP); … … 794 812 SetEnvironmentVariable ("CGISID", TEXT (sid->value)); 795 813 SetEnvironmentVariable ("QUERY_STRING", TEXT (tmpq)); 814 // knut: Prevent REQUEST_METHOD=POST in background process call to cgic:main (process hangs when reading cgiIn): 815 SetEnvironmentVariable("REQUEST_METHOD", "GET"); 816 796 817 char clen[1000]; 797 818 sprintf (clen, "%d", strlen (tmpq)); … … 813 834 fprintf (stderr, "CreateProcess failed (%d).\n", GetLastError ()); 814 835 #endif 836 if (tmp != NULL) { 837 free(tmp); 838 } 839 if (tmpq != NULL) { 840 free(tmpq); 841 } 815 842 return; 816 843 } … … 818 845 { 819 846 #ifdef DEBUG 820 fprintf (stderr, "CreateProcess successful l(%d).\n\n\n\n",847 fprintf (stderr, "CreateProcess successful (%d).\n\n\n\n", 821 848 GetLastError ()); 822 849 #endif … … 824 851 CloseHandle (pi.hProcess); 825 852 CloseHandle (pi.hThread); 853 854 if (tmp != NULL) { 855 free(tmp); 856 } 857 if (tmpq != NULL) { 858 free(tmpq); 859 } 860 826 861 #ifdef DEBUG 827 862 fprintf (stderr, "CreateProcess finished !\n"); … … 1367 1402 "InternalError", NULL); 1368 1403 } 1404 1369 1405 r_inputs = getMap (request_inputs, "MetaPath"); 1370 1406 if (r_inputs != NULL) … … 2821 2857 while (cur1 != NULL && cur1->type != XML_ELEMENT_NODE) 2822 2858 cur1 = cur1->next; 2859 2860 if (request_output_real_format == NULL) 2861 request_output_real_format = dupMaps (&tmpmaps); 2862 else 2863 addMapsToMaps (&request_output_real_format, tmpmaps); 2823 2864 } 2824 }2825 if (request_output_real_format == NULL)2826 request_output_real_format = dupMaps (&tmpmaps);2827 else2828 addMapsToMaps (&request_output_real_format, tmpmaps);2829 if (tmpmaps != NULL)2830 {2831 freeMaps (&tmpmaps);2832 free (tmpmaps);2833 tmpmaps = NULL;2834 2865 } 2835 2866 }
Note: See TracChangeset
for help on using the changeset viewer.