Changeset 839 for branches/prototype-v0
- Timestamp:
- Aug 7, 2017, 2:56:24 PM (7 years ago)
- Location:
- branches/prototype-v0
- Files:
-
- 9 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/thirds/otb2zcfg/otb2zcfg.cxx
r783 r839 312 312 std::string s=m_Application->GetParameterDescription(paramKey); 313 313 if(s.length()>0){ 314 s=ReplaceAll(ReplaceAll(s,std::string("\n"),std::string("")),std::string("\t"),std::string("")); 314 315 std::cout << " Title = " << s << std::endl; 315 316 std::cout << " Abstract = " << s << std::endl; -
branches/prototype-v0/zoo-project/zoo-kernel/Makefile.in
r822 r839 41 41 g++ -fPIC ${CFLAGS} -c sshapi.c 42 42 43 service_json.o: service_json.c 44 g++ -fPIC ${JSON_CFLAGS} ${CFLAGS} -c service_json.c 45 46 service_callback.o: service_callback.c 47 g++ -fPIC ${JSON_CFLAGS} ${CFLAGS} -c service_callback.c 48 43 49 request_parser.o: request_parser.c request_parser.h 44 50 g++ -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c request_parser.c … … 51 57 52 58 response_print.o: response_print.c response_print.h 53 g++ -fPIC ${GDAL_CFLAGS} ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c response_print.c59 g++ -fPIC ${GDAL_CFLAGS} ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} ${HPC_ENABLED} -c response_print.c 54 60 55 61 server_internal.o: server_internal.c server_internal.h service.h mimetypes.h … … 76 82 77 83 service_internal_hpc.o: service_internal_hpc.c service_internal_hpc.h service.h 78 g++ ${ XML2CFLAGS} ${HPCCFLAGS} ${CFLAGS} -c service_internal_hpc.c84 g++ ${JSON_CFLAGS} ${XML2CFLAGS} ${HPCCFLAGS} ${CFLAGS} -c service_internal_hpc.c 79 85 80 86 service_internal_saga.o: service_internal_saga.c service_internal_saga.h service.h … … 109 115 110 116 zoo_service_loader.o: zoo_service_loader.c service.h version.h ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE} ${MONO_FILE} ${HPC_FILES} ${METADB_FILE} 111 g++ -g -O2 ${ GDAL_CFLAGS} ${XML2CFLAGS} ${CFLAGS} ${MONO_CFLAGS} ${SAGA_CFLAGS} ${OTBCFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${SAGA_ENABLED} ${OTB_ENABLED} ${HPC_ENABLED} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} ${MONO_ENABLED} ${METADB_ENABLED} -c zoo_service_loader.c -fno-common -DPIC -o zoo_service_loader.o117 g++ -g -O2 ${JSON_CFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${CFLAGS} ${MONO_CFLAGS} ${SAGA_CFLAGS} ${OTBCFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${SAGA_ENABLED} ${OTB_ENABLED} ${HPC_ENABLED} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} ${MONO_ENABLED} ${METADB_ENABLED} -c zoo_service_loader.c -fno-common -DPIC -o zoo_service_loader.o 112 118 113 119 libzoo_service.${EXT}: version.h service_internal.o service.o sqlapi.o 114 gcc -shared ${GDAL_CFLAGS} ${DEFAULT_OPTS} -fpic -o libzoo_service.${EXT} ${CFLAGS} service_internal.o service.o sqlapi.o ${FCGI_LDFLAGS} ${GDAL_LIBS} 120 gcc -shared ${GDAL_CFLAGS} ${DEFAULT_OPTS} -fpic -o libzoo_service.${EXT} ${CFLAGS} service_internal.o service.o sqlapi.o ${FCGI_LDFLAGS} ${GDAL_LIBS} ${ZOO_LDFLAGS} 115 121 116 zoo_loader.cgi: version.h libzoo_service.${EXT} zoo_loader.c zoo_service_loader.o ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o request_parser.o response_print.o server_internal.o caching.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE} ${HPC_FILES} ${METADB_FILE} 117 g++ -g -O2 ${JS CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${RUBYCFLAGS} ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c -fno-common -DPIC -o zoo_loader.o118 g++ ${JS CFLAGS} ${SAGA_CFLAGS} ${OTBCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_loader.o zoo_service_loader.o ${MS_FILE} ${PYTHON_FILE} ${PERL_FILE} ${PHP_FILE} ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE} ${MONO_FILE} ${HPC_FILES} ${METADB_FILE}response_print.o server_internal.o caching.o request_parser.o ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi -L. ${LDFLAGS}122 zoo_loader.cgi: version.h libzoo_service.${EXT} zoo_loader.c zoo_service_loader.o ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o request_parser.o response_print.o server_internal.o caching.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE} ${HPC_FILES} ${METADB_FILE} ${JSON_FILE} service_callback.o 123 g++ -g -O2 ${JSON_CFLAGS} ${JSCFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${RUBYCFLAGS} ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c -fno-common -DPIC -o zoo_loader.o 124 g++ ${JSON_CFLAGS} ${JSCFLAGS} ${SAGA_CFLAGS} ${OTBCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_loader.o zoo_service_loader.o ${MS_FILE} ${PYTHON_FILE} ${PERL_FILE} ${PHP_FILE} ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE} ${MONO_FILE} ${HPC_FILES} ${METADB_FILE} ${JSON_FILE} service_callback.o response_print.o server_internal.o caching.o request_parser.o ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi -L. ${LDFLAGS} 119 125 120 126 zcfg2yaml: zcfg2yaml.c service.h lex.sr.o service_conf.tab.o service_conf.y main_conf_read.tab.o lex.cr.o response_print.o server_internal.o service_internal.o ${MS_FILE} ${YAML_FILE} -
branches/prototype-v0/zoo-project/zoo-kernel/ZOOMakefile.opts.in
r822 r839 29 29 YAML_FILE=@YAML_FILE@ 30 30 YAML_FILE1=@YAML_FILE1@ 31 32 JSON_CFLAGS=@JSON_CPPFLAGS@ 33 JSON_LDFLAGS=@JSON_LDFLAGS@ 34 JSON_FILE=@JSON_FILE@ 31 35 32 36 METADB_ENABLED=@METADB@ … … 111 115 112 116 CFLAGS=@SSH2_CPPFLAGS@ @GETTEXT_CFLAGS@ @PROJ_CPPFLAGS@ @RELY_ON_DB@ @DEB_DEF@ -fpic @OPENSSL_CFLAGS@ @UUID_CFLAGS@ ${FCGI_CFLAGS} ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF 113 LDFLAGS=-lzoo_service @SSH2_LDFLAGS@ @PROJ_LDFLAGS@ @DEFAULT_LIBS@ -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS} ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} ${FCGI_LDFLAGS} @OPENSSL_LDFLAGS@ @UUID_LDFLAGS@ ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${MACOS_LD_NET_FLAGS} ${YAML_LDFLAGS} ${OTBLDFLAGS} ${SAGA_LDFLAGS} ${MONO_LDFLAGS} @GETTEXT_LDFLAGS@ 117 LDFLAGS=-lzoo_service @SSH2_LDFLAGS@ @PROJ_LDFLAGS@ @DEFAULT_LIBS@ -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS} ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} ${FCGI_LDFLAGS} @OPENSSL_LDFLAGS@ @UUID_LDFLAGS@ ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${MACOS_LD_NET_FLAGS} ${YAML_LDFLAGS} ${OTBLDFLAGS} ${SAGA_LDFLAGS} ${MONO_LDFLAGS} @GETTEXT_LDFLAGS@ @JSON_LDFLAGS@ 114 118 115 119 DATAROOTDIR=@datarootdir@/zoo-project -
branches/prototype-v0/zoo-project/zoo-kernel/caching.c
r822 r839 158 158 */ 159 159 int readCurrentInput(maps** m,maps** in,int* index,HINTERNET* hInternet,map** error){ 160 160 161 map* tmp1; 161 162 char sindex[5]; … … 212 213 sprintf(sindex,"%d",*index+1); 213 214 if((tmp1=getMap(content->content,xname))!=NULL && tmap!=NULL && strcasecmp(tmap->value,sindex)==0){ 214 215 if(getMap(content->content,icname)==NULL){ 215 216 if(getMap(content->content,icname)==NULL){ 216 217 fcontent=(char*)malloc((hInternet->ihandle[*index].nDataLen+1)*sizeof(char)); 217 218 if(fcontent == NULL){ … … 266 267 char* md5str=NULL; 267 268 if((tmp2=getMap(content->content,bname))!=NULL){ 268 dumpMap(tmp2);269 269 char *tmpStr=(char*)malloc((strlen(tmp1->value)+strlen(tmp2->value)+1)*sizeof(char)); 270 270 sprintf(tmpStr,"%s%s",tmp1->value,tmp2->value); 271 271 if((tmp2=getMap(content->content,"headers"))!=NULL){ 272 272 char *tmpStr2=zStrdup(tmpStr); 273 free(tmpStr); 273 274 tmpStr=(char*)malloc((strlen(tmpStr2)+strlen(tmp2->value)+1)*sizeof(char)); 274 275 sprintf(tmpStr,"%s%s",tmpStr2,tmp2->value); … … 293 294 free(mimeType); 294 295 free(request); 295 *index++; 296 296 (*index)++; 297 297 } 298 298 } … … 361 361 free(oreq); 362 362 }else{ 363 setMapArray(oreq->content,"value",hInternet->nb -1,url);363 setMapArray(oreq->content,"value",hInternet->nb,url); 364 364 } 365 365 } … … 444 444 addToMap(*content,"cache_file",fname); 445 445 free(fname); 446 free(md5str); 446 447 } 447 448 } -
branches/prototype-v0/zoo-project/zoo-kernel/configure.ac
r822 r839 60 60 AC_SUBST([UUID_CFLAGS]) 61 61 AC_SUBST([UUID_LDFLAGS]) 62 63 #============================================================================ 64 # Detect if json-c is available 65 #============================================================================ 66 67 AC_ARG_WITH([json], 68 [AS_HELP_STRING([--with-json=PATH], [Specifies an alternative location for the json-c library])], 69 [JSON_DIR="$withval"], [JSON_DIR="/usr/"]) 70 JSON_CPPFLAGS="-I$JSON_DIR/include/json-c/" 71 JSON_LDFLAGS="-L$JSON_DIR/lib -ljson-c" 72 CPPFLAGS_SAVE="$CPPFLAGS" 73 CPPFLAGS="$JSON_CPPFLAGS" 74 LIBS_SAVE="$LIBS" 75 LIBS="$JSON_LDFLAGS" 76 echo $CPPFLAGS 77 AC_CHECK_HEADERS([json_object.h], 78 [], [AC_MSG_ERROR([could not find header file json_object.h])]) 79 AC_CHECK_LIB([json-c], [json_object_new_object], 80 [], [AC_MSG_ERROR([could not find function in json-c library])]) 81 CPPFLAGS="$CPPFLAGS_SAVE" 82 JSON_FILE="service_json.o" 83 JSON_ENABLED="-DJSON" 84 AC_SUBST([JSON_CPPFLAGS]) 85 AC_SUBST([JSON_LDFLAGS]) 86 AC_SUBST([JSON_FILE]) 87 AC_SUBST([JSON_ENABLED]) 62 88 63 89 #============================================================================ -
branches/prototype-v0/zoo-project/zoo-kernel/main_conf_read.y
r790 r839 99 99 } 100 100 free(curr_key); 101 curr_key=NULL; 101 102 } 102 103 | SPAIR {curr_key=zStrdup($1);if(debug) printf("SPAIR FOUND !!\n"); } … … 162 163 free(current_content); 163 164 } 165 if(curr_key!=NULL){ 166 free(curr_key); 167 } 164 168 165 169 fclose(crin); -
branches/prototype-v0/zoo-project/zoo-kernel/mimetypes.h
r601 r839 180 180 { "application/vnd.dece.unspecified", "uvx" }, 181 181 { "application/vnd.dece.zip", "uvz" }, 182 { "application/vnd.denovo.fcselayout-link", "fe_launch" }, 182 { "application/vnd.denovo.fcselayout-link", "fe_launch" }, 183 183 { "application/vnd.dna", "dna" }, 184 184 { "application/vnd.dolby.mlp", "mlp" }, … … 836 836 return ext; 837 837 } 838 839 static int isGeographic(const char* mimeType){ 840 char* imageMimeType[4]={ 841 "image/tiff", 842 "image/png", 843 "image/jpeg", 844 "application/vnd.google-earth.kmz" 845 }; 846 char* vectorMimeType[5]={ 847 "text/xml", 848 "application/json", 849 "application/gml+xml", 850 "application/zip", 851 "application/vnd.google-earth.kml+xml" 852 }; 853 int i=0; 854 for(;i<4;i++){ 855 if(strncmp(imageMimeType[i],mimeType,strlen(imageMimeType[i]))==0) 856 return 1; 857 } 858 i=0; 859 for(;i<5;i++){ 860 if(strncmp(vectorMimeType[i],mimeType,strlen(vectorMimeType[i]))==0) 861 return 2; 862 } 863 return -1; 864 } -
branches/prototype-v0/zoo-project/zoo-kernel/request_parser.c
r802 r839 533 533 xmlChar *val = xmlGetProp (cur, BAD_CAST "id"); 534 534 tmpmaps = createMaps((char *) val); 535 xmlFree(val); 535 536 } 536 537 … … 624 625 tmpmaps->content = 625 626 createMap (refs[l], (char *) val); 626 627 627 map *ltmp = getMap (tmpmaps->content, "method"); 628 628 if (l == 4 ) … … 750 750 map *btmp = 751 751 getMap (tmpmaps->content, "Reference"); 752 addToMap (tmpmaps->content, "Body", tmp); 752 753 if (btmp != NULL) 753 754 { … … 815 816 &bRead); 816 817 tmp[bInternet.ihandle[0].nDataLen] = 0; 817 InternetCloseHandle (&bInternet); 818 InternetCloseHandle(&bInternet); 819 addToMap (tmpmaps->content, "Body", tmp); 818 820 map *btmp = 819 821 getMap (tmpmaps->content, "href"); … … 832 834 } 833 835 free (tmp); 836 xmlFree (val); 834 837 } 835 838 } … … 1120 1123 const char ress[4][13] = 1121 1124 { "mimeType", "encoding", "schema", "transmission" }; 1125 xmlFree (val); 1122 1126 for (l = 0; l < 4; l++){ 1123 1127 val = xmlGetProp (cur, BAD_CAST ress[l]); … … 1139 1143 while (ccur != NULL){ 1140 1144 if(ccur->type == XML_ELEMENT_NODE){ 1141 char *xpathExpr=(char*)malloc(6 5+strlen(tmpmaps->name));1142 sprintf(xpathExpr,"/*/*[local-name()='Output' and @id='%s']/*[local-name()='Output']",tmpmaps->name); 1145 char *xpathExpr=(char*)malloc(66+strlen(tmpmaps->name)); 1146 sprintf(xpathExpr,"/*/*[local-name()='Output' and @id='%s']/*[local-name()='Output']",tmpmaps->name); 1143 1147 xmlXPathObjectPtr tmpsptr = extractFromDoc (doc, xpathExpr); 1144 1148 xmlNodeSet* cnodes = tmpsptr->nodesetval; 1145 1149 xmlParseOutputs2(main_conf,request_inputs,&tmpmaps->child,doc,cnodes); 1150 xmlXPathFreeObject (tmpsptr); 1151 free(xpathExpr); 1146 1152 break; 1147 1153 } … … 1424 1430 else 1425 1431 addToMap(*request_inputs,"mode","auto"); 1432 xmlFree(val); 1426 1433 val = xmlGetProp (cur, BAD_CAST "response"); 1427 1434 if(val!=NULL){ … … 1436 1443 addToMap(*request_inputs,"ResponseDocument",""); 1437 1444 } 1445 xmlFree(val); 1438 1446 } 1439 1447 } -
branches/prototype-v0/zoo-project/zoo-kernel/response_print.c
r822 r839 23 23 */ 24 24 25 #include "service.h" 25 26 #include "response_print.h" 26 27 #include "request_parser.h" … … 644 645 * @return the generated wps:ProcessOfferings xmlNodePtr 645 646 */ 646 void printGetCapabilitiesForProcess(registry *reg, maps* m,xml NodePtr nc,service* serv){647 void printGetCapabilitiesForProcess(registry *reg, maps* m,xmlDocPtr doc,xmlNodePtr nc,service* serv){ 647 648 xmlNsPtr ns,ns_ows,ns_xml,ns_xlink; 648 649 xmlNodePtr n=NULL,nc1,nc2,nc3; … … 692 693 tmp1=serv->metadata; 693 694 694 addMetadata(tmp1,nc1,ns_ows,ns_xlink); 695 696 /*while(tmp1!=NULL){ 697 nc2 = xmlNewNode(ns_ows, BAD_CAST "Metadata"); 698 if(strcmp(tmp1->name,"title")==0 || 699 strcmp(tmp1->name,"href")==0 || 700 strcmp(tmp1->name,"role")==0 || 701 strcmp(tmp1->name,"link_type")==0){ 702 xmlNewNsProp(nc2,ns_xlink,BAD_CAST tmp1->name,BAD_CAST tmp1->value); 703 xmlAddChild(nc1,nc2); 704 }else{ 705 if(nc3==NULL) 706 nc3 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameter"); 707 xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Name"); 708 xmlAddChild(nc4,xmlNewText(BAD_CAST tmp1->name)); 709 xmlNodePtr nc5 = xmlNewNode(ns_ows, BAD_CAST "Value"); 710 xmlAddChild(nc5,xmlNewText(BAD_CAST tmp1->value)); 711 xmlAddChild(nc3,nc4); 712 xmlAddChild(nc3,nc5); 713 } 714 tmp1=tmp1->next; 715 }*/ 695 addMetadata(tmp1,doc,nc1,ns_ows,ns_xlink); 696 tmp1=serv->additional_parameters; 697 int fromDb=-1; 698 map* test=getMap(serv->content,"fromDb"); 699 if(test!=NULL && strncasecmp(test->value,"true",4)==0) 700 fromDb=1; 701 addAdditionalParameters(tmp1,doc,nc1,ns_ows,ns_xlink,fromDb); 702 716 703 if(nc3!=NULL) 717 704 xmlAddChild(nc1,nc3); … … 756 743 } 757 744 758 int addMetadata(map* meta,xml NodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink){745 int addMetadata(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink){ 759 746 int hasTitle=-1; 760 747 int hasValue=-1; … … 830 817 } 831 818 819 820 int addAdditionalParameters(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,int fromDb){ 821 int hasTitle=-1; 822 int hasValue=-1; 823 xmlNodePtr nc1; 824 map* oMeta=meta; 825 int isAdditionalParameters=-1; 826 //if(count(oMeta)>=2){ 827 int level=0; 828 map* test=getMap(meta,"title"); 829 if(test!=NULL) 830 level+=1; 831 test=getMap(meta,"href"); 832 if(test!=NULL) 833 level+=1; 834 test=getMap(meta,"role"); 835 if(test!=NULL) 836 level+=1; 837 if(count(oMeta)>level+1) 838 isAdditionalParameters=1; 839 //} 840 char *ctitle=NULL; 841 while(meta!=NULL){ 842 if(hasTitle<0) 843 if(hasValue<0) 844 nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters"); 845 if(strncasecmp(meta->name,"title",5)==0 || 846 strcasecmp(meta->name,"href")==0 || 847 strcasecmp(meta->name,"role")==0 ){ 848 int index=5; 849 if(strncasecmp(meta->name,"title",5)==0){ 850 index=6; 851 hasTitle=1; 852 if(ctitle!=NULL && strcasecmp(meta->value,ctitle)!=0){ 853 xmlAddChild(nc,nc1); 854 nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters"); 855 free(ctitle); 856 ctitle=NULL; 857 } 858 if(ctitle==NULL){ 859 char *tmp=(char*)malloc((strlen(meta->name)+1)*sizeof(char)); 860 snprintf(tmp,index,"%s",meta->name); 861 xmlNewNsProp(nc1,ns_xlink,BAD_CAST tmp,BAD_CAST meta->value); 862 free(tmp); 863 } 864 if(ctitle!=NULL) 865 free(ctitle); 866 ctitle=zStrdup(meta->value); 867 } 868 }else{ 869 xmlNodePtr nc2 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameter"); 870 xmlNodePtr nc3 = xmlNewNode(ns_ows, BAD_CAST "Name"); 871 xmlAddChild(nc3,xmlNewText(BAD_CAST meta->name)); 872 xmlAddChild(nc2,nc3); 873 if(fromDb<0){ 874 char *mptr; 875 char* meta_values=strtok_r(meta->value,",",&mptr); 876 while(meta_values!=NULL){ 877 xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Value"); 878 xmlAddChild(nc4,xmlNewText(BAD_CAST meta_values)); 879 xmlAddChild(nc2,nc4); 880 meta_values=strtok_r(NULL,",",&mptr); 881 } 882 }else{ 883 xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Value"); 884 xmlAddChild(nc4,xmlNewCDataBlock(doc,BAD_CAST meta->value,strlen(meta->value))); 885 xmlAddChild(nc2,nc4); 886 } 887 xmlAddChild(nc1,nc2); 888 hasTitle=-1; 889 } 890 meta=meta->next; 891 if(hasTitle<0){ 892 xmlAddChild(nc,nc1); 893 hasValue=1; 894 } 895 } 896 if(oMeta!=NULL && hasValue<0 && nc1!=NULL){ 897 xmlAddChild(nc,nc1); 898 } 899 } 900 832 901 /** 833 902 * Add the ows:Metadata nodes relative to the profile registry … … 886 955 * @return the generated wps:ProcessOfferings xmlNodePtr 887 956 */ 888 void printDescribeProcessForProcess(registry *reg, maps* m,xml NodePtr nc,service* serv){957 void printDescribeProcessForProcess(registry *reg, maps* m,xmlDocPtr doc,xmlNodePtr nc,service* serv){ 889 958 xmlNsPtr ns,ns_ows,ns_xlink; 890 959 xmlNodePtr n,nc1; … … 892 961 map* version=getMapFromMaps(m,"main","rversion"); 893 962 int vid=getVersionId(version->value); 963 int fromDb=-1; 964 map* serviceType=getMap(serv->content,"serviceType"); 965 map* test=getMap(serv->content,"fromDb"); 966 if(test!=NULL && strncasecmp(test->value,"true",4)==0) 967 fromDb=1; 894 968 895 969 n=nc; … … 937 1011 tmp1=serv->metadata; 938 1012 while(tmp1!=NULL){ 939 addMetadata(tmp1, nc,ns_ows,ns_xlink);1013 addMetadata(tmp1,doc,nc,ns_ows,ns_xlink); 940 1014 /*nc1 = xmlNewNode(ns_ows, BAD_CAST "Metadata"); 941 1015 xmlNewNsProp(nc1,ns_xlink,BAD_CAST tmp1->name,BAD_CAST tmp1->value); … … 951 1025 }else{ 952 1026 tmp1=serv->metadata; 953 addMetadata(tmp1, nc,ns_ows,ns_xlink);1027 addMetadata(tmp1,doc,nc,ns_ows,ns_xlink); 954 1028 addInheritedMetadata(nc,ns_ows,ns_xlink,reg,m,serv); 1029 tmp1=serv->additional_parameters; 1030 addAdditionalParameters(tmp1,doc,nc,ns_ows,ns_xlink,fromDb); 955 1031 } 956 1032 … … 959 1035 if(vid==0){ 960 1036 nc1 = xmlNewNode(NULL, BAD_CAST "DataInputs"); 961 printFullDescription( 1,e,"Input",ns,ns_ows,nc1,vid);1037 printFullDescription(doc,1,e,"Input",ns,ns_ows,nc1,vid,fromDb,NULL); 962 1038 xmlAddChild(nc,nc1); 963 1039 } 964 1040 else{ 965 printFullDescription( 1,e,"wps:Input",ns,ns_ows,nc,vid);1041 printFullDescription(doc,1,e,"wps:Input",ns,ns_ows,nc,vid,fromDb,NULL); 966 1042 } 967 1043 } … … 970 1046 if(vid==0){ 971 1047 nc1 = xmlNewNode(NULL, BAD_CAST "ProcessOutputs"); 972 printFullDescription( 0,e,"Output",ns,ns_ows,nc1,vid);1048 printFullDescription(doc,0,e,"Output",ns,ns_ows,nc1,vid,fromDb,NULL); 973 1049 xmlAddChild(nc,nc1); 974 1050 } 975 1051 else{ 976 printFullDescription( 0,e,"wps:Output",ns,ns_ows,nc,vid);1052 printFullDescription(doc,0,e,"wps:Output",ns,ns_ows,nc,vid,fromDb,serviceType); 977 1053 } 978 1054 if(vid==0) … … 996 1072 * @param nc1 the XML node to use to add the created tree 997 1073 * @param vid the WPS version id (0 for 1.0.0, 1 for 2.0.0) 998 */ 999 void printFullDescription(int in,elements *elem,const char* type,xmlNsPtr ns,xmlNsPtr ns_ows,xmlNodePtr nc1,int vid){ 1074 * @param fromDb 1 in case the metadata comes from the DB, -1 in other cases 1075 * @param serviceType the serviceType found in the ZCFG file or the DB 1076 */ 1077 void printFullDescription(xmlDocPtr doc,int in,elements *elem,const char* type,xmlNsPtr ns,xmlNsPtr ns_ows,xmlNodePtr nc1,int vid,int fromDb,const map* serviceType){ 1000 1078 xmlNsPtr ns1=NULL; 1001 1079 if(vid==1) … … 1032 1110 1033 1111 if(e->format!=NULL){ 1112 #ifdef USE_HPC 1113 DEFAULT_OUT: 1114 #endif 1034 1115 const char orderedFields[13][14]={ 1035 1116 "mimeType", … … 1138 1219 char *tmps=strdup(token); 1139 1220 tmps[strlen(tmps)]=0; 1140 xmlAddChild(nc7,xmlNewText(BAD_CAST tmps)); 1221 nc8 = xmlNewText(BAD_CAST tmps); 1222 xmlAddChild(nc7,nc8); 1141 1223 free(tmps); 1142 1224 xmlAddChild(nc6,nc7); … … 1437 1519 xmlNsPtr ns_xlink=usedNs[xlinkId]; 1438 1520 1439 dumpMap(metadata); 1440 addMetadata(metadata,nc2,ns_ows,ns_xlink); 1521 //dumpMap(metadata); 1522 addMetadata(metadata,doc,nc2,ns_ows,ns_xlink); 1523 addAdditionalParameters(e->additional_parameters,doc,nc2,ns_ows,ns_xlink,fromDb); 1441 1524 1442 1525 } … … 1583 1666 xmlAddChild(nc2,nc3); 1584 1667 }else{ 1585 if(e->child!=NULL && vid!=0){ 1586 printFullDescription(in,e->child,type,ns,ns_ows,nc2,vid); 1587 } 1588 } 1589 1668 if(e->child!=NULL){ 1669 if(e->child!=NULL && vid!=0){ 1670 printFullDescription(doc,in,e->child,type,ns,ns_ows,nc2,vid,fromDb,NULL); 1671 } 1672 } 1673 } 1590 1674 if(e->child!=NULL && vid==0){ 1591 1675 elements* children=dupElements(e->child); … … 1598 1682 cursor=cursor->next; 1599 1683 } 1600 printFullDescription( in,children,type,ns,ns_ows,nc2,vid);1684 printFullDescription(doc,in,children,type,ns,ns_ows,nc2,vid,fromDb,serviceType); 1601 1685 xmlAddChild(nc1,nc2); 1602 1686 freeElements(&children); … … 1604 1688 }else 1605 1689 xmlAddChild(nc1,nc2); 1606 1607 1690 e=e->next; 1608 1691 } … … 2588 2671 toto=getMap(tmpI->content,"asReference"); 2589 2672 #ifdef USE_MS 2590 if(toto!=NULL && strcasecmp(toto->value,"true")==0 && testMap==NULL)2673 if(toto!=NULL && strcasecmp(toto->value,"true")==0 && (testMap==NULL || strncasecmp(testMap->value,"true",4)!=0) ) 2591 2674 #else 2592 2675 if(toto!=NULL && strcasecmp(toto->value,"true")==0) -
branches/prototype-v0/zoo-project/zoo-kernel/response_print.h
r822 r839 209 209 xmlNodePtr printWPSHeader(xmlDocPtr,maps*,const char*,const char*,const char*,int); 210 210 xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr,maps*,const char*); 211 void printGetCapabilitiesForProcess(registry*,maps*,xml NodePtr,service*);212 void printDescribeProcessForProcess(registry*,maps*,xml NodePtr,service*);213 void printFullDescription( int,elements*,const char*,xmlNsPtr,xmlNsPtr,xmlNodePtr,int);211 void printGetCapabilitiesForProcess(registry*,maps*,xmlDocPtr,xmlNodePtr,service*); 212 void printDescribeProcessForProcess(registry*,maps*,xmlDocPtr,xmlNodePtr,service*); 213 void printFullDescription(xmlDocPtr,int,elements*,const char*,xmlNsPtr,xmlNsPtr,xmlNodePtr,int,int,const map*); 214 214 void printDocument(maps*,xmlDocPtr,int); 215 215 void printDescription(xmlNodePtr,xmlNsPtr,const char*,map*,int); … … 220 220 void printOutputDefinitions(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*); 221 221 void printStatusInfo(maps*,map*,char*); 222 int addMetadata(map* meta,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink); 222 int addAdditionalParameters(map*,xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,int); 223 int addMetadata(map*,xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr); 223 224 224 225 void outputResponse(service*,maps*,maps*,map*,int,maps*,int); -
branches/prototype-v0/zoo-project/zoo-kernel/server_internal.c
r822 r839 597 597 setMapArray(res,"value",nb,out1->name); 598 598 } 599 600 599 nb++; 601 600 result=out1->name; … … 806 805 */ 807 806 if(tmpIoType!=NULL){ 808 map* tmpCheck=getMap(tmpIoType->content,"useMap Server");809 if(tmpCheck!=NULL ){807 map* tmpCheck=getMap(tmpIoType->content,"useMapserver"); 808 if(tmpCheck!=NULL && strncasecmp(tmpCheck->value,"true",4)==0){ 810 809 // Get the default value 811 810 tmpIoType=getIoTypeFromElement(tmpInputs,tmpInputs->name,NULL); … … 841 840 } 842 841 } 843 /*if(tmpInputs->child!=NULL){842 if(tmpInputs->child!=NULL){ 844 843 tmpInputss=tmpInputs->next; 845 844 tmpInputs=tmpInputs->child; … … 848 847 out1s=tmpMaps; 849 848 } 850 }else*/851 849 } 850 tmpInputs=tmpInputs->next; 852 851 } 853 852 if(tmpInputss!=NULL){ … … 980 979 if(isRunning(conf,pid)>0){ 981 980 if(strncasecmp(req,"GetResult",strlen(req))==0){ 982 errorException (conf, _("The result for the requested JobID has not yet been generated. "),981 errorException (conf, _("The result for the requested JobID has not yet been generated. (1)"), 983 982 "ResultNotReady", pid); 984 983 return; … … 1012 1011 return; 1013 1012 }else{ 1014 errorException (conf, _("The result for the requested JobID has not yet been generated. "),1013 errorException (conf, _("The result for the requested JobID has not yet been generated. (2)"), 1015 1014 "ResultNotReady", pid); 1016 1015 freeMap(&statusInfo); … … 1034 1033 } 1035 1034 } 1035 free(sid); 1036 1036 printStatusInfo(conf,statusInfo,req); 1037 1037 freeMap(&statusInfo); -
branches/prototype-v0/zoo-project/zoo-kernel/service.c
r822 r839 146 146 147 147 /** 148 * Create a new iotype* 149 * 150 * @return a pointer to the allocated iotype 151 */ 152 iotype* createIoType(){ 153 iotype* io=(iotype*)malloc(IOTYPE_SIZE); 154 io->content=NULL; 155 io->next=NULL; 156 return io; 157 } 158 159 /** 148 160 * Create a new map 149 161 * … … 400 412 if(tmp->metadata!=NULL) 401 413 free(tmp->metadata); 414 freeMap(&tmp->additional_parameters); 415 if(tmp->additional_parameters!=NULL) 416 free(tmp->additional_parameters); 402 417 if(tmp->format!=NULL) 403 418 free(tmp->format); … … 831 846 } 832 847 } 833 else 848 else{ 834 849 sprintf(tmp,"%s",key); 850 addToMap(m,"length","1"); 851 } 835 852 map* tmpSize=getMapArray(m,"size",index); 836 853 if(tmpSize!=NULL && strncasecmp(key,"value",5)==0){ … … 964 981 res->content=NULL; 965 982 res->metadata=NULL; 983 res->additional_parameters=NULL; 966 984 res->format=NULL; 967 985 res->defaults=NULL; … … 983 1001 res->content=NULL; 984 1002 res->metadata=NULL; 1003 res->additional_parameters=NULL; 985 1004 res->format=NULL; 986 1005 res->defaults=NULL; … … 1022 1041 fprintf(stderr," > METADATA [%s]\n",tmp->name); 1023 1042 dumpMap(tmp->metadata); 1043 fprintf(stderr," > ADDITIONAL PARAMETERS [%s]\n",tmp->name); 1044 dumpMap(tmp->additional_parameters); 1024 1045 fprintf(stderr," > FORMAT [%s]\n",tmp->format); 1025 1046 iotype* tmpio=tmp->defaults; … … 1139 1160 elements* cursor=e; 1140 1161 elements* tmp=NULL; 1141 if(cursor!=NULL ){1162 if(cursor!=NULL && e->name!=NULL){ 1142 1163 #ifdef DEBUG 1143 1164 fprintf(stderr,">> %s %i\n",__FILE__,__LINE__); … … 1151 1172 tmp->metadata=NULL; 1152 1173 addMapToMap(&tmp->metadata,e->metadata); 1174 tmp->additional_parameters=NULL; 1175 addMapToMap(&tmp->additional_parameters,e->additional_parameters); 1153 1176 if(e->format!=NULL) 1154 1177 tmp->format=zStrdup(e->format); … … 1187 1210 else 1188 1211 tmp->child=NULL; 1189 tmp->next=dupElements(cursor->next); 1212 if(cursor->next!=NULL) 1213 tmp->next=dupElements(cursor->next); 1214 else 1215 tmp->next=NULL; 1190 1216 } 1191 1217 return tmp; … … 1234 1260 fprintf(stderr,"CONTENT MAP\n"); 1235 1261 dumpMap(s->content); 1236 fprintf(stderr,"CONTENT METADATA\n"); 1262 if(s->metadata!=NULL) 1263 fprintf(stderr,"CONTENT METADATA\n"); 1237 1264 dumpMap(s->metadata); 1265 if(s->additional_parameters!=NULL) 1266 fprintf(stderr,"CONTENT AdditionalParameters\n"); 1267 dumpMap(s->additional_parameters); 1238 1268 } 1239 1269 if(s->inputs!=NULL){ … … 1293 1323 res->metadata=NULL; 1294 1324 addMapToMap(&res->metadata,s->metadata); 1325 res->additional_parameters=NULL; 1326 addMapToMap(&res->additional_parameters,s->additional_parameters); 1295 1327 res->inputs=dupElements(s->inputs); 1296 1328 res->outputs=dupElements(s->outputs); -
branches/prototype-v0/zoo-project/zoo-kernel/service.h
r822 r839 139 139 * The memory size to create an elements 140 140 */ 141 #define ELEMENTS_SIZE (sizeof(char*)+(((2*sizeof(char*))+sizeof(maps*))* 2)+sizeof(char*)+(((2*sizeof(char*))+sizeof(iotype*))*2)+(2*sizeof(elements*)))141 #define ELEMENTS_SIZE (sizeof(char*)+(((2*sizeof(char*))+sizeof(maps*))*3)+sizeof(char*)+(((2*sizeof(char*))+sizeof(iotype*))*2)+(2*sizeof(elements*))) 142 142 /** 143 143 * The memory size to create a map … … 159 159 */ 160 160 //#define SERVICE_SIZE (ELEMENTS_SIZE*2)+(MAP_SIZE*2)+sizeof(char*) 161 #define SERVICE_SIZE sizeof(char*) + 2*sizeof(map*) + 2*sizeof(elements*)161 #define SERVICE_SIZE sizeof(char*) + 3*sizeof(map*) + 2*sizeof(elements*) 162 162 /** 163 163 * The memory size to create a services … … 228 228 struct map* content; //!< the content map 229 229 struct map* metadata; //!< the metadata map 230 struct map* additional_parameters; //!< the additional parameters map 230 231 char* format; //!< the format: LiteralData or ComplexData or BoundingBoxData 231 232 struct iotype* defaults; //!< the default iotype … … 242 243 struct map* content; //!< the content map 243 244 struct map* metadata; //!< the metadata map 245 struct map* additional_parameters; //!< the additional parameters map 244 246 struct elements* inputs; //!< the inputs elements 245 247 struct elements* outputs; //!< the outputs elements … … 278 280 ZOO_DLL_EXPORT void freeMap(map**); 279 281 ZOO_DLL_EXPORT void freeMaps(maps** mo); 280 281 282 ZOO_DLL_EXPORT iotype* createIoType(); 282 283 ZOO_DLL_EXPORT elements* createEmptyElements(); 283 284 ZOO_DLL_EXPORT elements* createElements(const char*); -
branches/prototype-v0/zoo-project/zoo-kernel/service_conf.y
r790 r839 33 33 static bool wait_maincontent=true; 34 34 static bool wait_mainmetadata=false; 35 static bool wait_mainap=false; 35 36 static bool wait_metadata=false; 37 static bool wait_ap=false; 36 38 static bool wait_nested=false; 37 39 static bool wait_inputs=false; … … 156 158 current_content=NULL; 157 159 my_service->metadata=NULL; 160 my_service->additional_parameters=NULL; 158 161 wait_maincontent=false; 159 162 } 160 163 if(strncasecmp($2,"EndNested",9)==0){ 161 164 #ifdef DEBUG_SERVICE_CONF 162 163 164 #endif 165 166 167 168 165 fprintf(stderr,"(ENDNESTED - %d) \n",__LINE__); 166 fflush(stderr); 167 #endif 168 nested_level-=1; 169 if(nested_level==0){ 170 wait_nested=false; 171 } 169 172 } 170 173 … … 229 232 } 230 233 else 231 if(strncasecmp($2,"MetaData",8)==0){ 232 previous_data=current_data; 233 current_data=3; 234 if(current_element!=NULL){ 235 #ifdef DEBUG_SERVICE_CONF 236 fprintf(stderr,"add current_content to current_element->content\n"); 237 fprintf(stderr,"LINE %d",__LINE__); 238 #endif 239 addMapToMap(¤t_element->content,current_content); 240 freeMap(¤t_content); 241 free(current_content); 242 if(previous_data==1 || previous_data==2) 243 wait_metadata=true; 244 else 245 wait_mainmetadata=true; 246 } 247 else{ 248 if(previous_data==1 || previous_data==2) 249 wait_metadata=true; 250 else 251 wait_mainmetadata=true; 234 if(strncasecmp($2,"MetaData",8)==0 || 235 strncasecmp($2,"AdditionalParameters",8)==0){ 236 if(strncasecmp($2,"AdditionalParameters",8)==0){ 237 previous_data=current_data; 238 current_data=4; 239 if(current_element!=NULL){ 240 #ifdef DEBUG_SERVICE_CONF 241 fprintf(stderr,"add current_content to current_element->content\n"); 242 fprintf(stderr,"LINE %d",__LINE__); 243 #endif 244 if(wait_mainmetadata) 245 addMapToMap(&my_service->metadata,current_content); 246 else 247 if(wait_metadata) 248 addMapToMap(¤t_element->metadata,current_content); 249 else 250 addMapToMap(¤t_element->content,current_content); 251 freeMap(¤t_content); 252 free(current_content); 253 if(previous_data==1 || previous_data==2) 254 wait_ap=true; 255 else 256 wait_mainap=true; 257 } 258 else{ 259 if(previous_data==1 || previous_data==2) 260 wait_ap=true; 261 else 262 wait_mainap=true; 263 } 264 }else{ 265 previous_data=current_data; 266 current_data=3; 267 if(current_element!=NULL){ 268 #ifdef DEBUG_SERVICE_CONF 269 fprintf(stderr,"add current_content to current_element->content\n"); 270 fprintf(stderr,"LINE %d",__LINE__); 271 #endif 272 addMapToMap(¤t_element->content,current_content); 273 freeMap(¤t_content); 274 free(current_content); 275 if(previous_data==1 || previous_data==2) 276 wait_metadata=true; 277 else 278 wait_mainmetadata=true; 279 } 280 else{ 281 if(previous_data==1 || previous_data==2) 282 wait_metadata=true; 283 else 284 wait_mainmetadata=true; 285 } 252 286 } 253 287 current_content=NULL; … … 425 459 if(strcmp($3,"DataOutputs")==0){ 426 460 current_data=2; 461 } 462 if(strcmp($3,"AdditionalParameters")==0){ 463 if(current_content!=NULL){ 464 #ifdef DEBUG_SERVICE_CONF 465 fprintf(stderr,"add current_content to current_element->content\n"); 466 fprintf(stderr,"LINE %d",__LINE__); 467 #endif 468 if(wait_ap){ 469 current_element->additional_parameters=NULL; 470 addMapToMap(¤t_element->additional_parameters,current_content); 471 current_element->next=NULL; 472 current_element->defaults=NULL; 473 current_element->supported=NULL; 474 current_element->child=NULL; 475 }else{ 476 if(wait_mainap){ 477 addMapToMap(&my_service->additional_parameters,current_content); 478 } 479 } 480 481 freeMap(¤t_content); 482 free(current_content); 483 current_content=NULL; 484 } 485 current_data=previous_data; 486 wait_mainap=false; 487 wait_ap=false; 427 488 } 428 489 if(strcmp($3,"MetaData")==0){ … … 866 927 wait_mainmetadata=false; 867 928 wait_metadata=false; 929 wait_mainap=false; 930 wait_ap=false; 868 931 wait_inputs=false; 869 932 wait_defaults=false; -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal.c
r788 r839 148 148 149 149 //FILE* f0 = fopen (fileName, "r"); 150 151 150 // knut: open file in binary mode to avoid conversion of line endings (yielding extra bytes) on Windows platforms 151 FILE* f0 = fopen(fileName, "rb"); 152 152 if(f0!=NULL){ 153 153 fseek (f0, 0, SEEK_END); … … 162 162 free(stat); 163 163 } 164 165 164 return tmps1; 166 165 } -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_hpc.c
r822 r839 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright (c) 2015 GeoLabs SARL 4 * Copyright (c) 2017 GeoLabs SARL 5 * 6 * This work was supported by public funds received in the framework of GEOSUD, 7 * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed 8 * by the French National Research Agency 5 9 * 6 10 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 22 26 * THE SOFTWARE. 23 27 * 24 * See Ref: http://hg.orfeo-toolbox.org/OTB/ Copyright25 * Some parts of this code are derived from ITK. See ITKCopyright.txt for26 * details.27 28 */ 28 29 … … 30 31 #include "response_print.h" 31 32 #include "server_internal.h" 33 #include "service_callback.h" 34 #include "mimetypes.h" 32 35 #include <sys/un.h> 33 36 34 void appendOutputParameters(maps* input,char** parameters,int* cnt,service* s,map* uuid,map* targetPathMap){ 35 while(input!=NULL){ 36 if(input->child==NULL){ 37 *cnt+=1; 38 if(*cnt==1) 39 parameters=(char**)malloc((*cnt)*sizeof(char*)); 40 else 41 parameters=(char**)realloc(parameters,(*cnt)*sizeof(char*)); 42 // Name every files that should be produced by the service execution 43 char* targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+10)*sizeof(char)); 44 sprintf(targetName,"output_%s_%s_%s",s->name,input->name,uuid->value); 45 // TODO: We should verify if any optional tag for output is required (i.e. -out output.tiff int8) 46 char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); 47 sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); 48 parameters[*cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char)); 49 sprintf(parameters[*cnt-1],"-%s %s",input->name,targetPath); 50 }else 51 appendOutputParameters(input->child,parameters,cnt,s,uuid,targetPathMap); 52 input=input->next; 37 typedef struct { 38 maps* conf; 39 char* local_file; 40 char* target_file; 41 } local_params; 42 43 #ifdef PTHREADS 44 #endif 45 46 void addNestedOutputs(service** s){ 47 if((*s)==NULL){ 48 return; 49 } 50 if(*s==NULL || (*s)->outputs==NULL){ 51 return; 52 } 53 elements *out=(*s)->outputs; 54 elements* cur=out; 55 map* serviceType=getMap((*s)->content,"ServiceType"); 56 if(strncmp(serviceType->value,"HPC",3)!=0) 57 return; 58 while(cur!=NULL && cur->defaults!=NULL){ 59 map* mimeType=getMap(cur->defaults->content,"mimeType"); 60 if(mimeType!=NULL){ 61 int geo=isGeographic(mimeType->value); 62 if(geo>0){ 63 elements *tmp[3]={ 64 dupElements(cur), 65 dupElements(cur), 66 dupElements(cur) 67 }; 68 char *geoLink="wcs_link"; 69 if(geo==2){ 70 geoLink="wfs_link"; 71 } 72 int i=0; 73 for(;i<3;i++){ 74 if(tmp[i]->next!=NULL){ 75 freeElements(&tmp[i]->next); 76 free(tmp[i]->next); 77 tmp[i]->next=NULL; 78 } 79 free(tmp[i]->name); 80 tmp[i]->format=zStrdup("ComplexData"); 81 freeMap(&tmp[i]->content); 82 free(tmp[i]->content); 83 tmp[i]->content=NULL; 84 switch(i){ 85 case 0: 86 tmp[i]->name=zStrdup("download_link"); 87 tmp[i]->content=createMap("Title",_("Download link")); 88 addToMap(tmp[i]->content,"Abstract",_("The download link")); 89 addToMap(tmp[i]->defaults->content,"useMapserver","false"); 90 if(tmp[i]->supported!=NULL){ 91 freeIOType(&tmp[i]->supported); 92 free(tmp[i]->supported); 93 tmp[i]->supported=NULL; 94 } 95 break; 96 case 1: 97 tmp[i]->name=zStrdup("wms_link"); 98 tmp[i]->content=createMap("Title",_("WMS link")); 99 addToMap(tmp[i]->content,"Abstract",_("The WMS link")); 100 if(tmp[i]->supported!=NULL && tmp[i]->supported->next!=NULL){ 101 freeIOType(&tmp[i]->supported->next); 102 free(tmp[i]->supported->next); 103 tmp[i]->supported->next=NULL; 104 }else{ 105 if(tmp[i]->supported!=NULL) 106 addToMap(tmp[i]->supported->content,"useMapserver","true"); 107 addToMap(tmp[i]->defaults->content,"useMapserver","true"); 108 } 109 break; 110 case 2: 111 if(geo==2){ 112 tmp[i]->name=zStrdup("wfs_link"); 113 tmp[i]->content=createMap("Title",_("WFS link")); 114 addToMap(tmp[i]->content,"Abstract",_("The WFS link")); 115 }else{ 116 tmp[i]->name=zStrdup("wcs_link"); 117 tmp[i]->content=createMap("Title",_("WCS link")); 118 addToMap(tmp[i]->content,"Abstract",_("The WCS link")); 119 } 120 if(tmp[i]->supported!=NULL && tmp[i]->supported->next!=NULL && 121 tmp[i]->supported->next->content!=NULL){ 122 freeIOType(&tmp[i]->supported); 123 free(tmp[i]->supported); 124 tmp[i]->supported=NULL; 125 tmp[i]->supported=createIoType(); 126 iotype* cnext=cur->supported->next; 127 tmp[i]->supported->content=createMap(cnext->content->name,cnext->content->value); 128 addMapToMap(&tmp[i]->supported->content,cnext->content->next); 129 addToMap(tmp[i]->supported->content,"useMapserver","true"); 130 }else 131 addToMap(tmp[i]->defaults->content,"useMapserver","true"); 132 break; 133 } 134 } 135 136 addToElements(&cur->child,tmp[0]); 137 addToElements(&cur->child,tmp[1]); 138 addToElements(&cur->child,tmp[2]); 139 free(cur->format); 140 cur->format=NULL; 141 if(cur->defaults!=NULL){ 142 freeIOType(&cur->defaults); 143 cur->defaults=NULL; 144 } 145 if(cur->supported!=NULL){ 146 freeIOType(&cur->supported); 147 cur->supported=NULL; 148 } 149 freeElements(&tmp[2]); 150 free(tmp[2]); 151 freeElements(&tmp[1]); 152 free(tmp[1]); 153 freeElements(&tmp[0]); 154 free(tmp[0]); 155 //addToMap(cur->content,"internal","true"); 156 } 157 } 158 cur=cur->next; 53 159 } 54 160 } … … 71 177 map* tmp=NULL; 72 178 int res=-1; 73 map* targetPathMap=getMapFromMaps(*main_conf,"HPC","storagePath"); 179 char *serviceType; 180 map* mServiceType=getMap(s->content,"serviceType"); 181 if(mServiceType!=NULL) 182 serviceType=mServiceType->value; 183 else 184 serviceType="HPC"; 185 map* targetPathMap=getMapFromMaps(*main_conf,serviceType,"storagePath"); 74 186 map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath"); 75 187 map* uuid=getMapFromMaps(*main_conf,"lenv","usid"); 76 77 sleep(5); 188 pthread_t threads_pool[50]; 189 // Force the HPC services to be called asynchronously 190 map* isAsync=getMapFromMaps(*main_conf,"lenv","async"); 191 if(isAsync==NULL){ 192 errorException(*main_conf,_("The synchronous mode is not supported by this type of service"),"NoSuchMode",s->name); 193 return -1; 194 } 78 195 79 196 maps* input=*real_inputs; 80 197 char **parameters=NULL; 81 198 int parameters_cnt=0; 82 while(input!=NULL){ 83 parameters_cnt+=1; 84 if(parameters_cnt==1) 85 parameters=(char**)malloc(parameters_cnt*sizeof(char*)); 86 else 87 parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*)); 88 if(getMap(input->content,"mimeType")!=NULL){ 89 // Input is ComplexData 90 SSHCON *test=ssh_connect(*main_conf); 91 dumpMaps(getMaps(*main_conf,"lenv")); 92 if(test==NULL){ 93 sleep(3600); 94 return -1; 95 } 96 if(getMap(input->content,"cache_file")==NULL){ 97 // Input data has been passed by value 98 // TODO: store data remotely 99 // TODO: publish input through MapServer / use output publication 100 dumpMapsValuesToFiles(main_conf,&input); 101 } 102 if(getMap(input->content,"cache_file")!=NULL){ 103 // Input data passed by reference or by value 104 map* tmp=getMap(input->content,"cache_file"); 105 char* targetName=strrchr(tmp->value,'/'); 106 char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); 107 sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); 108 ssh_copy(*main_conf,tmp->value,targetPath); 109 parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char)); 110 sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath); 111 free(targetPath); 199 while(input!=NULL && input->content!=NULL){ 200 if(getMaps(*real_outputs,input->name)==NULL){ 201 parameters_cnt+=1; 202 if(parameters_cnt==1) 203 parameters=(char**)malloc(parameters_cnt*sizeof(char*)); 204 else 205 parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*)); 206 if(getMap(input->content,"mimeType")!=NULL){ 207 // Input is ComplexData 208 if(getMap(input->content,"cache_file")==NULL){ 209 // Input data has been passed by value 210 // TODO: publish input through MapServer / use output publication 211 dumpMapsValuesToFiles(main_conf,&input); 212 addToMap(input->content,"toPublish","true"); 213 } 214 if(getMap(input->content,"cache_file")!=NULL){ 215 map* length=getMap(input->content,"length"); 216 if(length==NULL){ 217 addToMap(input->content,"length","1"); 218 length=getMap(input->content,"length"); 219 } 220 int len=atoi(length->value); 221 int i=0; 222 for(i=0;i<len;i++){ 223 map* tmp=getMapArray(input->content,"cache_file",i); 224 char* targetName=strrchr(tmp->value,'/'); 225 char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); 226 sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); 227 setMapArray(input->content,"targetPath",i,targetPath); 228 setMapArray(input->content,"localPath",i,tmp->value); 229 addToUploadQueue(main_conf,input); 230 if(i==0){ 231 parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char)); 232 sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath); 233 }else{ 234 char *tmpStr=zStrdup(parameters[parameters_cnt-1]); 235 parameters[parameters_cnt-1]=(char*)realloc(parameters[parameters_cnt-1],(strlen(tmpStr)+strlen(targetPath)+2)*sizeof(char)); 236 sprintf(parameters[parameters_cnt-1],"%s %s",tmpStr,targetPath); 237 free(tmpStr); 238 } 239 free(targetPath); 240 } 241 }else{ 242 // ??? 243 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 244 fflush(stderr); 245 } 112 246 }else{ 113 // ??? 114 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 115 fflush(stderr); 116 } 117 }else{ 118 // LitteralData and BboxData 119 if(getMap(input->content,"dataType")!=NULL){ 120 // For LitteralData, simply pass the value 121 map* val=getMap(input->content,"value"); 122 sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,val->value); 123 } 124 247 // LitteralData and BboxData 248 if(getMap(input->content,"dataType")!=NULL){ 249 // For LitteralData, simply pass the value 250 map* val=getMap(input->content,"value"); 251 parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(val->value)+3)*sizeof(char)); 252 sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,val->value); 253 } 254 } 125 255 } 126 256 input=input->next; 127 257 } 258 259 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 260 invokeCallback(m,inputs,NULL,2,0); 261 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 262 263 // Upload data on HPC 264 runUpload(main_conf); 265 266 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 267 invokeCallback(m,inputs,NULL,2,1); 268 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 128 269 129 270 // Add the filename to generate for every output to the parameters … … 140 281 parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*)); 141 282 // Name every files that should be produced by the service execution 142 char* targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+10)*sizeof(char)); 143 sprintf(targetName,"output_%s_%s_%s",s->name,input->name,uuid->value); 144 // TODO: We should verify if any optional tag for output is required (i.e. -out output.tiff *int8*) 145 // TODO: Add support for Array values 283 map* mime=getMap(input->content,"mimeType"); 284 char* targetName; 285 if(mime!=NULL){ 286 bool hasExt=false; 287 map* fileExt=getFileExtensionMap(mime->value,&hasExt); 288 targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+strlen(fileExt->value)+11)*sizeof(char)); 289 sprintf(targetName,"output_%s_%s_%s.%s",s->name,input->name,uuid->value,fileExt->value); 290 freeMap(&fileExt); 291 free(fileExt); 292 }else{ 293 targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+14)*sizeof(char)); 294 sprintf(targetName,"output_%s_%s_%s.tif",s->name,input->name,uuid->value); 295 } 146 296 char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); 147 297 sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); 148 298 setMapInMaps(*real_outputs,input->name,"generated_file",targetPath); 149 parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char)); 150 sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath); 299 // We should verify if any optional tag for output is required 300 // (i.e. -out output.tiff *int8*), meaning that we should search 301 // for a corresponding inputs name. 302 map* inValue=getMapFromMaps(*real_inputs,input->name,"value"); 303 if(inValue!=NULL){ 304 parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+strlen(inValue->value)+4)*sizeof(char)); 305 sprintf(parameters[parameters_cnt-1],"-%s %s %s",input->name,targetPath,inValue->value); 306 }else{ 307 parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char)); 308 sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath); 309 } 310 free(targetPath); 311 }// In other case it means we need to return the cache_file as generated_file 312 else{ 313 parameters_cnt+=1; 314 if(parameters_cnt==1) 315 parameters=(char**)malloc(parameters_cnt*sizeof(char*)); 316 else 317 parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*)); 318 // Name every files that should be produced by the service execution 319 map* mime=getMap(input->child->content,"mimeType"); 320 char* targetName; 321 if(mime!=NULL){ 322 bool hasExt=false; 323 map* fileExt=getFileExtensionMap(mime->value,&hasExt); 324 targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+strlen(fileExt->value)+11)*sizeof(char)); 325 sprintf(targetName,"output_%s_%s_%s.%s",s->name,input->name,uuid->value,fileExt->value); 326 freeMap(&fileExt); 327 free(fileExt); 328 }else{ 329 targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+14)*sizeof(char)); 330 sprintf(targetName,"output_%s_%s_%s.tif",s->name,input->name,uuid->value); 331 } 332 char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); 333 sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); 334 addToMap(input->content,"generated_file",targetPath); 335 // We should verify if any optional tag for output is required 336 // (i.e. -out output.tiff *int8*), meaning that we should search 337 // for a corresponding inputs name. 338 map* inValue=getMapFromMaps(*real_inputs,input->name,"value"); 339 if(inValue!=NULL){ 340 parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+strlen(inValue->value)+4)*sizeof(char)); 341 sprintf(parameters[parameters_cnt-1],"-%s %s %s",input->name,targetPath,inValue->value); 342 }else{ 343 parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char)); 344 sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath); 345 } 346 free(targetPath); 151 347 } 152 348 input=input->next; 153 349 } 154 350 351 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 352 fflush(stderr); 353 invokeCallback(m,inputs,NULL,3,0); 354 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 355 fflush(stderr); 356 155 357 // Produce the SBATCH File locally 156 char *scriptPath=(char*)malloc((strlen(s->name)+strlen(tmpPath->value)+strlen(uuid->value)+ 9)*sizeof(char));358 char *scriptPath=(char*)malloc((strlen(s->name)+strlen(tmpPath->value)+strlen(uuid->value)+10)*sizeof(char)); 157 359 sprintf(scriptPath,"%s/zoo_%s_%s.sh",tmpPath->value,s->name,uuid->value); 360 setMapInMaps(*main_conf,"lenv","local_script",scriptPath); 361 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 362 fflush(stderr); 363 invokeCallback(m,inputs,NULL,3,0); 364 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 365 fflush(stderr); 158 366 FILE* scriptFile=fopen(scriptPath,"w+"); 159 maps* hpc_opts=getMaps(*main_conf,"sbatch_options"); 160 map* hpc_opts_content=hpc_opts->content; 161 map* headerMap=getMapFromMaps(*main_conf,"HPC","header"); 367 map* headerMap=getMapFromMaps(*main_conf,serviceType,"header"); 162 368 if(headerMap!=NULL){ 163 369 // Use the header file if defined in the HPC section of the main.cfg file … … 171 377 fcontent[fsize]=0; 172 378 fclose(f); 173 fprintf(scriptFile,"%s\n### --- ZOO-Service HEADER end --- ### ",fcontent);379 fprintf(scriptFile,"%s\n### --- ZOO-Service HEADER end --- ###\n\n",fcontent); 174 380 free(fcontent); 175 381 }else … … 177 383 }else 178 384 fprintf(scriptFile,"#!/bin/bash\n\n### *** Default ZOO-Service HEADER *** ###\n\n"); 179 180 while(hpc_opts_content!=NULL){ 181 fprintf(scriptFile,"#SBATCH --%s=%s\n",hpc_opts_content->name,hpc_opts_content->value); 182 hpc_opts_content=hpc_opts_content->next; 385 maps* hpc_opts=getMaps(*main_conf,"sbatch_options"); 386 if(hpc_opts!=NULL){ 387 map* hpc_opts_content=hpc_opts->content; 388 while(hpc_opts_content!=NULL){ 389 fprintf(scriptFile,"#SBATCH --%s=%s\n",hpc_opts_content->name,hpc_opts_content->value); 390 hpc_opts_content=hpc_opts_content->next; 391 } 183 392 } 184 393 fprintf(scriptFile,"#SBATCH --job-name=ZOO-Project_%s_%s\n\n",uuid->value,s->name); … … 186 395 if(mods!=NULL) 187 396 fprintf(scriptFile,"#SBATCH --export=MODULES=%s\n",mods->value); 188 else 189 fprintf(scriptFile,"#SBATCH --export=MODULES=\n"); 397 398 map* bodyMap=getMapFromMaps(*main_conf,serviceType,"body"); 399 if(bodyMap!=NULL){ 400 // Use the header file if defined in the HPC section of the main.cfg file 401 struct stat f_status; 402 int s=stat(bodyMap->value, &f_status); 403 if(s==0){ 404 char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 405 FILE* f=fopen(bodyMap->value,"rb"); 406 fread(fcontent,f_status.st_size,1,f); 407 int fsize=f_status.st_size; 408 fcontent[fsize]=0; 409 fclose(f); 410 fprintf(scriptFile,"%s\n### --- ZOO-Service BODY end --- ###\n\n",fcontent); 411 free(fcontent); 412 }else 413 fprintf(scriptFile,"#!/bin/bash\n\n### *** Default ZOO-Service BODY (no body found) *** ###\n\n"); 414 }else 415 fprintf(scriptFile,"#!/bin/bash\n\n### *** Default ZOO-Service BODY *** ###\n\n"); 416 417 190 418 map* sp=getMap(s->content,"serviceProvider"); 419 191 420 // Require to produce the command line to be executed 192 421 fprintf(scriptFile,"\n\necho \"Job started at: $(date)\"\n"); … … 195 424 for(int i=0;i<parameters_cnt;i++){ 196 425 fprintf(scriptFile," %s",parameters[i]); 197 //free(parameters[i]); 426 } 427 for(int i=parameters_cnt-1;i>=0;i--){ 428 free(parameters[i]); 198 429 } 199 430 free(parameters); 200 431 fprintf(scriptFile,"\n"); 201 432 fprintf(scriptFile,"echo \"Job finished at: $(date)\"\n"); 202 203 433 fflush(scriptFile); 204 434 fclose(scriptFile); 435 436 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 437 invokeCallback(m,inputs,NULL,3,1); 438 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 205 439 206 440 // Upload the SBATCH File to the remote host 207 targetPathMap=getMapFromMaps(*main_conf,"HPC","executePath"); 441 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 442 invokeCallback(m,inputs,NULL,4,0); 443 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 444 targetPathMap=getMapFromMaps(*main_conf,serviceType,"executePath"); 208 445 if(targetPathMap==NULL){ 209 446 setMapInMaps(*main_conf,"lenv","message",_("There is no executePath defined in you HPC section!")); … … 213 450 char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); 214 451 sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); 452 setMapInMaps(*main_conf,"lenv","remote_script",targetPath); 215 453 SSHCON *test=ssh_connect(*main_conf); 216 ssh_copy(*main_conf,scriptPath,targetPath );454 ssh_copy(*main_conf,scriptPath,targetPath,ssh_get_cnt(*main_conf)); 217 455 218 456 // Execute the SBATCH script remotely 219 457 map* subStr=getMapFromMaps(*main_conf,"HPC","subStr"); 220 //char *command=(char*)malloc((strlen(targetPath)+strlen(targetPathMap->value)+strlen(subStr->value)+strlen(uuid->value)+37)*sizeof(char));221 458 char *command=(char*)malloc((strlen(targetPath)+strlen(targetPathMap->value)+strlen(subStr->value)+strlen(uuid->value)+137)*sizeof(char)); 222 //sprintf(command,"ls # %s 2> %s/error_%s.log | sed \"s:%s::g\"",targetPath,targetPathMap->value,uuid->value,subStr->value);223 459 sprintf(command,"sbatch %s 2> %s/error_%s.log | sed \"s:%s::g\"",targetPath,targetPathMap->value,uuid->value,subStr->value); 224 if(ssh_exec(*main_conf,command )==0){460 if(ssh_exec(*main_conf,command,ssh_get_cnt(m))==0){ 225 461 // The sbatch command has failed! 226 462 // Download the error log file from the HPC server 227 463 char tmpS[1024]; 228 464 free(command); 229 command=(char*)malloc((strlen(targetPathMap->value)+strlen(uuid->value)+ 22)*sizeof(char));465 command=(char*)malloc((strlen(targetPathMap->value)+strlen(uuid->value)+11)*sizeof(char)); 230 466 sprintf(command,"%s/error_%s.log",targetPathMap->value,uuid->value); 231 467 targetName=strrchr(command,'/'); … … 233 469 targetPath=(char*)malloc((strlen(tmpPath->value)+strlen(targetName)+2)*sizeof(char)); 234 470 sprintf(targetPath,"%s/%s",tmpPath->value,targetName); 235 if(ssh_fetch(*main_conf,targetPath,command )==0){471 if(ssh_fetch(*main_conf,targetPath,command,ssh_get_cnt(m))==0){ 236 472 struct stat f_status; 237 473 int ts=stat(targetPath, &f_status); … … 251 487 setMapInMaps(*main_conf,"lenv","message",_("Unable to fetch the remote error log file")); 252 488 tmpPath=getMapFromMaps(*main_conf,"lenv","message"); 489 invokeCallback(m,NULL,NULL,7,1); 253 490 sprintf(tmpS, "Cannot execute the HPC ZOO-Service %s: %s", s->name, tmpPath->value); 254 491 errorException(m,tmpS,"NoApplicableCode",NULL); … … 259 496 return -1; 260 497 } 498 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 499 fflush(stderr); 500 invokeCallback(m,NULL,NULL,4,1); 501 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 502 fflush(stderr); 503 free(command); 261 504 262 505 struct sockaddr_un addr; … … 264 507 addr.sun_family = AF_UNIX; 265 508 int rc, cl, fd = socket(AF_UNIX, SOCK_STREAM, 0); 266 char buf[100]; 267 char *sname=(char*)malloc((strlen(tmpPath->value)+strlen(uuid->value)+19)); 509 char *sname=(char*)malloc((strlen(tmpPath->value)+strlen(uuid->value)+20)); 268 510 sprintf(sname,"%s/.wait_socket_%s.sock",tmpPath->value,uuid->value); 269 511 strncpy(addr.sun_path, sname, sizeof(addr.sun_path)-1); 512 270 513 if (bind(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) { 271 514 perror("bind error"); … … 274 517 } 275 518 if (listen(fd, 5) == -1) { 276 perror("listen error"); 277 sleep(120); 519 setMapInMaps(*main_conf,"lenv","message",_("Listen error")); 278 520 return -1; 279 521 } 280 /*fd_set master, read_fds; 281 int fdmax; 282 FD_ZERO(&master); 283 FD_ZERO(&read_fds); 284 FD_SET(fd, &master); 285 if (select(fd+1, &master, NULL, NULL, NULL) == -1) { 286 perror("select"); 287 sleep(120); 522 if ( (cl = accept(fd, NULL, NULL)) == -1) { 523 setMapInMaps(*main_conf,"lenv","message",_("Accept error")); 288 524 return -1; 289 } 290 if (FD_ISSET(fd, &master)) {*/ 291 if ( (cl = accept(fd, NULL, NULL)) == -1) { 292 perror("accept error"); 525 }else{ 526 int hasPassed=-1; 527 char buf[11]; 528 memset(&buf,0,11); 529 while ( (rc=read(cl,buf,10)) ) { 530 if(rc==0){ 531 sleep(1); 532 setMapInMaps(*main_conf,"lenv","message",_("Read closed")); 533 return -1; 534 }else{ 535 if(rc<0){ 536 setMapInMaps(*main_conf,"lenv","message",_("Read error")); 537 return -1; 538 } 539 } 540 hasPassed=1; 541 res=atoi(buf); 542 unlink(sname); 543 //free(sname); 544 545 if(res==3){ 546 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 547 fflush(stderr); 548 invokeCallback(m,NULL,outputs,5,0); 549 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 550 fflush(stderr); 551 input=*real_outputs; 552 while(input!=NULL){ 553 if(input->child==NULL){ 554 map* generatedFile=getMap(input->content,"generated_file"); 555 if(generatedFile!=NULL){ 556 char* filename=strrchr(generatedFile->value,'/'); 557 char* targetPath=(char*)malloc((strlen(tmpPath->value)+strlen(filename)+2)*sizeof(char)); 558 sprintf(targetPath,"%s/%s",tmpPath->value,filename); 559 test=ssh_connect(*main_conf); 560 if(ssh_fetch(*main_conf,targetPath,generatedFile->value,ssh_get_cnt(m))==0){ 561 setMapInMaps(*real_outputs,input->name,"generated_file",targetPath); 562 free(targetPath); 563 }else{ 564 char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); 565 sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename); 566 setMapInMaps(*main_conf,"lenv","message",tmpStr); 567 free(tmpStr); 568 return SERVICE_FAILED; 569 } 570 } 571 }else{ 572 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 573 fflush(stderr); 574 map* generatedFile=getMap(input->content,"generated_file"); 575 if(generatedFile!=NULL){ 576 char* filename=strrchr(generatedFile->value,'/'); 577 char* targetPath=(char*)malloc((strlen(tmpPath->value)+strlen(filename)+2)*sizeof(char)); 578 sprintf(targetPath,"%s/%s",tmpPath->value,filename); 579 test=ssh_connect(*main_conf); 580 if(ssh_fetch(*main_conf,targetPath,generatedFile->value,ssh_get_cnt(m))==0){ 581 maps* tmp=getMaps(*real_outputs,input->name); 582 freeMap(&tmp->content); 583 free(tmp->content); 584 tmp->content=NULL; 585 maps* output=getMaps(*real_outputs,input->name); 586 setMapInMaps(output->child,"download_link","generated_file",targetPath); 587 setMapInMaps(output->child,"download_link","useMapserver","false"); 588 setMapInMaps(output->child,"WMS_LINK","generated_file",targetPath); 589 setMapInMaps(output->child,"WMS_LINK","useMapserver","true"); 590 setMapInMaps(output->child,"WCS_LINK","generated_file",targetPath); 591 setMapInMaps(output->child,"WCS_LINK","useMapserver","true"); 592 } 593 } 594 } 595 input=input->next; 596 } 597 } 598 //free(buf); 599 } 600 if(hasPassed<0){ 601 perror("Failed to read"); 602 setMapInMaps(*main_conf,"lenv","message",_("Unable to parse the value returned by remote execution")); 293 603 sleep(120); 294 return -1; 295 }else{ 296 int hasPassed=-1; 297 /*FD_SET(cl,&read_fds); 298 if (select(cl+1, &read_fds, NULL, NULL, NULL) == -1) { 299 perror("select"); 300 sleep(120); 301 return -1; 302 }*/ 303 while ( (rc=read(cl,buf,10)) ) { 304 if(rc==0){ 305 sleep(120); 306 return -1; 307 }else{ 308 if(rc<0){ 309 perror("read"); 310 sleep(120); 311 return -1; 312 } 313 } 314 hasPassed=1; 315 res=atoi(buf); 316 unlink(sname); 317 if(res==3){ 318 input=*real_outputs; 319 while(input!=NULL){ 320 // TODO: parse all outputs including inner outputs if required. 321 if(input->child==NULL){ 322 //map* dataPath=getMapFromMaps(*main_conf,"main","dataPath"); 323 map* generatedFile=getMap(input->content,"generated_file"); 324 if(generatedFile!=NULL){ 325 char* filename=strrchr(generatedFile->value,'/'); 326 char* targetPath=(char*)malloc((strlen(tmpPath->value)+strlen(filename)+2)*sizeof(char)); 327 sprintf(targetPath,"%s/%s",tmpPath->value,filename); 328 test=ssh_connect(*main_conf); 329 if(ssh_fetch(*main_conf,targetPath,generatedFile->value)==0){ 330 setMapInMaps(*real_outputs,input->name,"generated_file",targetPath); 331 }else{ 332 char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); 333 sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename); 334 setMapInMaps(*main_conf,"lenv","message",tmpStr); 335 free(tmpStr); 336 return SERVICE_FAILED; 337 } 338 } 339 }/*else{ 340 // Generate the nested outputs based on each input value 341 if(getMaps(*real_inputs,input->name)!=NULL && getMapFromMaps(*real_inputs,input->name,"mimeType")!=NULL){ 342 // Input was ComplexeData 343 maps* output=getMaps(*real_outputs,input->name); 344 map* cache=getMapFromMaps(*real_inputs,input->name,"cache_file"); 345 setMapInMaps(output->child,"download","generated_file",cache->value); 346 setMapInMaps(output->child,"WCS_LINK","generated_file",cache->value); 347 setMapInMaps(output->child,"WCS_LINK","useMs","true"); 348 setMapInMaps(output->child,"WMS_LINK","generated_file",cache->value); 349 setMapInMaps(output->child,"WMS_LINK","useMs","true"); 350 } 351 }*/ 352 input=input->next; 353 } 354 } 355 } 356 if(hasPassed<0){ 357 perror("Failed to read"); 358 setMapInMaps(*main_conf,"lenv","message",_("Unable to parse the value returned by remote execution")); 359 sleep(120); 360 return SERVICE_FAILED; 361 } 604 return SERVICE_FAILED; 362 605 } 363 //}606 } 364 607 ssh_close(*main_conf); 365 //sleep(120);366 608 return res; 367 609 } -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_hpc.h
r822 r839 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright (c) 2015 GeoLabs SARL 4 * Copyright (c) 2017 GeoLabs SARL 5 * 6 * This work was supported by public funds received in the framework of GEOSUD, 7 * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed 8 * by the French National Research Agency 5 9 * 6 10 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 37 41 #include "sshapi.h" 38 42 43 void addNestedOutputs(service**); 39 44 int zoo_hpc_support(maps**,map*,service*,maps**,maps**); 40 45 -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_js.c
r790 r839 934 934 }else{ 935 935 if(argc==3){ 936 char *body=JSValToChar(cx,&argv[2]); 937 InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],body,strlen(body), 938 INTERNET_FLAG_NO_CACHE_WRITE,0); 939 processDownloads(&hInternet); 940 free(body); 936 if(strncasecmp(method,"GET",3)==0){ 937 header=JSVAL_TO_OBJECT(argv[2]); 938 if(JS_IsArrayObject(cx,header)){ 939 setHeader(&hInternet,cx,header); 940 } 941 InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],NULL,0, 942 INTERNET_FLAG_NO_CACHE_WRITE,0); 943 processDownloads(&hInternet); 944 }else{ 945 char *body=JSValToChar(cx,&argv[2]); 946 InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],body,strlen(body), 947 INTERNET_FLAG_NO_CACHE_WRITE,0); 948 processDownloads(&hInternet); 949 free(body); 950 } 941 951 }else{ 942 952 InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],NULL,0, -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c
r822 r839 131 131 */ 132 132 void setReferenceUrl(maps* m,maps* tmpI){ 133 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);134 fflush(stderr);135 dumpMaps(tmpI);136 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);137 fflush(stderr);138 133 outputMapfile(m,tmpI); 139 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);140 fflush(stderr);141 dumpMaps(tmpI);142 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);143 fflush(stderr);144 134 map *msUrl=getMapFromMaps(m,"main","mapserverAddress"); 145 135 if(msUrl==NULL){ … … 169 159 if(strncasecmp(rformat->value,"text/xml",8)==0) 170 160 proto=1; 171 if(strncasecmp(rformat->value,"image/tiff",10)==0) 161 if(strncasecmp(rformat->value,"image/tiff",10)==0 || 162 strncasecmp(rformat->value,"image/geotiff",10)==0) 172 163 proto=2; 173 164 if(protoMap!=NULL){ … … 478 469 fprintf(stderr,"Unable to access the DataSource as ZIP File\n"); 479 470 setMapInMaps(conf,"lenv","message","Unable to open datasource in read only mode"); 480 OGR_DS_Destroy(poDS1);471 //OGR_DS_Destroy(poDS1); 481 472 }else{ 482 473 #ifdef DEBUGMS … … 549 540 #endif 550 541 setMapInMaps(conf,"lenv","message","Unable to open datasource in read only mode"); 551 OGR_DS_Destroy(poDS);552 OGRCleanupAll();542 //OGR_DS_Destroy(poDS); 543 //OGRCleanupAll(); 553 544 #ifdef DEBUGMS 554 545 fprintf(stderr,"Unable to access the DataSource, exit! \n"); … … 652 643 if (OGR_L_GetExtent(poLayer,&oExt, TRUE) == OGRERR_NONE){ 653 644 setMsExtent(output,m,myLayer,oExt.MinX, oExt.MinY, oExt.MaxX, oExt.MaxY); 645 char extent[1024]; 646 memset(&extent,0,1024); 647 sprintf(extent,"%d,%d,%d,%d",oExt.MinX, oExt.MinY, oExt.MaxX, oExt.MaxY); 648 addToMap(output->content,"boundingbox",extent); 654 649 } 655 650 … … 724 719 } 725 720 726 OGR_DS_Destroy(poDS);727 OGRCleanupAll();721 //OGR_DS_Destroy(poDS); 722 //OGRCleanupAll(); 728 723 729 724 return 1; … … 819 814 } 820 815 821 822 816 /** 823 817 * Set extent … … 836 830 + adfGeoTransform[4] * GDALGetRasterXSize(hDataset); 837 831 838 setMsExtent(output,m,myLayer,minX,minY,maxX,maxY); 839 832 setMsExtent(output,m,myLayer,minX,minY,maxX,maxY); 833 char extent[1024]; 834 memset(&extent,0,1024); 835 sprintf(extent,"%d,%d,%d,%d",minX,minY,maxX,maxY); 836 addToMap(output->content,"boundingbox",extent); 840 837 } 841 838 } … … 846 843 */ 847 844 char nBands[3]; 845 memset(&nBands,0,3); 848 846 int nBandsI=GDALGetRasterCount( hDataset ); 849 sprintf(nBands,"%d",GDALGetRasterCount( hDataset )); 850 msInsertHashTable(&(myLayer->metadata), "ows_bandcount", nBands); 847 if(nBandsI<100){ 848 sprintf(nBands,"%d",GDALGetRasterCount( hDataset )); 849 msInsertHashTable(&(myLayer->metadata), "ows_bandcount", nBands); 850 } 851 851 if(nBandsI>=3) 852 852 msLayerAddProcessing(myLayer,"BANDS=1,2,3"); … … 860 860 */ 861 861 char lBands[7]; 862 memset(&nBands,0,7); 862 863 char *nameBands=NULL; 863 864 for( iBand = 0; iBand < nBandsI; iBand++ ){ 864 sprintf(lBands,"Band%d",iBand+1); 865 sprintf(lBands,"Band%d",iBand+1); 865 866 if(nameBands==NULL){ 866 867 nameBands=(char*)malloc((strlen(lBands)+1)*sizeof(char)); … … 869 870 if(iBand<4){ 870 871 char *tmpS=zStrdup(nameBands); 871 nameBands=(char*)realloc(nameBands,(strlen( nameBands)+strlen(lBands)+1)*sizeof(char));872 nameBands=(char*)realloc(nameBands,(strlen(tmpS)+strlen(lBands)+2)*sizeof(char)); 872 873 sprintf(nameBands,"%s %s",tmpS,lBands); 873 874 free(tmpS); … … 875 876 } 876 877 } 877 msInsertHashTable(&(myLayer->metadata), "ows_bandnames", nameBands); 878 878 if(nameBands!=NULL){ 879 msInsertHashTable(&(myLayer->metadata), "ows_bandnames", nameBands); 880 free(nameBands); 881 } 882 879 883 /** 880 884 * Loops over metadata information to setup specific information … … 894 898 char tmpMm[100]; 895 899 sprintf(tmpMm,"%.3f %.3f",adfCMinMax[0],adfCMinMax[1]); 896 char tmpI[ 21];900 char tmpI[31]; 897 901 sprintf(tmpI,"%s_interval",tmpN); 898 902 msInsertHashTable(&(myLayer->metadata), tmpI, tmpMm); … … 977 981 } 978 982 if( strlen(GDALGetRasterUnitType(hBand)) > 0 ){ 979 char tmpU[ 21];983 char tmpU[31]; 980 984 sprintf(tmpU,"%s_band_uom",tmpN); 981 985 msInsertHashTable(&(myLayer->metadata), tmpU, GDALGetRasterUnitType(hBand)); … … 988 992 GDALClose( hDataset ); 989 993 GDALDestroyDriverManager(); 994 990 995 CPLCleanupTLS(); 991 996 return 1; … … 999 1004 */ 1000 1005 void outputMapfile(maps* conf,maps* outputs){ 1001 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1002 fflush(stderr);1003 dumpMaps(outputs);1004 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1005 fflush(stderr);1006 1006 /** 1007 1007 * First store the value on disk … … 1013 1013 ext="json"; 1014 1014 1015 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1016 fflush(stderr);1017 1015 map* tmpMap=getMapFromMaps(conf,"main","dataPath"); 1018 1016 map* sidMap=getMapFromMaps(conf,"lenv","usid"); 1019 1017 char *pszDataSource=(char*)malloc((strlen(tmpMap->value)+strlen(sidMap->value)+strlen(outputs->name)+17)*sizeof(char)); 1020 sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext); 1018 sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext); 1021 1019 int f=zOpen(pszDataSource,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); 1022 1020 map *gfile=getMap(outputs->content,"generated_file"); … … 1026 1024 map* sizeMap=getMap(outputs->content,"size"); 1027 1025 map* vData=getMap(outputs->content,"value"); 1028 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1029 fflush(stderr);1030 1026 if(sizeMap!=NULL){ 1031 1027 zWrite(f,vData->value,atoi(sizeMap->value)*sizeof(char)); … … 1034 1030 zWrite(f,vData->value,(strlen(vData->value)+1)*sizeof(char)); 1035 1031 } 1036 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1037 fflush(stderr);1038 1032 close(f); 1039 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1040 fflush(stderr);1041 1033 addToMap(outputs->content,"storage",pszDataSource); 1042 1034 free(pszDataSource); 1043 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1044 fflush(stderr);1045 1035 1046 1036 /* … … 1049 1039 mapObj *myMap=msNewMapObj(); 1050 1040 free(myMap->name); 1051 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1052 fflush(stderr);1053 1041 myMap->name=zStrdup("ZOO-Project_WXS_Server"); 1054 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1055 fflush(stderr);1056 1042 msMapSetSize(myMap,2048,2048); 1057 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1058 fflush(stderr);1059 1043 msMapSetExtent(myMap,-1,-1,1,1); 1060 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1061 fflush(stderr);1062 1044 1063 1045 /* … … 1068 1050 tmp1=getMapFromMaps(conf,"main","tmpUrl"); 1069 1051 myMap->web.imageurl=zStrdup(tmp1->value); 1070 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1071 fflush(stderr);1072 1052 1073 1053 /* … … 1080 1060 msAppendOutputFormat(myMap,msCloneOutputFormat(o1)); 1081 1061 msFreeOutputFormat(o1); 1082 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1083 fflush(stderr);1084 1062 1085 1063 #ifdef USE_KML … … 1094 1072 } 1095 1073 #endif 1096 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1097 fflush(stderr);1098 1074 1099 1075 outputFormatObj *o3=msCreateDefaultOutputFormat(NULL,"GDAL/GTiff","tiff"); … … 1106 1082 msFreeOutputFormat(o3); 1107 1083 } 1108 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1109 fflush(stderr);1110 1084 1111 1085 outputFormatObj *o4=msCreateDefaultOutputFormat(NULL,"GDAL/AAIGRID","grd"); … … 1118 1092 msFreeOutputFormat(o4); 1119 1093 } 1120 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1121 fflush(stderr);1122 1094 1123 1095 #ifdef USE_CAIRO … … 1133 1105 } 1134 1106 #endif 1135 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1136 fflush(stderr);1137 1107 1138 1108 /* … … 1141 1111 msLoadProjectionStringEPSG(&myMap->projection,"EPSG:4326"); 1142 1112 myMap->transparent=1; 1143 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1144 fflush(stderr);1145 1113 1146 1114 /** -
branches/prototype-v0/zoo-project/zoo-kernel/sql/schema.sql
r781 r839 45 45 creation_time timestamp with time zone default now(), 46 46 end_time timestamp with time zone default NULL, 47 -- queue_duration , 48 -- run_duration , 47 49 progress int, 48 message TEXT 50 message TEXT, 51 -- data_lifetime timestamp with time zone default now() + interval '48 hours', 52 rps_step int4 default 0 49 53 ); 50 54 -------------------------------------------------------------------------------- … … 52 56 -- Used to store the response provided by a services running asynchronously 53 57 create table responses ( 54 uuid text references services(uuid) ON DELETE CASCADE,58 uuid text references process(uuid) ON DELETE CASCADE, 55 59 content text, 56 60 creation_time timestamp with time zone default now() -
branches/prototype-v0/zoo-project/zoo-kernel/sqlapi.c
r822 r839 43 43 OGRDataSource 44 44 #endif 45 * zoo_DS = NULL;45 **zoo_DS = NULL; 46 46 47 47 /** … … 70 70 int i=0; 71 71 maps* cconf=getMaps(conf,key); 72 if(cconf==NULL) 73 return "-1"; 72 74 int len=0; 73 75 for(i=0;i<6;i++){ 74 76 map* tmp=getMap(cconf->content,keywords[i]); 75 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);76 fflush(stderr);77 77 if(tmp!=NULL){ 78 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);79 fflush(stderr);80 78 if(res==NULL){ 81 79 res=(char*)malloc((strlen(keywords[i])+strlen(tmp->value)+4)*sizeof(char)); … … 89 87 len+=strlen(res1); 90 88 res[len]=0; 91 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);92 fflush(stderr);93 89 free(res1); 94 90 } 95 91 } 96 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 97 fflush(stderr); 98 } 99 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 100 fflush(stderr); 92 } 101 93 map* tmp=getMap(cconf->content,"type"); 102 94 if(tmp!=NULL){ … … 125 117 * @see createInitString 126 118 */ 127 void_init_sql(maps* conf,const char* key){119 int _init_sql(maps* conf,const char* key){ 128 120 char* sqlInitString=_createInitString(conf,key); 121 if(strncmp(sqlInitString,"-1",2)==0) 122 return -1; 129 123 OGRSFDriver *poDriver = NULL; 130 124 OGRRegisterAll(); 131 125 int zoo_ds_nb=0; 126 map* dsNb=getMapFromMaps(conf,"lenv","ds_nb"); 127 if(dsNb==NULL){ 128 setMapInMaps(conf,"lenv","ds_nb","1"); 129 }else{ 130 zoo_ds_nb=atoi(dsNb->value); 131 char* tmp=(char*)malloc(11*sizeof(char)); 132 sprintf(tmp,"%d",zoo_ds_nb+1); 133 setMapInMaps(conf,"lenv","ds_nb",(const char*)tmp); 134 free(tmp); 135 } 136 if(zoo_DS==NULL) 137 zoo_DS= 132 138 #if GDAL_VERSION_MAJOR >= 2 133 zoo_DS = (GDALDataset*) GDALOpenEx( sqlInitString, 139 (GDALDataset**) malloc(sizeof(GDALDataset*)) 140 #else 141 (OGRDataSource**) malloc(sizeof(OGRDataSource*)) 142 #endif 143 ; 144 else 145 zoo_DS= 146 #if GDAL_VERSION_MAJOR >= 2 147 (GDALDataset**)realloc(zoo_DS,(zoo_ds_nb+1)*sizeof(GDALDataset*)) 148 #else 149 (OGRDataSource**)realloc(zoo_DS,(zoo_ds_nb+1)*sizeof(OGRDataSource*)) 150 #endif 151 ; 152 153 #if GDAL_VERSION_MAJOR >= 2 154 zoo_DS[zoo_ds_nb] = (GDALDataset*) GDALOpenEx( sqlInitString, 134 155 GDAL_OF_UPDATE | GDAL_OF_VECTOR, 135 156 NULL, NULL, NULL ); 136 157 #else 137 zoo_DS = OGRSFDriverRegistrar::Open(sqlInitString,false,&poDriver);138 #endif 139 if( zoo_DS == NULL ){158 zoo_DS[zoo_ds_nb] = OGRSFDriverRegistrar::Open(sqlInitString,false,&poDriver); 159 #endif 160 if( zoo_DS[zoo_ds_nb] == NULL ){ 140 161 #ifdef DEBUG 141 162 fprintf(stderr,"sqlInitString: %s FAILED !\n",sqlInitString); … … 143 164 #endif 144 165 free(sqlInitString); 145 setMapInMaps(conf,"lenv","message","Failed to connect to the database backend"); 146 return; 166 setMapInMaps(conf,"lenv","dbIssue","1"); 167 setMapInMaps(conf,"lenv","message",_("Failed to connect to the database backend")); 168 return -2; 147 169 } 148 170 #ifdef DEBUG … … 150 172 fflush(stderr); 151 173 #endif 174 fprintf(stderr,"sqlInitString: %s SUCEED %d !\n",sqlInitString,zoo_ds_nb); 175 fflush(stderr); 152 176 free(sqlInitString); 177 zoo_ds_nb++; 178 return zoo_ds_nb; 153 179 } 154 180 … … 159 185 * @see createInitString 160 186 */ 161 voidinit_sql(maps* conf){187 int init_sql(maps* conf){ 162 188 return _init_sql(conf,"database"); 163 189 } … … 168 194 * @param conf the maps containing the setting of the main.cfg file 169 195 */ 170 void close_sql(maps* conf ){196 void close_sql(maps* conf,int cid){ 171 197 if( zoo_ResultSet != NULL ) 172 zoo_DS ->ReleaseResultSet( zoo_ResultSet );198 zoo_DS[cid]->ReleaseResultSet( zoo_ResultSet ); 173 199 if(zoo_DS!=NULL){ 174 200 #if GDAL_VERSION_MAJOR >= 2 175 GDALClose(zoo_DS );176 #else 177 OGRDataSource::DestroyDataSource( zoo_DS );178 #endif 179 zoo_DS =NULL;201 GDALClose(zoo_DS[cid]); 202 #else 203 OGRDataSource::DestroyDataSource( zoo_DS[cid] ); 204 #endif 205 zoo_DS[cid]=NULL; 180 206 } 181 207 } … … 196 222 * @return NULL in case of failure or an OGRLayer pointer if the query succeed. 197 223 */ 198 OGRLayer *fetchSql(maps* conf,const char* sqlQuery){ 224 OGRLayer *fetchSql(maps* conf,int cid,const char* sqlQuery){ 225 if(zoo_DS[cid]==NULL) 226 return NULL; 199 227 OGRLayer *res=NULL; 200 res = zoo_DS->ExecuteSQL( sqlQuery, NULL, NULL); 228 #ifdef DEBUG 229 fprintf(stderr,"************************* %s %s %d\n\n",sqlQuery,__FILE__,__LINE__); 230 fflush(stderr); 231 #endif 232 res = zoo_DS[cid]->ExecuteSQL( sqlQuery, NULL, NULL); 201 233 return res; 202 234 } 203 235 204 void cleanFetchSql(maps* conf, OGRLayer *objects){236 void cleanFetchSql(maps* conf,int cid,OGRLayer *objects){ 205 237 if( objects != NULL ){ 206 zoo_DS ->ReleaseResultSet( objects );238 zoo_DS[cid]->ReleaseResultSet( objects ); 207 239 objects=NULL; 208 240 } … … 216 248 * @return -1 in case of failure and 1 if the query succeed. 217 249 */ 218 int execSql(maps* conf, const char* sqlQuery){250 int execSql(maps* conf,int cid,const char* sqlQuery){ 219 251 int res=-1; 220 zoo_ResultSet = zoo_DS ->ExecuteSQL( sqlQuery, NULL, NULL);252 zoo_ResultSet = zoo_DS[cid]->ExecuteSQL( sqlQuery, NULL, NULL); 221 253 if( zoo_ResultSet != NULL ){ 222 254 res=1; 223 255 } 224 zoo_DS->ReleaseResultSet( zoo_ResultSet );225 256 return res; 226 257 } … … 233 264 * @return -1 in case of failure and 1 if the query succeed. 234 265 */ 235 void cleanUpResultSet(const maps* conf ){266 void cleanUpResultSet(const maps* conf,int cid){ 236 267 if( zoo_ResultSet != NULL ){ 237 zoo_DS ->ReleaseResultSet( zoo_ResultSet );268 zoo_DS[cid]->ReleaseResultSet( zoo_ResultSet ); 238 269 zoo_ResultSet=NULL; 239 270 } 271 } 272 273 #ifdef RELY_ON_DB 274 int getCurrentId(maps* conf){ 275 int res=0; 276 map* dsNb=getMapFromMaps(conf,"lenv","ds_nb"); 277 if(dsNb!=NULL) 278 res=atoi(dsNb->value); 279 return res; 240 280 } 241 281 … … 249 289 */ 250 290 void recordStoredFile(maps* conf,const char* filename,const char* type,const char* name){ 291 int zoo_ds_nb=getCurrentId(conf); 251 292 map *uusid=getMapFromMaps(conf,"lenv","usid"); 252 293 map *schema=getMapFromMaps(conf,"database","schema"); … … 256 297 else 257 298 sprintf(sqlQuery,"INSERT INTO %s.files (uuid,filename,nature,name) VALUES ('%s','%s','%s',NULL);",schema->value,uusid->value,filename,type); 258 execSql(conf, sqlQuery);259 free(sqlQuery); 260 cleanUpResultSet(conf );299 execSql(conf,zoo_ds_nb-1,sqlQuery); 300 free(sqlQuery); 301 cleanUpResultSet(conf,zoo_ds_nb-1); 261 302 } 262 303 … … 267 308 */ 268 309 void recordServiceStatus(maps* conf){ 310 int zoo_ds_nb=getCurrentId(conf); 269 311 map *sid=getMapFromMaps(conf,"lenv","sid"); 270 312 map *osid=getMapFromMaps(conf,"lenv","osid"); … … 284 326 osid->value, 285 327 wpsStatus[2]); 286 execSql(conf, sqlQuery);287 free(sqlQuery); 288 cleanUpResultSet(conf );328 execSql(conf,zoo_ds_nb-1,sqlQuery); 329 free(sqlQuery); 330 cleanUpResultSet(conf,zoo_ds_nb-1); 289 331 } 290 332 … … 296 338 */ 297 339 void recordResponse(maps* conf,char* filename){ 340 int zoo_ds_nb=getCurrentId(conf); 298 341 FILE *file = fopen (filename, "rb"); 299 342 fseek (file, 0, SEEK_END); … … 308 351 char *sqlQuery=(char*)malloc((strlen(schema->value)+flen+strlen(sid->value)+57+1)*sizeof(char)); 309 352 sprintf(sqlQuery,"INSERT INTO %s.responses (content,uuid) VALUES ($$%s$$,$$%s$$);",schema->value,tmps,sid->value); 310 execSql(conf, sqlQuery);353 execSql(conf,zoo_ds_nb-1,sqlQuery); 311 354 free(sqlQuery); 312 355 free(tmps); 313 cleanUpResultSet(conf); 314 } 315 316 #ifdef RELY_ON_DB 356 cleanUpResultSet(conf,zoo_ds_nb-1); 357 } 358 317 359 /** 318 360 * Update the current status of the running service. … … 322 364 */ 323 365 int _updateStatus(maps* conf){ 366 int zoo_ds_nb=getCurrentId(conf); 324 367 map *sid=getMapFromMaps(conf,"lenv","usid"); 325 368 map *p=getMapFromMaps(conf,"lenv","status"); … … 328 371 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(msg->value)+strlen(p->value)+strlen(sid->value)+64+1)*sizeof(char)); 329 372 sprintf(sqlQuery,"UPDATE %s.services set status=$$%s$$,message=$$%s$$ where uuid=$$%s$$;",schema->value,p->value,msg->value,sid->value); 330 fflush(stderr); 331 if( zoo_DS == NULL ) 373 if( zoo_ds_nb== 374 #ifdef META_DB 375 1 376 #else 377 0 378 #endif 379 ){ 332 380 init_sql(conf); 333 execSql(conf,sqlQuery); 334 cleanUpResultSet(conf); 381 zoo_ds_nb++; 382 } 383 execSql(conf,zoo_ds_nb-1,sqlQuery); 384 cleanUpResultSet(conf,zoo_ds_nb-1); 335 385 free(sqlQuery); 336 386 return 0; … … 345 395 */ 346 396 char* _getStatus(maps* conf,char* pid){ 397 int zoo_ds_nb=getCurrentId(conf); 347 398 map *schema=getMapFromMaps(conf,"database","schema"); 348 399 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+58+1)*sizeof(char)); 349 400 sprintf(sqlQuery,"select status||'|'||message from %s.services where uuid=$$%s$$;",schema->value,pid); 350 if( zoo_DS == NULL ) 401 if( zoo_ds_nb== 402 #ifdef META_DB 403 1 404 #else 405 0 406 #endif 407 ){ 351 408 init_sql(conf); 352 execSql(conf,sqlQuery); 409 zoo_ds_nb++; 410 } 411 execSql(conf,zoo_ds_nb-1,sqlQuery); 353 412 OGRFeature *poFeature = NULL; 354 413 const char *tmp1; … … 363 422 OGRFeature::DestroyFeature( poFeature ); 364 423 } 365 cleanUpResultSet(conf );424 cleanUpResultSet(conf,zoo_ds_nb-1); 366 425 free(sqlQuery); 367 426 return (char*)tmp1; … … 376 435 */ 377 436 char* _getStatusFile(maps* conf,char* pid){ 437 int zoo_ds_nb=getCurrentId(conf); 378 438 map *schema=getMapFromMaps(conf,"database","schema"); 379 439 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+82+1)*sizeof(char)); … … 381 441 "select content from %s.responses where uuid=$$%s$$" 382 442 " order by creation_time desc limit 1",schema->value,pid); 383 if( zoo_DS == NULL ) 443 if( zoo_ds_nb== 444 #ifdef META_DB 445 1 446 #else 447 0 448 #endif 449 ){ 384 450 init_sql(conf); 385 execSql(conf,sqlQuery); 451 zoo_ds_nb++; 452 } 453 execSql(conf,zoo_ds_nb-1,sqlQuery); 386 454 OGRFeature *poFeature = NULL; 387 455 const char *tmp1; 388 456 int hasRes=-1; 389 while( (poFeature = zoo_ResultSet->GetNextFeature()) != NULL ){ 390 for( int iField = 0; iField < poFeature->GetFieldCount(); iField++ ){ 391 if( poFeature->IsFieldSet( iField ) ){ 392 tmp1=strdup(poFeature->GetFieldAsString( iField )); 393 hasRes=1; 457 if(zoo_ResultSet!=NULL){ 458 while( (poFeature = zoo_ResultSet->GetNextFeature()) != NULL ){ 459 for( int iField = 0; iField < poFeature->GetFieldCount(); iField++ ){ 460 if( poFeature->IsFieldSet( iField ) ){ 461 tmp1=strdup(poFeature->GetFieldAsString( iField )); 462 hasRes=1; 463 } 464 else 465 tmp1=NULL; 466 } 467 OGRFeature::DestroyFeature( poFeature ); 394 468 } 395 else396 tmp1=NULL;397 }398 OGRFeature::DestroyFeature( poFeature );399 469 } 400 470 if(hasRes<0) 401 471 tmp1=NULL; 402 cleanUpResultSet(conf); 472 else 473 cleanUpResultSet(conf,zoo_ds_nb-1); 403 474 free(sqlQuery); 404 475 return (char*)tmp1; … … 412 483 */ 413 484 void removeService(maps* conf,char* pid){ 485 int zoo_ds_nb=getCurrentId(conf); 414 486 map *schema=getMapFromMaps(conf,"database","schema"); 415 487 char *sqlQuery=(char*) 416 488 malloc((strlen(pid)+strlen(schema->value)+38+1) 417 489 *sizeof(char)); 418 if( zoo_DS == NULL ) 490 if( zoo_ds_nb== 491 #ifdef META_DB 492 1 493 #else 494 0 495 #endif 496 ){ 419 497 init_sql(conf); 498 zoo_ds_nb++; 499 } 420 500 sprintf(sqlQuery, 421 501 "DELETE FROM %s.services where uuid=$$%s$$;", 422 502 schema->value,pid); 423 execSql(conf, sqlQuery);424 cleanUpResultSet(conf );425 close_sql(conf );503 execSql(conf,zoo_ds_nb-1,sqlQuery); 504 cleanUpResultSet(conf,zoo_ds_nb-1); 505 close_sql(conf,zoo_ds_nb-1); 426 506 free(sqlQuery); 427 507 end_sql(); … … 434 514 */ 435 515 void unhandleStatus(maps* conf){ 516 int zoo_ds_nb=getCurrentId(conf); 436 517 map *schema=getMapFromMaps(conf,"database","schema"); 437 518 map *sid=getMapFromMaps(conf,"lenv","usid"); … … 447 528 " where uuid=$$%s$$;", 448 529 schema->value,(fstate!=NULL?fstate->value:"Failed"),sid->value); 449 execSql(conf, sqlQuery);450 cleanUpResultSet(conf );451 close_sql(conf );530 execSql(conf,zoo_ds_nb-1,sqlQuery); 531 cleanUpResultSet(conf,zoo_ds_nb-1); 532 close_sql(conf,zoo_ds_nb-1); 452 533 free(sqlQuery); 453 534 end_sql(); … … 462 543 */ 463 544 char* getStatusId(maps* conf,char* pid){ 545 int zoo_ds_nb=getCurrentId(conf); 464 546 map *schema=getMapFromMaps(conf,"database","schema"); 465 547 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+58+1)*sizeof(char)); … … 467 549 "select osid from %s.services where uuid=$$%s$$", 468 550 schema->value,pid); 469 if( zoo_ DS == NULL )551 if( zoo_ds_nb==0 ){ 470 552 init_sql(conf); 471 execSql(conf,sqlQuery); 553 zoo_ds_nb++; 554 } 555 execSql(conf,zoo_ds_nb-1,sqlQuery); 472 556 OGRFeature *poFeature = NULL; 473 557 const char *tmp1; … … 486 570 tmp1=NULL; 487 571 free(sqlQuery); 572 cleanUpResultSet(conf,zoo_ds_nb-1); 488 573 return (char*)tmp1; 489 574 } … … 496 581 */ 497 582 void readFinalRes(maps* conf,char* pid,map* statusInfo){ 583 int zoo_ds_nb=getCurrentId(conf); 498 584 map *schema=getMapFromMaps(conf,"database","schema"); 499 585 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+58+1)*sizeof(char)); … … 503 589 if( zoo_DS == NULL ) 504 590 init_sql(conf); 505 execSql(conf, sqlQuery);591 execSql(conf,zoo_ds_nb-1,sqlQuery); 506 592 OGRFeature *poFeature = NULL; 507 593 int hasRes=-1; … … 531 617 int isRunning(maps* conf,char* pid){ 532 618 int res=0; 619 int zoo_ds_nb=getCurrentId(conf); 533 620 map *schema=getMapFromMaps(conf,"database","schema"); 534 621 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+73+1)*sizeof(char)); 535 622 sprintf(sqlQuery,"select count(*) as t from %s.services where uuid=$$%s$$ and end_time is null;",schema->value,pid); 536 if( zoo_ DS == NULL )623 if( zoo_ds_nb == 0 ){ 537 624 init_sql(conf); 538 execSql(conf,sqlQuery); 625 zoo_ds_nb++; 626 } 627 execSql(conf,zoo_ds_nb-1,sqlQuery); 539 628 OGRFeature *poFeature = NULL; 540 629 const char *tmp1; … … 549 638 OGRFeature::DestroyFeature( poFeature ); 550 639 } 551 cleanUpResultSet(conf );640 cleanUpResultSet(conf,zoo_ds_nb-1); 552 641 free(sqlQuery); 553 642 return res; -
branches/prototype-v0/zoo-project/zoo-kernel/sqlapi.h
r822 r839 42 42 #ifdef META_DB 43 43 ZOO_DLL_EXPORT char* _createInitString(maps*,const char*); 44 ZOO_DLL_EXPORT void _init_sql(maps*,const char*); 45 ZOO_DLL_EXPORT OGRLayer *fetchSql(maps*,const char*); 44 ZOO_DLL_EXPORT int _init_sql(maps*,const char*); 45 ZOO_DLL_EXPORT OGRLayer *fetchSql(maps*,int,const char*); 46 ZOO_DLL_EXPORT void cleanFetchSql(maps*,int,OGRLayer*); 46 47 #endif 47 48 #ifdef RELY_ON_DB 48 ZOO_DLL_EXPORT voidinit_sql(maps*);49 ZOO_DLL_EXPORT void close_sql(maps* );50 ZOO_DLL_EXPORT int execSql(maps*, const char*);49 ZOO_DLL_EXPORT int init_sql(maps*); 50 ZOO_DLL_EXPORT void close_sql(maps*,int); 51 ZOO_DLL_EXPORT int execSql(maps*,int,const char*); 51 52 ZOO_DLL_EXPORT void recordStoredFile(maps*,const char*,const char*,const char*); 52 53 ZOO_DLL_EXPORT void recordServiceStatus(maps*); … … 56 57 ZOO_DLL_EXPORT char* getStatusId(maps*,char*); 57 58 ZOO_DLL_EXPORT void removeService(maps*,char*); 59 ZOO_DLL_EXPORT void end_sql(); 58 60 #endif 59 61 -
branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c
r822 r839 9 9 * by the French National Research Agency 10 10 * 11 * permission is hereby granted, free of charge, to any person obtaining a copy11 * Permission is hereby granted, free of charge, to any person obtaining a copy 12 12 * of this software and associated documentation files (the "Software"), to deal 13 13 * in the Software without restriction, including without limitation the rights … … 249 249 * @return true in case of success, false if failure occured 250 250 */ 251 size_t ssh_file_exists(maps* conf,const char* targetPath ){251 size_t ssh_file_exists(maps* conf,const char* targetPath,int cnt){ 252 252 size_t result=-1; 253 int cnt=ssh_get_cnt(conf);254 253 if(cnt>0) 255 254 cnt-=1; … … 303 302 * @return true in case of success, false if failure occured 304 303 */ 305 bool ssh_copy(maps* conf,const char* localPath,const char* targetPath ){304 bool ssh_copy(maps* conf,const char* localPath,const char* targetPath,int cnt){ 306 305 char mem[1024 * 1000]; 307 306 size_t nread; … … 310 309 long total = 0; 311 310 int duration; 312 int cnt=ssh_get_cnt(conf);313 311 int rc; 314 312 LIBSSH2_SFTP_HANDLE *sftp_handle; … … 323 321 if (!local) { 324 322 fprintf(stderr, "Can't open local file %s\n", localPath); 325 return -1;323 return false; 326 324 } 327 325 … … 382 380 duration = (int)(time(NULL)-start); 383 381 fclose(local); 384 libssh2_sftp_close (sftp_handle);382 libssh2_sftp_close_handle(sftp_handle); 385 383 386 384 libssh2_sftp_shutdown(sessions[cnt]->sftp_session); … … 396 394 * @return true in case of success, false if failure occured 397 395 */ 398 int ssh_fetch(maps* conf,const char* localPath,const char* targetPath ){396 int ssh_fetch(maps* conf,const char* localPath,const char* targetPath,int cnt){ 399 397 char mem[1024]; 400 398 size_t nread; … … 403 401 long total = 0; 404 402 int duration; 405 int cnt=ssh_get_cnt(conf);406 403 int rc; 407 404 LIBSSH2_SFTP_HANDLE *sftp_handle; … … 428 425 if (!sftp_handle) { 429 426 if (libssh2_session_last_errno(sessions[cnt]->session) != LIBSSH2_ERROR_EAGAIN) { 430 431 427 fprintf(stderr, "Unable to open file with SFTP\n"); 432 428 return -1; … … 443 439 do { 444 440 rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem)); 445 fprintf(stderr, "libssh2_sftp_read returned %d\n", 446 rc); 447 441 /*fprintf(stderr, "libssh2_sftp_read returned %d\n", 442 rc);*/ 448 443 if(rc > 0) { 449 444 //write(2, mem, rc); 450 445 fwrite(mem, rc, 1, local); 451 446 } … … 479 474 duration = (int)(time(NULL)-start); 480 475 fclose(local); 481 libssh2_sftp_close (sftp_handle);476 libssh2_sftp_close_handle(sftp_handle); 482 477 483 478 libssh2_sftp_shutdown(sessions[cnt]->sftp_session); … … 491 486 * @return bytecount resulting from the execution of the command 492 487 */ 493 int ssh_exec(maps* conf,const char* command){ 494 int cnt=ssh_get_cnt(conf); 488 int ssh_exec(maps* conf,const char* command,int cnt){ 495 489 LIBSSH2_CHANNEL *channel; 496 490 int rc; … … 571 565 while (libssh2_session_disconnect(con->session, "Normal Shutdown, Thank you for using the ZOO-Project sshapi") 572 566 == LIBSSH2_ERROR_EAGAIN); 573 libssh2_session_free(con->session);574 567 #ifdef WIN32 575 568 closesocket(con->sock_id); … … 577 570 close(con->sock_id); 578 571 #endif 572 libssh2_session_free(con->session); 579 573 return true; 580 574 } … … 596 590 return true; 597 591 } 592 593 bool addToUploadQueue(maps** conf,maps* input){ 594 map* queueMap=getMapFromMaps(*conf,"uploadQueue","length"); 595 if(queueMap==NULL){ 596 maps* queueMaps=createMaps("uploadQueue"); 597 queueMaps->content=createMap("length","0"); 598 addMapsToMaps(conf,queueMaps); 599 freeMaps(&queueMaps); 600 free(queueMaps); 601 queueMap=getMapFromMaps(*conf,"uploadQueue","length"); 602 } 603 maps* queueMaps=getMaps(*conf,"uploadQueue"); 604 int queueIndex=atoi(queueMap->value); 605 if(input!=NULL){ 606 if(getMap(input->content,"cache_file")!=NULL){ 607 map* length=getMap(input->content,"length"); 608 if(length==NULL){ 609 addToMap(input->content,"length","1"); 610 length=getMap(input->content,"length"); 611 } 612 int len=atoi(length->value); 613 int i=0; 614 for(i=0;i<len;i++){ 615 616 map* tmp[2]={getMapArray(input->content,"localPath",i), 617 getMapArray(input->content,"targetPath",i)}; 618 619 setMapArray(queueMaps->content,"input",queueIndex,input->name); 620 setMapArray(queueMaps->content,"localPath",queueIndex,tmp[0]->value); 621 setMapArray(queueMaps->content,"targetPath",queueIndex,tmp[1]->value); 622 queueIndex+=1; 623 } 624 } 625 } 626 #ifdef DEBUG 627 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 628 fflush(stderr); 629 dumpMaps(queueMaps); 630 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 631 fflush(stderr); 632 dumpMaps(*conf); 633 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 634 fflush(stderr); 635 #endif 636 return true; 637 } 638 639 bool runUpload(maps** conf){ 640 SSHCON *test=ssh_connect(*conf); 641 if(test==NULL){ 642 return false; 643 } 644 #ifdef DEBUG 645 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 646 fflush(stderr); 647 dumpMaps(getMaps(*conf,"uploadQueue")); 648 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 649 fflush(stderr); 650 #endif 651 map* queueLengthMap=getMapFromMaps(*conf,"uploadQueue","length"); 652 maps* queueMaps=getMaps(*conf,"uploadQueue"); 653 if(queueLengthMap!=NULL){ 654 int cnt=atoi(queueLengthMap->value); 655 int i=0; 656 for(i=0;i<cnt;i++){ 657 map* argv[3]={ 658 getMapArray(queueMaps->content,"input",i), 659 getMapArray(queueMaps->content,"localPath",i), 660 getMapArray(queueMaps->content,"targetPath",i) 661 }; 662 fprintf(stderr,"%s %d %s %s\n",__FILE__,__LINE__,argv[1]->value,argv[2]->value); 663 ssh_copy(*conf,argv[1]->value,argv[2]->value,ssh_get_cnt(*conf)); 664 } 665 } 666 return true; 667 } -
branches/prototype-v0/zoo-project/zoo-kernel/sshapi.h
r822 r839 85 85 86 86 ZOO_DLL_EXPORT SSHCON *ssh_connect(maps*); 87 ZOO_DLL_EXPORT bool ssh_copy(maps*,const char*,const char*); 88 ZOO_DLL_EXPORT int ssh_fetch(maps*,const char*,const char*); 89 ZOO_DLL_EXPORT int ssh_exec(maps*,const char*); 87 ZOO_DLL_EXPORT bool ssh_copy(maps*,const char*,const char*,int); 88 ZOO_DLL_EXPORT int ssh_get_cnt(maps*); 89 ZOO_DLL_EXPORT int ssh_fetch(maps*,const char*,const char*,int); 90 ZOO_DLL_EXPORT int ssh_exec(maps*,const char*,int); 90 91 ZOO_DLL_EXPORT bool ssh_close_session(maps*,SSHCON*); 91 92 ZOO_DLL_EXPORT bool ssh_close(maps*); 93 ZOO_DLL_EXPORT bool addToUploadQueue(maps**,maps*); 94 ZOO_DLL_EXPORT bool runUpload(maps**); 92 95 93 96 #ifdef __cplusplus -
branches/prototype-v0/zoo-project/zoo-kernel/ulinet.c
r821 r839 70 70 /** 71 71 * In case of presence of "Set-Cookie" in the headers red, store the cookie 72 * identifier in CCookie72 * identifier in cookie 73 73 * 74 74 * @param buffer the buffer to read … … 77 77 * @param data the _HINTERNET structure to write in 78 78 * @return the size red, -1 if buffer is NULL 79 * @see CCookie79 * @see cookie 80 80 */ 81 81 size_t header_write_data(void *buffer, size_t size, size_t nmemb, void *data){ 82 82 if(strncmp("Set-Cookie: ",(char*)buffer,12)==0){ 83 83 int i; 84 char env[256];85 char path[256];86 char domain[256];87 84 char* tmp; 88 85 for(i=0;i<12;i++) … … 92 89 ; 93 90 #endif 94 sscanf((char*)buffer,"%s; path=%s; domain=%s",env,path,domain); 91 tmp=strtok(buffer,";"); 92 int cnt=0; 95 93 _HINTERNET *psInternet=(_HINTERNET *)data; 96 tmp=strcat(env,CCookie[psInternet->id][0]); 97 #ifdef MSG_LAF_OUT 98 printf("\n**Cookie env : [%s] , path : [%s], domain : [%s]**\n",env,path,domain); 99 printf("buffer : %d (%s) (%s) (%s)\n",(buffer==NULL),buffer,tmp,CCookie); 100 #endif 101 strcpy(CCookie[psInternet->id][0],tmp); 94 if(tmp!=NULL && psInternet!=NULL){ 95 psInternet->cookie=(char*)malloc(sizeof(char)*(strlen(tmp)+1)); 96 sprintf(psInternet->cookie,"%s",tmp); 97 } 102 98 } 103 99 return size * nmemb;//write_data_into(buffer,size,nmemb,data,HEADER); … … 340 336 if(handle.url!=NULL) 341 337 free(handle.url); 342 free(handle.mimeType); 343 handle.mimeType = NULL; 338 if(handle.mimeType!=NULL) 339 free(handle.mimeType); 340 if(handle.cookie!=NULL) 341 free(handle.cookie); 344 342 } 345 343 if(handle0->handle) … … 371 369 hInternet->ihandle[hInternet->nb].url = NULL; 372 370 hInternet->ihandle[hInternet->nb].mimeType = NULL; 371 hInternet->ihandle[hInternet->nb].cookie = NULL; 373 372 hInternet->ihandle[hInternet->nb].nDataLen = 0; 374 373 hInternet->ihandle[hInternet->nb].id = hInternet->nb; … … 376 375 hInternet->ihandle[hInternet->nb].pabyData = NULL; 377 376 hInternet->ihandle[hInternet->nb].post = NULL; 378 377 379 378 curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_COOKIEFILE, "ALL"); 380 379 #ifndef TIGER … … 475 474 curl_multi_remove_handle(hInternet->handle, hInternet->ihandle[i].handle); 476 475 curl_easy_cleanup(hInternet->ihandle[i].handle); 476 //fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,hInternet->ihandle[i].mimeType); 477 //fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,hInternet->ihandle[i].pabyData); 477 478 } 478 479 return 0; … … 480 481 481 482 /** 482 * Initialize the CCookie for a specific index (hInternet.nb)483 * 484 * @param hInternet the HINTERNET structure to know the CCookie index to reset483 * Initialize the cookie for a specific index (hInternet.nb) 484 * 485 * @param hInternet the HINTERNET structure to know the cookie index to reset 485 486 * @return 1 486 487 * @see HINTERNET 487 488 */ 488 489 int freeCookieList(HINTERNET hInternet){ 489 memset(&CCookie[hInternet.nb][0],0,1024);490 hInternet.ihandle[hInternet.nb].cookie=strdup(""); 490 491 #ifndef TIGER 491 492 curl_easy_setopt(hInternet.ihandle[hInternet.nb].handle, CURLOPT_COOKIELIST, "ALL"); … … 536 537 } 537 538 538 CCookie[hInternet.id][0]=0;539 540 539 if( *lpdwNumberOfBytesRead < dwDataSize ) 541 540 return 0; -
branches/prototype-v0/zoo-project/zoo-kernel/ulinet.h
r817 r839 54 54 #define MAX_REQ 50 55 55 56 #ifdef _ULINET57 static char CCookie[MAX_REQ][1024];58 #else59 /**60 * The cookies found61 */62 extern char CCookie[MAX_REQ][1024];63 #endif64 65 56 #ifdef __cplusplus 66 57 extern "C" { … … 88 79 char *mimeType; //!< the mimeType returned by the server 89 80 char *post; //!< the potential POST XML content 81 char* cookie; //!< The potential Cookie returned by the server 90 82 int hasCacheFile; //!< 1 if we used a cache file 91 83 int nDataLen; //!< the length of the downloaded content -
branches/prototype-v0/zoo-project/zoo-kernel/zoo_service_loader.c
r822 r839 102 102 #endif 103 103 104 #include "service_json.h" 105 #include "service_callback.h" 106 104 107 #include <dirent.h> 105 108 #include <signal.h> … … 158 161 159 162 #ifdef WIN32 160 161 162 163 #ifndef PROGRAMNAME 164 #define PROGRAMNAME "zoo_loader.cgi" 165 #endif 163 166 #endif 164 167 … … 213 216 fclose (f2); 214 217 fclose (f3); 218 free(tmps1); 215 219 return 1; 216 220 } … … 233 237 */ 234 238 int 235 recursReaddirF ( maps * m, registry *r, xml NodePtr n, char *conf_dir,239 recursReaddirF ( maps * m, registry *r, xmlDocPtr doc, xmlNodePtr n, char *conf_dir, 236 240 char *prefix, int saved_stdout, int level, 237 void (func) (registry *, maps *, xml NodePtr, service *) )241 void (func) (registry *, maps *, xmlDocPtr, xmlNodePtr, service *) ) 238 242 { 239 243 struct dirent *dp; … … 282 286 setMapInMaps (m, "lenv", "level", levels1); 283 287 res = 284 recursReaddirF (m, r, n, tmp, prefix, saved_stdout, level + 1,288 recursReaddirF (m, r, doc, n, tmp, prefix, saved_stdout, level + 1, 285 289 func); 286 290 sprintf (levels1, "%d", level); … … 320 324 return -1; 321 325 } 322 #if ndef DEBUG326 #ifdef DEBUG 323 327 fprintf (stderr, "#################\n%s\n#################\n", 324 328 tmps1); … … 346 350 #endif 347 351 inheritance(r,&s1); 348 func (r, m, n, s1);352 func (r, m, doc, n, s1); 349 353 freeService (&s1); 350 354 free (s1); … … 949 953 #endif 950 954 955 951 956 map *r_inputs = NULL; 952 957 map *request_inputs = *inputs; 958 //fprintf(stderr,"%s \n",json_object_to_json_string_ext(mapToJson(request_inputs),JSON_C_TO_STRING_PLAIN)); 959 953 960 #ifdef IGNORE_METAPATH 954 961 addToMap(request_inputs, "metapath", ""); … … 1305 1312 } 1306 1313 inheritance(zooRegistry, &svc); 1307 printGetCapabilitiesForProcess(zooRegistry, m, n, svc);1314 printGetCapabilitiesForProcess(zooRegistry, m, doc, n, svc); 1308 1315 freeService(&svc); 1309 1316 free(svc); … … 1314 1321 1315 1322 if (int res = 1316 recursReaddirF (m, zooRegistry, n, conf_dir, NULL, saved_stdout, 0,1323 recursReaddirF (m, zooRegistry, doc, n, conf_dir, NULL, saved_stdout, 0, 1317 1324 printGetCapabilitiesForProcess) < 0) 1318 1325 { … … 1331 1338 dup2 (saved_stdout, fileno (stdout)); 1332 1339 #ifdef META_DB 1333 fetchServicesFromDb(zooRegistry,m,n,printGetCapabilitiesForProcess); 1340 fetchServicesFromDb(zooRegistry,m,doc,n,printGetCapabilitiesForProcess,1); 1341 fprintf(stderr,"************************* %s %d\n\n",__FILE__,__LINE__); 1342 close_sql(m,0); 1334 1343 #endif 1335 1344 printDocument (m, doc, getpid ()); … … 1353 1362 runGetStatus(m,r_inputs->value,REQUEST); 1354 1363 freeMaps (&m); 1355 free 1364 free(m); 1356 1365 if(zooRegistry!=NULL){ 1357 1366 freeRegistry(&zooRegistry); … … 1429 1438 } 1430 1439 inheritance(zooRegistry, &svc); 1431 printDescribeProcessForProcess(zooRegistry, m, n, svc); 1440 #ifdef USE_HPC 1441 addNestedOutputs(&svc); 1442 #endif 1443 1444 printDescribeProcessForProcess(zooRegistry, m, doc, n, svc); 1432 1445 freeService(&svc); 1433 1446 free(svc); … … 1438 1451 1439 1452 if (int res = 1440 recursReaddirF (m, zooRegistry, n, conf_dir, NULL, saved_stdout, 0,1453 recursReaddirF (m, zooRegistry, doc, n, conf_dir, NULL, saved_stdout, 0, 1441 1454 printDescribeProcessForProcess) < 0) 1442 1455 return res; 1443 1456 #ifdef META_DB 1444 fetchServicesFromDb(zooRegistry,m,n,printDescribeProcessForProcess); 1457 fetchServicesFromDb(zooRegistry,m,doc,n,printDescribeProcessForProcess,0); 1458 close_sql(m,0); 1445 1459 #endif 1446 1460 … … 1461 1475 { 1462 1476 #ifdef META_DB 1463 service* s2=extractServiceFromDb(m,import->name); 1464 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 1465 fflush(stderr); 1477 service* s2=extractServiceFromDb(m,import->name,0); 1466 1478 if(s2==NULL){ 1467 1479 #endif … … 1500 1512 dumpService (s1); 1501 1513 #endif 1502 1503 1514 inheritance(zooRegistry,&s1); 1504 printDescribeProcessForProcess (zooRegistry,m, n, s1); 1515 #ifdef USE_HPC 1516 addNestedOutputs(&s1); 1517 #endif 1518 printDescribeProcessForProcess (zooRegistry, m, doc, n, s1); 1505 1519 freeService (&s1); 1506 1520 free (s1); … … 1520 1534 addToMap (request_inputs, "metapath", tmpMap->value); 1521 1535 map *tmpMapI = getMapFromMaps (m, "lenv", "Identifier"); 1522 1523 1536 #ifdef META_DB 1524 service* s2=extractServiceFromDb(m,tmpMapI->name); 1525 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 1526 fflush(stderr); 1537 service* s2=extractServiceFromDb(m,tmpMapI->name,0); 1527 1538 if(s2==NULL){ 1528 1539 #endif … … 1567 1578 #endif 1568 1579 inheritance(zooRegistry,&s1); 1569 printDescribeProcessForProcess (zooRegistry,m, n, s1); 1580 #ifdef USE_HPC 1581 addNestedOutputs(&s1); 1582 #endif 1583 printDescribeProcessForProcess (zooRegistry, m, doc, n, s1); 1570 1584 freeService (&s1); 1571 1585 free (s1); … … 1580 1594 else 1581 1595 { 1582 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);1583 fflush(stderr);1584 1596 #ifdef META_DB 1585 1597 _init_sql(m,"metadb"); 1586 service* s2=extractServiceFromDb(m,corig); 1598 //FAILED CONNECTING DB 1599 if(getMapFromMaps(m,"lenv","dbIssue")!=NULL){ 1600 fprintf(stderr,"ERROR CONNECTING METADB"); 1601 } 1602 service* s2=extractServiceFromDb(m,corig,0); 1587 1603 if(s2!=NULL){ 1588 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);1589 fflush(stderr);1590 1604 inheritance(zooRegistry,&s2); 1591 printDescribeProcessForProcess (zooRegistry,m, n, s2); 1605 #ifdef USE_HPC 1606 addNestedOutputs(&s2); 1607 #endif 1608 printDescribeProcessForProcess (zooRegistry,m, doc, n, s2); 1592 1609 freeService (&s2); 1593 1610 free (s2); … … 1664 1681 #endif 1665 1682 inheritance(zooRegistry,&s1); 1666 printDescribeProcessForProcess (zooRegistry,m, n, s1); 1683 #ifdef USE_HPC 1684 addNestedOutputs(&s1); 1685 #endif 1686 printDescribeProcessForProcess (zooRegistry,m, doc, n, s1); 1667 1687 freeService (&s1); 1668 1688 free (s1); … … 1725 1745 free (SERVICE_URL); 1726 1746 fflush (stdout); 1747 #ifdef META_DB 1748 close_sql(m,0); 1749 //end_sql(); 1750 #endif 1727 1751 return 0; 1728 1752 } … … 1803 1827 } 1804 1828 s1 = NULL; 1805 s1 = (service *) malloc (SERVICE_SIZE); 1806 if (s1 == NULL) 1807 { 1808 freeMaps (&m); 1809 free (m); 1810 if(zooRegistry!=NULL){ 1811 freeRegistry(&zooRegistry); 1812 free(zooRegistry); 1813 } 1814 free (REQUEST); 1815 free (SERVICE_URL); 1816 return errorException (m, _("Unable to allocate memory"), 1817 "InternalError", NULL); 1818 } 1819 1829 if(postRequest!=NULL) 1830 setMapInMaps (m, "lenv", "xrequest", postRequest->value); 1831 1820 1832 r_inputs = getMap (request_inputs, "Identifier"); 1821 1822 1833 map* import = getMapFromMaps (m, IMPORTSERVICE, r_inputs->value); 1823 1834 if (import != NULL && import->value != NULL) { … … 1848 1859 1849 1860 r_inputs = getMapFromMaps (m, "lenv", "Identifier"); 1861 1862 #ifdef META_DB 1863 int metadb_id=_init_sql(m,"metadb"); 1864 fprintf(stderr,"CONNECTING METADB!\n"); 1865 //FAILED CONNECTING DB 1866 if(getMapFromMaps(m,"lenv","dbIssue")!=NULL){ 1867 fprintf(stderr,"ERROR CONNECTING METADB\n"); 1868 } 1869 s1=extractServiceFromDb(m,r_inputs->value,0); 1870 //close_sql(m,0); 1871 if(s1!=NULL){ 1872 inheritance(zooRegistry,&s1); 1873 #ifdef USE_HPC 1874 addNestedOutputs(&s1); 1875 #endif 1876 if(zooRegistry!=NULL){ 1877 freeRegistry(&zooRegistry); 1878 free(zooRegistry); 1879 } 1880 }else /* Not found in MetaDB */{ 1881 #endif 1882 s1 = (service *) malloc (SERVICE_SIZE); 1883 if (s1 == NULL) 1884 { 1885 freeMaps (&m); 1886 free (m); 1887 if(zooRegistry!=NULL){ 1888 freeRegistry(&zooRegistry); 1889 free(zooRegistry); 1890 } 1891 free (REQUEST); 1892 free (SERVICE_URL); 1893 return errorException (m, _("Unable to allocate memory"), 1894 "InternalError", NULL); 1895 } 1896 1850 1897 int saved_stdout = dup (fileno (stdout)); 1851 1898 dup2 (fileno (stderr), fileno (stdout)); 1852 1899 t = readServiceFile (m, tmps1, &s1, r_inputs->value); 1853 1900 inheritance(zooRegistry,&s1); 1901 #ifdef USE_HPC 1902 addNestedOutputs(&s1); 1903 #endif 1854 1904 if(zooRegistry!=NULL){ 1855 1905 freeRegistry(&zooRegistry); … … 1875 1925 } 1876 1926 close (saved_stdout); 1877 1927 #ifdef META_DB 1928 } 1929 #endif 1930 1878 1931 #ifdef DEBUG 1879 1932 dumpService (s1); … … 1912 1965 return 0; 1913 1966 } 1914 1967 //InternetCloseHandle (&hInternet); 1968 1915 1969 // Define each env variable in runing environment 1916 1970 maps *curs = getMaps (m, "env"); … … 2052 2106 int cpid = getpid (); 2053 2107 2108 // Create a map containing a copy of the request map 2109 maps *_tmpMaps = createMaps("request"); 2110 addMapToMap(&_tmpMaps->content,request_inputs); 2111 addMapsToMaps (&m, _tmpMaps); 2112 freeMaps (&_tmpMaps); 2113 free (_tmpMaps); 2054 2114 /** 2055 2115 * Initialize the specific [lenv] section which contains runtime variables: … … 2072 2132 * 2073 2133 */ 2074 maps *_tmpMaps = createMaps("lenv");2134 _tmpMaps = createMaps("lenv"); 2075 2135 char tmpBuff[100]; 2076 2136 struct ztimeval tp; … … 2182 2242 #endif 2183 2243 int ei = 1; 2184 char * s=2244 char **orig = 2185 2245 #ifdef WIN32 2186 GetEnvironmentStrings() ;2246 GetEnvironmentStrings() 2187 2247 #else 2188 *environ; 2189 #endif 2248 environ 2249 #endif 2250 ; 2251 char *s=*orig; 2190 2252 _tmpMaps = createMaps("renv"); 2191 2253 for (; s; ei++) { 2192 2254 char* tmpName=zStrdup(s); 2193 2255 char* tmpValue=strstr(s,"=")+1; 2194 tmpName[strlen(tmpName)-strlen(tmpValue)-1]=0; 2256 char* tmpName1=(char*)malloc((1+(strlen(tmpName)-strlen(tmpValue)))*sizeof(char)); 2257 snprintf(tmpName1,(strlen(tmpName)-strlen(tmpValue)),"%s",tmpName); 2195 2258 if(_tmpMaps->content == NULL) 2196 _tmpMaps->content = createMap (tmpName ,tmpValue);2259 _tmpMaps->content = createMap (tmpName1,tmpValue); 2197 2260 else 2198 addToMap (_tmpMaps->content,tmpName ,tmpValue);2261 addToMap (_tmpMaps->content,tmpName1,tmpValue); 2199 2262 free(tmpName); 2200 s = *(environ+ei); 2263 free(tmpName1); 2264 s = *(orig+ei); 2201 2265 } 2202 2266 addMapsToMaps (&m, _tmpMaps); … … 2228 2292 } 2229 2293 #endif 2294 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 2295 invokeCallback(m,NULL,NULL,0,0); 2296 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 2230 2297 2231 2298 char *fbkp, *fbkpid, *fbkpres, *fbkp1, *flog; … … 2236 2303 if (status == NULLMAP) 2237 2304 { 2305 /* hInternet = InternetOpen ( 2306 #ifndef WIN32 2307 (LPCTSTR) 2308 #endif 2309 "ZooWPSClient\0", 2310 INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);*/ 2311 2238 2312 if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){ 2239 2313 freeService (&s1); … … 2251 2325 return -1; 2252 2326 } 2327 fprintf(stderr,"*************************\n\n"); 2328 //fprintf(stderr,"%s \n",json_object_to_json_string_ext(mapsToJson(request_input_real_format),JSON_C_TO_STRING_PLAIN)); 2329 fprintf(stderr,"*************************\n\n"); 2253 2330 loadServiceAndRun (&m, s1, request_inputs, &request_input_real_format, 2254 2331 &request_output_real_format, &eres); … … 2300 2377 int cpid = atoi (tmpm->value); 2301 2378 r_inputs = getMapFromMaps (m, "main", "tmpPath"); 2379 setMapInMaps (m, "lenv", "async","true"); 2302 2380 map* r_inputs1 = createMap("ServiceName", s1->name); 2303 2381 … … 2396 2474 f1 = freopen (fbkp1, "w+", stdout); 2397 2475 2476 map* serviceTypeMap=getMap(s1->content,"serviceType"); 2477 if(serviceTypeMap!=NULL) 2478 setMapInMaps (m, "lenv", "serviceType", serviceTypeMap->value); 2479 2480 char *flenv = 2481 (char *) 2482 malloc ((strlen (r_inputs->value) + 2483 strlen (usid->value) + 12) * sizeof (char)); 2484 sprintf (flenv, "%s/%s_lenv.cfg", r_inputs->value, usid->value); 2485 maps* lenvMaps=getMaps(m,"lenv"); 2486 dumpMapsToFile(lenvMaps,flenv,0); 2487 free(flenv); 2488 2489 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 2490 invokeCallback(m,request_input_real_format,NULL,1,0); 2491 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 2398 2492 if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){ 2399 2493 freeService (&s1); … … 2419 2513 return -1; 2420 2514 } 2515 setMapInMaps(m,"lenv","ds_nb","1"); 2421 2516 loadServiceAndRun (&m, s1, request_inputs, 2422 2517 &request_input_real_format, … … 2435 2530 } 2436 2531 2437 //#ifdef DEBUG 2532 #ifdef DEBUG 2533 fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__); 2438 2534 dumpMaps (request_output_real_format); 2439 //#endif2440 //sleep(120); 2535 fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__); 2536 #endif 2441 2537 if (eres != -1) 2442 2538 outputResponse (s1, request_input_real_format, … … 2462 2558 { 2463 2559 fclose (stdout); 2464 fclose (stderr);2465 2560 2466 2561 fclose (f0); … … 2486 2581 #else 2487 2582 recordResponse(m,fbkp1); 2583 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 2584 invokeCallback(m,NULL,request_output_real_format,5,1); 2585 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 2488 2586 #endif 2489 2587 freeMaps(&bmap); … … 2492 2590 unlink (flog); 2493 2591 unhandleStatus (m); 2592 #ifdef META_DB 2593 close_sql(m,0); 2594 //end_sql(); 2595 #endif 2494 2596 free(fbkpid); 2495 2597 free(fbkpres); … … 2499 2601 if(cgiSid!=NULL) 2500 2602 free(cgiSid); 2501 } 2502 2603 //InternetCloseHandle (&hInternet); 2604 fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__); 2605 fflush(stderr); 2606 fclose (stderr); 2607 } 2608 else{ 2609 //InternetCloseHandle (&hInternet); 2610 #ifdef META_DB 2611 //close_sql(m,0); 2612 #endif 2613 } 2614 2503 2615 freeService (&s1); 2504 2616 free (s1); -
branches/prototype-v0/zoo-project/zoo-services/utils/status/service.c
r788 r839 85 85 */ 86 86 char *tmpStr=_getStatus(conf,tmpMap->value); 87 #ifdef DEBUG87 //#ifdef DEBUG 88 88 fprintf(stderr,"DEBUG: %s \n",tmpStr); 89 #endif89 //#endif 90 90 if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){ 91 91 char *tmpStr1=strdup(tmpStr); … … 140 140 char message[10]; 141 141 sprintf(message,"Step %d",i); 142 fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__); 143 fflush(stderr); 142 144 updateStatus(conf,i,message); 143 145 #ifndef WIN32
Note: See TracChangeset
for help on using the changeset viewer.