Changeset 490 for trunk/zoo-project/zoo-kernel/service_internal.c
- Timestamp:
- Jun 27, 2014, 1:14:39 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_internal.c
r485 r490 181 181 182 182 void unhandleStatus(maps *conf){ 183 int shmid ,i;183 int shmid; 184 184 key_t key; 185 185 void *shm; 186 186 struct shmid_ds shmids; 187 char *s,*s1;188 187 map *tmpMap=getMapFromMaps(conf,"lenv","sid"); 189 188 if(tmpMap!=NULL){ … … 207 206 208 207 int _updateStatus(maps *conf){ 209 int shmid ,i;208 int shmid; 210 209 key_t key; 211 210 char *shm,*s,*s1; … … 247 246 248 247 char* getStatus(int pid){ 249 int shmid ,i;248 int shmid; 250 249 key_t key; 251 250 void *shm; 252 char *s;253 251 key=pid; 254 252 if ((shmid = shmget(key, SHMSZ, 0666)) < 0) { … … 265 263 } 266 264 } 267 return "-1";265 return (char*)"-1"; 268 266 } 269 267 … … 277 275 jsval *argv = JS_ARGV(cx,argv1); 278 276 JS_MaybeGC(cx); 279 char *sid;280 277 int istatus=0; 281 278 char *status=NULL; 282 279 maps *conf; 283 int i=0;284 280 if(argc>2){ 285 281 #ifdef JS_DEBUG … … 385 381 #endif 386 382 int currId=-1; 387 int currNode=-1;388 383 if(nbNs==0){ 389 384 nbNs++; … … 419 414 nbNs=0; 420 415 } 416 417 418 int zooXmlAddDoc(const char* value){ 419 int currId=0; 420 nbDocs++; 421 currId=nbDocs-1; 422 iDocs[currId]=xmlParseMemory(value,strlen(value)); 423 return currId; 424 } 425 426 void zooXmlCleanupDocs(){ 427 int j; 428 for(j=nbDocs-1;j>=0;j--){ 429 xmlFreeDoc(iDocs[j]); 430 } 431 nbDocs=0; 432 } 433 421 434 422 435 xmlNodePtr soapEnvelope(maps* conf,xmlNodePtr n){ … … 447 460 448 461 xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi; 449 xmlNodePtr n,nc,nc1,nc2,nc3,nc4,nc5,nc6,pseudor; 450 xmlChar *xmlbuff; 451 int buffersize; 462 xmlNodePtr n,nc,nc1,nc2,nc3,nc4,nc5,nc6; 452 463 /** 453 464 * Create the document and its temporary root. … … 486 497 if(tmp4!=NULL){ 487 498 map* tmp2=tmp4->content; 488 c har *orderedFields[5];499 const char *orderedFields[5]; 489 500 orderedFields[0]="Title"; 490 501 orderedFields[1]="Abstract"; … … 555 566 if(tmp4!=NULL){ 556 567 map* tmp2=tmp4->content; 557 c har *tmpAddress[6];568 const char *tmpAddress[6]; 558 569 tmpAddress[0]="addressDeliveryPoint"; 559 570 tmpAddress[1]="addressCity"; … … 562 573 tmpAddress[4]="addressCountry"; 563 574 tmpAddress[5]="addressElectronicMailAddress"; 564 c har *tmpPhone[2];575 const char *tmpPhone[2]; 565 576 tmpPhone[0]="phoneVoice"; 566 577 tmpPhone[1]="phoneFacsimile"; 567 c har *orderedFields[12];578 const char *orderedFields[12]; 568 579 orderedFields[0]="providerName"; 569 580 orderedFields[1]="providerSite"; … … 608 619 for(j=0;j<2;j++) 609 620 if(strcasecmp(tmp2->name,tmpPhone[j])==0){ 610 char *toto=NULL; 611 char *toto1=tmp2->name; 612 toto=strstr(toto1,"Phone"); 613 nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+5); 621 char *tmp4=tmp2->name; 622 nc1 = xmlNewNode(ns_ows, BAD_CAST tmp4+5); 614 623 xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value)); 615 624 xmlAddChild(nc5,nc1); … … 621 630 for(j=0;j<6;j++) 622 631 if(strcasecmp(tmp2->name,tmpAddress[j])==0){ 623 char *toto=NULL; 624 char *toto1=tmp2->name; 625 toto=strstr(toto1,"Address"); 626 nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+7); 632 char *tmp4=tmp2->name; 633 nc1 = xmlNewNode(ns_ows, BAD_CAST tmp4+7); 627 634 xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value)); 628 635 xmlAddChild(nc6,nc1); … … 799 806 void printGetCapabilitiesForProcess(maps* m,xmlNodePtr nc,service* serv){ 800 807 xmlNsPtr ns,ns_ows,ns_xlink; 801 xmlNodePtr n r,n,nc1,nc2,nc3,nc4,nc5,nc6,pseudor;808 xmlNodePtr n=NULL,nc1,nc2; 802 809 /** 803 810 * Initialize or get existing namspaces … … 810 817 ns_xlink=usedNs[xlinkId]; 811 818 812 int cursor=0;813 819 map* tmp1; 814 820 if(serv->content!=NULL){ … … 833 839 xmlNodePtr printDescribeProcessHeader(xmlDocPtr doc,const char* service,maps* m){ 834 840 835 xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi; 836 xmlNodePtr n,nr; 837 xmlChar *xmlbuff; 838 int buffersize; 841 xmlNsPtr ns,ns_xsi; 842 xmlNodePtr n; 839 843 840 844 int wpsId=zooXmlAddNs(NULL,"http://schemas.opengis.net/wps/1.0.0","wps"); 841 845 ns=usedNs[wpsId]; 842 846 n = xmlNewNode(ns, BAD_CAST "ProcessDescriptions"); 843 int owsId=zooXmlAddNs(n,"http://www.opengis.net/ows/1.1","ows"); 844 ns_ows=usedNs[owsId]; 847 zooXmlAddNs(n,"http://www.opengis.net/ows/1.1","ows"); 845 848 xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps"); 846 849 zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink"); … … 860 863 861 864 void printDescribeProcessForProcess(maps* m,xmlNodePtr nc,service* serv){ 862 xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi; 863 xmlNodePtr nr,n,nc1,nc2,nc3,nc4,nc5,nc6,pseudor; 864 865 char tmp[256]; 865 xmlNsPtr ns,ns_ows,ns_xlink; 866 xmlNodePtr n,nc1; 867 866 868 n=nc; 867 869 … … 874 876 875 877 nc = xmlNewNode(NULL, BAD_CAST "ProcessDescription"); 876 c har *tmp4[3];878 const char *tmp4[3]; 877 879 tmp4[0]="processVersion"; 878 880 tmp4[1]="storeSupported"; … … 916 918 nc1 = xmlNewNode(NULL, BAD_CAST "DataInputs"); 917 919 elements* e=serv->inputs; 918 printFullDescription( e,"Input",ns_ows,nc1);920 printFullDescription(1,e,"Input",ns_ows,nc1); 919 921 xmlAddChild(nc,nc1); 920 922 } … … 922 924 nc1 = xmlNewNode(NULL, BAD_CAST "ProcessOutputs"); 923 925 elements* e=serv->outputs; 924 printFullDescription( e,"Output",ns_ows,nc1);926 printFullDescription(0,e,"Output",ns_ows,nc1); 925 927 xmlAddChild(nc,nc1); 926 928 … … 929 931 } 930 932 931 void printFullDescription( elements *elem,const char* type,xmlNsPtr ns_ows,xmlNodePtr nc1){932 c har *orderedFields[13];933 void printFullDescription(int in,elements *elem,const char* type,xmlNsPtr ns_ows,xmlNodePtr nc1){ 934 const char *orderedFields[13]; 933 935 orderedFields[0]="mimeType"; 934 936 orderedFields[1]="encoding"; … … 1001 1003 iotype* _tmp=e->defaults; 1002 1004 int datatype=0; 1003 bool hasDefault=false;1004 1005 bool hasUOM=false; 1005 1006 bool hasUOM1=false; … … 1079 1080 * RangeClosure: Table 47 OGC Web Services Common Standard 1080 1081 */ 1081 c har *tmp="closed";1082 const char *tmp="closed"; 1082 1083 if(orig[0]=='[' && orig[strlen(orig)-1]=='[') 1083 1084 tmp="closed-open"; … … 1146 1147 tmp0=getMap(tmp1,"rangeClosure"); 1147 1148 if(tmp0!=NULL){ 1148 c har *tmp="closed";1149 const char *tmp="closed"; 1149 1150 if(strcasecmp(tmp0->value,"co")==0) 1150 1151 tmp="closed-open"; … … 1190 1191 1191 1192 1192 int avcnt=0;1193 int dcnt=0;1194 1193 int oI=0; 1195 1194 for(oI=0;oI<13;oI++) … … 1247 1246 1248 1247 map* metadata=e->metadata; 1249 xmlNodePtr n ;1248 xmlNodePtr n=NULL; 1250 1249 int xlinkId=zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink"); 1251 1250 xmlNsPtr ns_xlink=usedNs[xlinkId]; … … 1353 1352 } 1354 1353 1355 if( datatype==1 &&1354 if(in>0 && datatype==1 && 1356 1355 getMap(_tmp->content,"AllowedValues")==NULL && 1357 1356 getMap(_tmp->content,"range")==NULL && … … 1389 1388 1390 1389 void printProcessResponse(maps* m,map* request, int pid,service* serv,const char* service,int status,maps* inputs,maps* outputs){ 1391 xmlNsPtr ns,ns 1,ns_ows,ns_xlink,ns_xsi;1392 xmlNodePtr nr,n,nc,nc1 ,nc2,nc3,pseudor;1390 xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi; 1391 xmlNodePtr nr,n,nc,nc1=NULL,nc3; 1393 1392 xmlDocPtr doc; 1394 xmlChar *xmlbuff;1395 int buffersize;1396 1393 time_t time1; 1397 1394 time(&time1); … … 1574 1571 if(lineage!=NULL && strcasecmp(lineage->value,"true")==0){ 1575 1572 nc = xmlNewNode(ns, BAD_CAST "DataInputs"); 1576 int i;1577 1573 maps* mcursor=inputs; 1578 1574 elements* scursor=NULL; … … 1727 1723 1728 1724 void printOutputDefinitions(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,elements* e,map* m,const char* type){ 1729 xmlNodePtr nc1 ,nc2,nc3;1725 xmlNodePtr nc1; 1730 1726 nc1=xmlNewNode(ns_wps, BAD_CAST type); 1731 1727 map *tmp=NULL; … … 1774 1770 xmlAddChild(nc1,nc2); 1775 1771 xmlAddChild(nc,nc1); 1776 // Extract Title required to be first element in the ZCFG file !1777 bool isTitle=TRUE;1778 1772 if(e!=NULL) 1779 1773 tmp=getMap(e->content,"Title"); … … 1836 1830 strcasecmp(tmp->name,"schema")==0 || 1837 1831 strcasecmp(tmp->name,"datatype")==0 || 1838 strcasecmp(tmp->name,"uom")==0) 1832 strcasecmp(tmp->name,"uom")==0){ 1839 1833 #ifdef USE_MS 1840 1834 if(testMap==NULL || (testMap!=NULL && strncasecmp(testMap->value,"text/xml",8)==0)){ 1841 1835 #endif 1842 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);1836 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 1843 1837 #ifdef USE_MS 1844 1838 } 1845 else 1846 if(strcasecmp(tmp->name,"mimeType")==0) 1847 if(testMap!=NULL) 1848 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST testMap->value); 1849 else 1850 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 1851 #endif 1839 else 1840 if(strcasecmp(tmp->name,"mimeType")==0){ 1841 if(testMap!=NULL) 1842 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST testMap->value); 1843 else 1844 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 1845 } 1846 #endif 1847 } 1852 1848 tmp=tmp->next; 1853 1849 xmlAddChild(nc2,nc3); … … 1897 1893 if((tmp1!=NULL && strncmp(tmp1->value,"base64",6)==0) 1898 1894 || (tmp2!=NULL && (strncmp(tmp2->value,"image/",6)==0 || 1899 (strncmp(tmp2->value,"application/",12)==0 )&&1900 strncmp(tmp2->value,"application/json",16)!=0&&1901 strncmp(tmp2->value,"application/x-javascript",24)!=0&&1902 strncmp(tmp2->value,"application/vnd.google-earth.kml",32)!=0)1895 (strncmp(tmp2->value,"application/",12)==0 && 1896 strncmp(tmp2->value,"application/json",16)!=0&& 1897 strncmp(tmp2->value,"application/x-javascript",24)!=0&& 1898 strncmp(tmp2->value,"application/vnd.google-earth.kml",32)!=0)) 1903 1899 )) { 1904 1900 map* rs=getMap(m->content,"size"); … … 1906 1902 if(rs==NULL){ 1907 1903 char tmp1[1024]; 1908 sprintf(tmp1,"% d",strlen(tmp3->value));1904 sprintf(tmp1,"%u",strlen(tmp3->value)); 1909 1905 rs=createMap("size",tmp1); 1910 1906 isSized=false; … … 1924 1920 if(strncmp(tmp2->value,"text/xml",8)==0 || 1925 1921 strncmp(tmp2->value,"application/vnd.google-earth.kml",32)==0){ 1926 xmlDocPtr doc =1927 xmlParseMemory(tmp3->value,strlen(tmp3->value));1922 int li=zooXmlAddDoc(tmp3->value); 1923 xmlDocPtr doc = iDocs[li]; 1928 1924 xmlNodePtr ir = xmlDocGetRootElement(doc); 1929 1925 xmlAddChild(nc3,ir); … … 1959 1955 strcasecmp(tmp->name,"schema")==0 || 1960 1956 strcasecmp(tmp->name,"datatype")==0 || 1961 strcasecmp(tmp->name,"uom")==0) 1957 strcasecmp(tmp->name,"uom")==0){ 1962 1958 #ifdef USE_MS 1963 1959 if(testMap!=NULL && strncasecmp(testMap->value,"text/xml",8)!=0){ … … 1967 1963 else 1968 1964 #endif 1969 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 1965 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 1966 } 1970 1967 tmp=tmp->next; 1971 1968 xmlAddChild(nc2,nc3); … … 1983 1980 xmlAddChild(root,nc2); 1984 1981 map* tmp=amap; 1985 c har *tmp2[2];1982 const char *tmp2[2]; 1986 1983 tmp2[0]="Title"; 1987 1984 tmp2[1]="Abstract"; … … 2004 2001 } 2005 2002 else 2006 return "UTF-8";2003 return (char*)"UTF-8"; 2007 2004 } 2008 2005 else 2009 return "UTF-8";2006 return (char*)"UTF-8"; 2010 2007 } 2011 2008 … … 2017 2014 } 2018 2015 else 2019 return "1.0.0";2016 return (char*)"1.0.0"; 2020 2017 } 2021 2018 else 2022 return "1.0.0";2019 return (char*)"1.0.0"; 2023 2020 } 2024 2021 … … 2035 2032 maps* tmpMap=getMaps(m,"main"); 2036 2033 char *encoding=getEncoding(tmpMap); 2037 c har *exceptionCode;2034 const char *exceptionCode; 2038 2035 2039 2036 map* tmp=getMap(s,"code"); … … 2087 2084 xmlNodePtr createExceptionReportNode(maps* m,map* s,int use_ns){ 2088 2085 2089 int buffersize; 2090 xmlChar *xmlbuff; 2091 xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi; 2092 xmlNodePtr n,nc,nc1,nc2; 2093 2094 maps* tmpMap=getMaps(m,"main"); 2086 xmlNsPtr ns,ns_xsi; 2087 xmlNodePtr n,nc,nc1; 2095 2088 2096 2089 int nsid=zooXmlAddNs(NULL,"http://www.opengis.net/ows","ows"); … … 2101 2094 n = xmlNewNode(ns, BAD_CAST "ExceptionReport"); 2102 2095 if(use_ns==1){ 2103 ns_ows=xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",NULL);2096 xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",NULL); 2104 2097 int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi"); 2105 2098 ns_xsi=usedNs[xsiId]; … … 2126 2119 tmp=getMap(s,"text"); 2127 2120 nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText"); 2128 nc2=NULL;2129 2121 if(tmp!=NULL){ 2130 2122 xmlNodeSetContent(nc1, BAD_CAST tmp->value); … … 2154 2146 if(tmpSess!=NULL){ 2155 2147 map *_tmp=getMapFromMaps(m,"lenv","cookie"); 2156 char* sessId ;2148 char* sessId=NULL; 2157 2149 if(_tmp!=NULL){ 2158 2150 printf("Set-Cookie: %s; HttpOnly\r\n",_tmp->value); … … 2493 2485 if(type==0){ 2494 2486 map* tmpMapMinO=getMap(tmpInputs->content,"minOccurs"); 2495 if(tmpMapMinO!=NULL) 2487 if(tmpMapMinO!=NULL){ 2496 2488 if(atoi(tmpMapMinO->value)>=1){ 2497 2489 freeMaps(&tmpMaps2); … … 2505 2497 addToMap(tmpMaps2->content,"minOccurs",tmpMapMinO->value); 2506 2498 } 2499 } 2507 2500 map* tmpMaxO=getMap(tmpInputs->content,"maxOccurs"); 2508 if(tmpMaxO!=NULL) 2501 if(tmpMaxO!=NULL){ 2509 2502 if(tmpMaps2->content==NULL) 2510 2503 tmpMaps2->content=createMap("maxOccurs",tmpMaxO->value); 2511 2504 else 2512 2505 addToMap(tmpMaps2->content,"maxOccurs",tmpMaxO->value); 2506 } 2513 2507 map* tmpMaxMB=getMap(tmpInputs->content,"maximumMegabytes"); 2514 if(tmpMaxMB!=NULL) 2508 if(tmpMaxMB!=NULL){ 2515 2509 if(tmpMaps2->content==NULL) 2516 2510 tmpMaps2->content=createMap("maximumMegabytes",tmpMaxMB->value); 2517 2511 else 2518 2512 addToMap(tmpMaps2->content,"maximumMegabytes",tmpMaxMB->value); 2513 } 2519 2514 } 2520 2515 … … 2572 2567 } 2573 2568 map* tmpMaxMB=getMap(tmpInputs->content,"maximumMegabytes"); 2574 if(tmpMaxMB!=NULL) 2569 if(tmpMaxMB!=NULL){ 2575 2570 if(tmpMaps->content==NULL) 2576 2571 tmpMaps->content=createMap("maximumMegabytes",tmpMaxMB->value); 2577 2572 else 2578 2573 addToMap(tmpMaps->content,"maximumMegabytes",tmpMaxMB->value); 2574 } 2579 2575 /** 2580 2576 * Parsing BoundingBoxData, fill the following map and then add it to … … 2746 2742 void printBoundingBox(xmlNsPtr ns_ows,xmlNodePtr n,map* boundingbox){ 2747 2743 2748 xmlNodePtr bb,lw,uc;2744 xmlNodePtr lw=NULL,uc=NULL; 2749 2745 2750 2746 map* tmp=getMap(boundingbox,"value"); … … 2876 2872 fprintf(stderr,"MIMETYPE: %s\n",mimeType); 2877 2873 #endif 2878 fwrite(mimeType, sizeof(char),strlen(mimeType),fo);2874 fwrite(mimeType,1,strlen(mimeType),fo); 2879 2875 fclose(fo); 2880 2876 … … 2914 2910 char* cached=isInCache(*m,url); 2915 2911 char *mimeType=NULL; 2916 int fsize; 2917 int hasF=-1; 2912 int fsize=0; 2918 2913 if(cached!=NULL){ 2919 2914 struct stat f_status; … … 2922 2917 fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 2923 2918 FILE* f=fopen(cached,"rb"); 2924 int len=fread(fcontent,f_status.st_size,1,f);2919 fread(fcontent,f_status.st_size,1,f); 2925 2920 fsize=f_status.st_size; 2926 2921 fcontent[fsize]=0; … … 2932 2927 mimeType=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 2933 2928 FILE* f=fopen(cached,"rb"); 2934 int len=fread(mimeType,f_status.st_size,1,f);2929 fread(mimeType,f_status.st_size,1,f); 2935 2930 mimeType[f_status.st_size]=0; 2936 2931 fclose(f); … … 2970 2965 if(cached==NULL) 2971 2966 addToCache(*m,url,fcontent,mimeType,fsize); 2972 else{ 2973 free(fcontent); 2974 free(mimeType); 2975 free(cached); 2976 } 2967 free(fcontent); 2968 free(mimeType); 2969 free(cached); 2977 2970 return 0; 2978 2971 } … … 2992 2985 } 2993 2986 2987 2994 2988 char *readVSIFile(maps* conf,const char* dataSource){ 2995 2989 VSILFILE * fichier=VSIFOpenL(dataSource,"rb"); … … 3004 2998 } 3005 2999 char *res1=(char *)malloc(file_status.st_size*sizeof(char)); 3006 VSIFReadL(res1,1,(file_status.st_size)*sizeof(char),fichier); 3000 VSIFReadL(res1,1,file_status.st_size*sizeof(char),fichier); 3001 res1[file_status.st_size-1]=0; 3007 3002 VSIFCloseL(fichier); 3008 3003 VSIUnlink(dataSource); … … 3065 3060 } 3066 3061 3067 3068 3062 int updateStatus( maps* conf, const int percentCompleted, const char* message ){ 3069 3063 char tmp[4]; … … 3098 3092 tmp->value=(char*) malloc((numberOfBytes+1)*sizeof(char)); 3099 3093 memcpy(tmp->value,data,numberOfBytes); 3100 sprintf(size,"% d",numberOfBytes);3094 sprintf(size,"%lu",numberOfBytes); 3101 3095 setMapInMaps(outputs,parameterName,"size",size); 3102 3096 }
Note: See TracChangeset
for help on using the changeset viewer.