- Timestamp:
- Jun 19, 2015, 4:02:34 PM (10 years ago)
- Location:
- branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/Makefile.in
r653 r677 36 36 gcc -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c ulinet.c 37 37 38 zoo_zcfg.o: zoo_zcfg.c service.h 39 g++ ${GLIB_CPPFLAGS} ${XML2CFLAGS} -c zoo_zcfg.c 40 38 41 request_parser.o: request_parser.c request_parser.h 39 42 g++ -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c request_parser.c … … 46 49 47 50 response_print.o: response_print.c response_print.h 48 g++ -fPIC ${ XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c response_print.c51 g++ -fPIC ${GDAL_CFLAGS} ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c response_print.c 49 52 50 53 server_internal.o: server_internal.c server_internal.h service.h mimetypes.h … … 96 99 gcc -shared ${GDAL_CFLAGS} ${DEFAULT_OPTS} -fpic -o libzoo_service.${EXT} ${CFLAGS} service_internal.o service.o sqlapi.o -lfcgi ${GDAL_LIBS} 97 100 98 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}101 zoo_loader.cgi: version.h libzoo_service.${EXT} zoo_loader.c zoo_service_loader.o ulinet.o zoo_zcfg.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} 99 102 g++ -g -O2 ${JSCFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${RUBYCFLAGS} ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c -fno-common -DPIC -o zoo_loader.o 100 g++ ${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} 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}103 g++ ${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} response_print.o server_internal.o caching.o request_parser.o ulinet.o zoo_zcfg.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi -L. ${LDFLAGS} 101 104 102 105 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/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/ZOOMakefile.opts.in
r653 r677 35 35 XSLT_CFLAGS=@XSLT_CPPFLAGS@ 36 36 XSLT_LDFLAGS=@XSLT_LDFLAGS@ 37 38 GLIB_LDFLAGS=@GLIB_LDFLAGS@ 39 GLIB_CPPFLAGS=@GLIB_CPPFLAGS@ 37 40 38 41 GEOS_CFLAGS=@GEOS_CPPFLAGS@ … … 93 96 SAGA_FILE=@SAGA_FILE@ 94 97 95 CFLAGS=@RELY_ON_DB@ @DEB_DEF@ -fpic ${ YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF96 LDFLAGS=-lzoo_service -lcurl -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS} ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lfcgi -lcrypto -luuid ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${MACOS_LD_NET_FLAGS} ${YAML_LDFLAGS} ${OTBLDFLAGS} ${SAGA_LDFLAGS}98 CFLAGS=@RELY_ON_DB@ @DEB_DEF@ -fpic ${GLIB_CPPFLAGS} ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF 99 LDFLAGS=-lzoo_service @DEFAULT_LIBS@ -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${GLIB_LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS} ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lfcgi -lcrypto -luuid ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${MACOS_LD_NET_FLAGS} ${YAML_LDFLAGS} ${OTBLDFLAGS} ${SAGA_LDFLAGS} 97 100 -
branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/configure.ac
r652 r677 9 9 10 10 # Checks for libraries. 11 AC_CHECK_LIB([cgic], [cgiMain]) 12 AC_CHECK_LIB([curl], [curl_easy_init curl_easy_setopt curl_easy_cleanup curl_easy_perform]) 13 AC_CHECK_LIB([dl], [dlopen dlsym dlerror dlclose]) 14 AC_CHECK_LIB([fl], [main]) 15 AC_CHECK_LIB([pthread], [main]) 16 AC_CHECK_LIB([ssl], [main]) 11 AC_CHECK_LIB([curl], [curl_easy_init,curl_easy_setopt,curl_easy_cleanup,curl_easy_perform]) 12 AC_CHECK_LIB([dl], [dlopen,dlsym,dlerror,dlclose]) 13 AC_CHECK_LIB([crypto], [EVP_DigestInit,EVP_md5,EVP_DigestUpdate,BIO_f_base64,BIO_new]) 14 AC_CHECK_LIB([uuid], [uuid_generate_time]) 15 16 DEFAULT_LIBS="$LIBS" 17 AC_SUBST([DEFAULT_LIBS]) 18 17 19 18 20 # Checks for header files. … … 165 167 AC_SUBST([XML2_LDFLAGS]) 166 168 LIBS="$LIBS_SAVE" 169 170 171 GLIB_LDFLAGS=`pkg-config --libs glib-2.0` 172 GLIB_CPPFLAGS=`pkg-config --cflags glib-2.0` 173 174 AC_SUBST([GLIB_CPPFLAGS]) 175 AC_SUBST([GLIB_LDFLAGS]) 176 177 167 178 168 179 -
branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/main.cfg
r539 r677 8 8 dataPath = /tmp/ 9 9 cacheDir = /tmp/ 10 10 11 11 12 [identification] -
branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/request_parser.h
r640 r677 30 30 #include "service.h" 31 31 #include "ulinet.h" 32 32 #include "cgic.h" 33 33 #ifdef __cplusplus 34 34 extern "C" { -
branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/response_print.c
r666 r677 451 451 xmlAddChild(nc,nc2); 452 452 nc2 = xmlNewNode(ns_ows, BAD_CAST "ServiceTypeVersion"); 453 dumpMaps(m);454 453 map* tmpv=getMapFromMaps(m,"main","rversion"); 455 454 xmlAddChild(nc2,xmlNewText(BAD_CAST tmpv->value)); … … 690 689 map* tmp3=getMapFromMaps(m,"lenv","level"); 691 690 addPrefix(m,tmp3,serv); 692 printDescription(nc1,ns_ows,serv-> name,serv->content,vid);691 printDescription(nc1,ns_ows,serv->identifier,serv->content,vid); 693 692 tmp1=serv->metadata; 694 693 while(tmp1!=NULL){ … … 781 780 tmp1=getMapFromMaps(m,"lenv","level"); 782 781 addPrefix(m,tmp1,serv); 783 printDescription(nc,ns_ows,serv-> name,serv->content,vid);782 printDescription(nc,ns_ows,serv->identifier,serv->content,vid); 784 783 785 784 tmp1=serv->metadata; … … 1914 1913 strcasecmp(tmp->name,"datatype")==0 || 1915 1914 strcasecmp(tmp->name,"uom")==0) { 1916 1917 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 1918 } 1915 1916 if(vid==0) 1917 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 1918 else{ 1919 if(strcasecmp(tmp->name,"datatype")==0) 1920 xmlNewProp(nc2,BAD_CAST "mimeType",BAD_CAST "text/plain"); 1921 else 1922 if(strcasecmp(tmp->name,"uom")!=0) 1923 xmlNewProp(nc2,BAD_CAST tmp->name,BAD_CAST tmp->value); 1924 } 1925 } 1926 if(vid==0) 1927 xmlAddChild(nc2,nc3); 1919 1928 tmp=tmp->next; 1920 xmlAddChild(nc2,nc3);1921 1929 } 1922 1930 if(e!=NULL && e->format!=NULL && strcasecmp(e->format,"BoundingBoxData")==0) { … … 1970 1978 } 1971 1979 1972 xmlAddChild( nc3,xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value)))); // base 64 encode in XML1980 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value)))); // base 64 encode in XML 1973 1981 1974 1982 if(tmp1==NULL || (tmp1!=NULL && strncmp(tmp1->value,"base64",6)!=0)) { 1975 xmlAttrPtr ap = xmlHasProp( nc3, BAD_CAST "encoding");1983 xmlAttrPtr ap = xmlHasProp((vid==0?nc3:nc2), BAD_CAST "encoding"); 1976 1984 if (ap != NULL) { 1977 1985 xmlRemoveProp(ap); 1978 1986 } 1979 xmlNewProp( nc3,BAD_CAST "encoding",BAD_CAST "base64");1987 xmlNewProp((vid==0?nc3:nc2),BAD_CAST "encoding",BAD_CAST "base64"); 1980 1988 } 1981 1989 … … 1990 1998 strstr(tmp2->value, "ecmascript") != NULL 1991 1999 ) { 1992 xmlAddChild( nc3,xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value)));2000 xmlAddChild((vid==0?nc3:nc2),xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value))); 1993 2001 } 1994 2002 else { // else … … 2002 2010 xmlDocPtr doc = iDocs[li]; 2003 2011 xmlNodePtr ir = xmlDocGetRootElement(doc); 2004 xmlAddChild( nc3,ir);2012 xmlAddChild((vid==0?nc3:nc2),ir); 2005 2013 } 2006 2014 else // else 2007 xmlAddChild( nc3,xmlNewText(BAD_CAST tmp3->value)); // add text node2015 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value)); // add text node 2008 2016 } 2009 2017 xmlAddChild(nc2,nc3); 2010 2018 } 2011 2019 else { 2012 xmlAddChild( nc3,xmlNewText(BAD_CAST tmp3->value));2020 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value)); 2013 2021 } 2014 2022 -
branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/response_print.h
r654 r677 60 60 */ 61 61 #define ZOO_LOCK_RELEASE_FAILED -6 62 63 62 #include <sys/stat.h> 64 63 #include <sys/types.h> 65 #include "cgic.h"66 64 #ifndef WIN32 67 65 #include <sys/ipc.h> -
branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/service.h
r640 r677 160 160 * The memory size to create a service 161 161 */ 162 #define SERVICE_SIZE (ELEMENTS_SIZE*2)+(MAP_SIZE*2)+sizeof(char*) 162 #define SERVICE_SIZE (ELEMENTS_SIZE*2)+(MAP_SIZE*2)+sizeof(char*)+sizeof(char*)+sizeof(char*) 163 163 /** 164 164 * The memory size to create a services … … 238 238 typedef struct service{ 239 239 char* name; //!< the name 240 char* identifier; //!< service identifier Ex: zcfg = /var/www/zoo/cgi-bin/gdal/ndvi/ExtractNDVI.zcfg ===> identifier = gdal.ndvi.ExtractNDVI 241 char * zcfg; // path to zcfg file 240 242 struct map* content; //!< the content map 241 243 struct map* metadata; //!< the metadata map -
branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/service_internal.h
r654 r677 67 67 #include <sys/stat.h> 68 68 #include <sys/types.h> 69 #include "cgic.h"70 69 #ifndef WIN32 71 70 #include <sys/ipc.h> -
branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/zoo_loader.c
r658 r677 38 38 #include "service_internal.h" 39 39 #include "response_print.h" 40 40 #include "zoo_zcfg.h" 41 41 42 42 #ifdef WIN32 … … 89 89 fflush(stderr); 90 90 #endif 91 91 92 93 init_services_conf ("/var/www/zoo-wps/cgi-bin","/var/www/zoo-wps/registry/"); 94 95 92 96 char *strQuery=NULL; 93 97 if(cgiQueryString!=NULL) … … 115 119 } 116 120 delete[] buffer; 117 if(res==NULL && (strQuery==NULL || strlen(strQuery)==0)){ 118 return errorException(NULL,"ZOO-Kernel failed to process your request because the request was empty.","InternalError",NULL); 119 }else{ 120 if(strQuery==NULL || strlen(strQuery)==0) 121 tmpMap=createMap("request",res); 122 } 121 if(res!=NULL && (strQuery==NULL || strlen(strQuery)==0)) 122 tmpMap=createMap("request",res); 123 123 if(res!=NULL) 124 124 free(res); -
branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/zoo_service_loader.c
r667 r677 42 42 #include <libxml/xpathInternals.h> 43 43 } 44 44 #include "zoo_zcfg.h" 45 45 #include "ulinet.h" 46 46 … … 184 184 } 185 185 } 186 187 188 /**189 * Create the profile registry.190 *191 * The profile registry is optional (created only if the registry key is192 * available in the [main] section of the main.cfg file) and can be used to193 * store the profiles hierarchy. The registry is a directory which should194 * contain the following sub-directories:195 * * concept: direcotry containing .html files describing concept196 * * generic: directory containing .zcfg files for wps:GenericProcess197 * * implementation: directory containing .zcfg files for wps:Process198 *199 * @param m the conf maps containing the main.cfg settings200 * @param r the registry to update201 * @param reg_dir the resgitry202 * @param saved_stdout the saved stdout identifier203 * @return 0 if the resgitry is null or was correctly updated, -1 on failure204 */205 int206 createRegistry (maps* m,registry ** r, char *reg_dir, int saved_stdout)207 {208 struct dirent *dp;209 int scount = 0;210 211 if (reg_dir == NULL)212 return 0;213 DIR *dirp = opendir (reg_dir);214 if (dirp == NULL)215 {216 return -1;217 }218 while ((dp = readdir (dirp)) != NULL){219 if ((dp->d_type == DT_DIR || dp->d_type == DT_LNK) && dp->d_name[0] != '.')220 {221 222 char * tmpName =223 (char *) malloc ((strlen (reg_dir) + strlen (dp->d_name) + 2) *224 sizeof (char));225 sprintf (tmpName, "%s/%s", reg_dir, dp->d_name);226 227 DIR *dirp1 = opendir (tmpName);228 struct dirent *dp1;229 while ((dp1 = readdir (dirp1)) != NULL){230 char* extn = strstr(dp1->d_name, ".zcfg");231 if(dp1->d_name[0] != '.' && extn != NULL && strlen(extn) == 5)232 {233 int t;234 char *tmps1=235 (char *) malloc ((strlen (tmpName) + strlen (dp1->d_name) + 2) *236 sizeof (char));237 sprintf (tmps1, "%s/%s", tmpName, dp1->d_name);238 char *tmpsn = zStrdup (dp1->d_name);239 tmpsn[strlen (tmpsn) - 5] = 0;240 service* s1 = (service *) malloc (SERVICE_SIZE);241 if (s1 == NULL)242 {243 dup2 (saved_stdout, fileno (stdout));244 errorException (m, _("Unable to allocate memory."),245 "InternalError", NULL);246 return -1;247 }248 t = readServiceFile (m, tmps1, &s1, tmpsn);249 free (tmpsn);250 if (t < 0)251 {252 map *tmp00 = getMapFromMaps (m, "lenv", "message");253 char tmp01[1024];254 if (tmp00 != NULL)255 sprintf (tmp01, _("Unable to parse the ZCFG file: %s (%s)"),256 dp1->d_name, tmp00->value);257 else258 sprintf (tmp01, _("Unable to parse the ZCFG file: %s."),259 dp1->d_name);260 dup2 (saved_stdout, fileno (stdout));261 errorException (m, tmp01, "InternalError", NULL);262 return -1;263 }264 #ifdef DEBUG265 dumpService (s1);266 fflush (stdout);267 fflush (stderr);268 #endif269 if(strncasecmp(dp->d_name,"implementation",14)==0){270 inheritance(*r,&s1);271 }272 addServiceToRegistry(r,dp->d_name,s1);273 freeService (&s1);274 free (s1);275 scount++;276 }277 }278 (void) closedir (dirp1);279 }280 }281 (void) closedir (dirp);282 return 0;283 }284 285 /**286 * Recursivelly parse zcfg starting from the ZOO-Kernel cwd.287 * Call the func function given in arguments after parsing the ZCFG file.288 *289 * @param m the conf maps containing the main.cfg settings290 * @param r the registry containing profiles hierarchy291 * @param n the root XML Node to add the sub-elements292 * @param conf_dir the location of the main.cfg file (basically cwd)293 * @param prefix the current prefix if any, or NULL294 * @param saved_stdout the saved stdout identifier295 * @param level the current level (number of sub-directories to reach the296 * current path)297 * @see inheritance, readServiceFile298 */299 int300 recursReaddirF (maps * m, registry *r, xmlNodePtr n, char *conf_dir, char *prefix,301 int saved_stdout, int level, void (func) (maps *, xmlNodePtr,302 service *))303 {304 struct dirent *dp;305 int scount = 0;306 307 if (conf_dir == NULL)308 return 1;309 DIR *dirp = opendir (conf_dir);310 if (dirp == NULL)311 {312 if (level > 0)313 return 1;314 else315 return -1;316 }317 char tmp1[25];318 sprintf (tmp1, "sprefix_%d", level);319 char levels[17];320 sprintf (levels, "%d", level);321 setMapInMaps (m, "lenv", "level", levels);322 while ((dp = readdir (dirp)) != NULL)323 if ((dp->d_type == DT_DIR || dp->d_type == DT_LNK) && dp->d_name[0] != '.'324 && strstr (dp->d_name, ".") == NULL)325 {326 327 char *tmp =328 (char *) malloc ((strlen (conf_dir) + strlen (dp->d_name) + 2) *329 sizeof (char));330 sprintf (tmp, "%s/%s", conf_dir, dp->d_name);331 332 if (prefix != NULL)333 {334 prefix = NULL;335 }336 prefix = (char *) malloc ((strlen (dp->d_name) + 2) * sizeof (char));337 sprintf (prefix, "%s.", dp->d_name);338 339 //map* tmpMap=getMapFromMaps(m,"lenv",tmp1);340 341 int res;342 if (prefix != NULL)343 {344 setMapInMaps (m, "lenv", tmp1, prefix);345 char levels1[17];346 sprintf (levels1, "%d", level + 1);347 setMapInMaps (m, "lenv", "level", levels1);348 res =349 recursReaddirF (m, r, n, tmp, prefix, saved_stdout, level + 1,350 func);351 sprintf (levels1, "%d", level);352 setMapInMaps (m, "lenv", "level", levels1);353 free (prefix);354 prefix = NULL;355 }356 else357 res = -1;358 free (tmp);359 if (res < 0)360 {361 return res;362 }363 }364 else365 {366 char* extn = strstr(dp->d_name, ".zcfg");367 if(dp->d_name[0] != '.' && extn != NULL && strlen(extn) == 5)368 {369 int t;370 char tmps1[1024];371 memset (tmps1, 0, 1024);372 snprintf (tmps1, 1024, "%s/%s", conf_dir, dp->d_name);373 service *s1 = (service *) malloc (SERVICE_SIZE);374 if (s1 == NULL)375 {376 dup2 (saved_stdout, fileno (stdout));377 errorException (m, _("Unable to allocate memory."),378 "InternalError", NULL);379 return -1;380 }381 #ifdef DEBUG382 fprintf (stderr, "#################\n%s\n#################\n",383 tmps1);384 #endif385 char *tmpsn = zStrdup (dp->d_name);386 tmpsn[strlen (tmpsn) - 5] = 0;387 t = readServiceFile (m, tmps1, &s1, tmpsn);388 free (tmpsn);389 if (t < 0)390 {391 map *tmp00 = getMapFromMaps (m, "lenv", "message");392 char tmp01[1024];393 if (tmp00 != NULL)394 sprintf (tmp01, _("Unable to parse the ZCFG file: %s (%s)"),395 dp->d_name, tmp00->value);396 else397 sprintf (tmp01, _("Unable to parse the ZCFG file: %s."),398 dp->d_name);399 dup2 (saved_stdout, fileno (stdout));400 errorException (m, tmp01, "InternalError", NULL);401 return -1;402 }403 #ifdef DEBUG404 dumpService (s1);405 fflush (stdout);406 fflush (stderr);407 #endif408 inheritance(r,&s1);409 func (m, n, s1);410 freeService (&s1);411 free (s1);412 scount++;413 }414 }415 (void) closedir (dirp);416 return 1;417 }418 419 186 /** 420 187 * Signal handling function which simply call exit(0). … … 520 287 sprintf (tmps1, "%s/%s", libp->value, r_inputs->value); 521 288 } 522 else { 523 r_inputs = getMap (request_inputs, "metapath"); 524 if (r_inputs != NULL) 525 sprintf (tmps1, "%s/%s", ntmp, r_inputs->value); 526 else 527 sprintf (tmps1, "%s/", ntmp); 528 529 char *altPath = zStrdup (tmps1); 289 else { 290 char *tmp_path = (char *) malloc ((strlen (s1->zcfg) + 1) * sizeof (char *)); 291 sprintf (tmp_path, "%s", s1->zcfg); 292 char *dir = dirname (tmp_path); 530 293 r_inputs = getMap (s1->content, "ServiceProvider"); 531 sprintf (tmps1, "%s/%s", altPath, r_inputs->value); 532 free (altPath); 294 sprintf (tmps1, "%s/%s", dir, r_inputs->value); 295 free (tmp_path); 296 533 297 } 534 298 #ifdef DEBUG … … 620 384 #endif 621 385 #endif 622 r_inputs = getMapFromMaps (m, "lenv", "Identifier");623 #ifdef DEBUG624 fprintf (stderr, "Try to load function %s\n", r_inputs->value);625 #endif626 386 typedef int (*execute_t) (maps **, maps **, maps **); 387 388 fprintf(stderr,"%s \n",s1->name); 627 389 #ifdef WIN32 628 390 execute_t execute = 629 (execute_t) GetProcAddress (so, r_inputs->value);630 #else 631 execute_t execute = (execute_t) dlsym (so, r_inputs->value);391 (execute_t) GetProcAddress (so, s1->name); 392 #else 393 execute_t execute = (execute_t) dlsym (so, s1->name); 632 394 #endif 633 395 … … 640 402 #endif 641 403 char *tmpMsg = 642 (char *) malloc (2048 + strlen ( r_inputs->value));404 (char *) malloc (2048 + strlen (s1->name)); 643 405 sprintf (tmpMsg, 644 406 _ 645 407 ("Error occured while running the %s function: %s"), 646 r_inputs->value, errstr);408 s1->name, errstr); 647 409 errorException (m, tmpMsg, "InternalError", NULL); 648 410 free (tmpMsg); 649 411 #ifdef DEBUG 650 fprintf (stderr, "Function %s error %s\n", r_inputs->value,412 fprintf (stderr, "Function %s error %s\n", s1->name, 651 413 errstr); 652 414 #endif … … 1253 1015 snprintf (conf_dir, 1024, "%s", ntmp); 1254 1016 1255 map* reg = getMapFromMaps (m, "main", "registry");1256 registry* zooRegistry=NULL;1257 if(reg!=NULL){1258 int saved_stdout = dup (fileno (stdout));1259 dup2 (fileno (stderr), fileno (stdout));1260 createRegistry (m,&zooRegistry,reg->value,saved_stdout);1261 dup2 (saved_stdout, fileno (stdout));1262 }1263 1017 1264 1018 if (strncasecmp (REQUEST, "GetCapabilities", 15) == 0) … … 1269 1023 xmlDocPtr doc = xmlNewDoc (BAD_CAST "1.0"); 1270 1024 xmlNodePtr n=printGetCapabilitiesHeader(doc,m,(version!=NULL?version->value:"1.0.0")); 1025 CapabilitiesAllProcess(m,n); 1271 1026 /** 1272 1027 * Here we need to close stdout to ensure that unsupported chars 1273 1028 * has been found in the zcfg and then printed on stdout 1274 1029 */ 1030 /* 1275 1031 int saved_stdout = dup (fileno (stdout)); 1276 1032 dup2 (fileno (stderr), fileno (stdout)); … … 1292 1048 fflush (stdout); 1293 1049 dup2 (saved_stdout, fileno (stdout)); 1050 */ 1294 1051 printDocument (m, doc, getpid ()); 1295 1052 freeMaps (&m); 1296 1053 free (m); 1054 /* 1297 1055 if(zooRegistry!=NULL){ 1298 1056 freeRegistry(&zooRegistry); 1299 1057 free(zooRegistry); 1300 1058 } 1059 */ 1301 1060 free (REQUEST); 1302 1061 free (SERVICE_URL); … … 1313 1072 freeMaps (&m); 1314 1073 free (m); 1315 if(zooRegistry!=NULL){1316 freeRegistry(&zooRegistry);1317 free(zooRegistry);1318 }1319 1074 free (REQUEST); 1320 1075 free (SERVICE_URL); … … 1326 1081 freeMaps (&m); 1327 1082 free (m); 1328 if(zooRegistry!=NULL){1329 freeRegistry(&zooRegistry);1330 free(zooRegistry);1331 }1332 1083 free (REQUEST); 1333 1084 free (SERVICE_URL); … … 1348 1099 freeMaps (&m); 1349 1100 free (m); 1350 if(zooRegistry!=NULL){1351 freeRegistry(&zooRegistry);1352 free(zooRegistry);1353 }1354 1101 free (REQUEST); 1355 1102 free (SERVICE_URL); … … 1371 1118 char *orig = zStrdup (r_inputs->value); 1372 1119 1373 int saved_stdout = dup (fileno (stdout)); 1374 dup2 (fileno (stderr), fileno (stdout)); 1375 if (strcasecmp ("all", orig) == 0) 1376 { 1377 if (int res = 1378 recursReaddirF (m, zooRegistry, n, conf_dir, NULL, saved_stdout, 0, 1379 printDescribeProcessForProcess) < 0) 1380 return res; 1381 } 1382 else 1383 { 1384 char *saveptr; 1385 char *tmps = strtok_r (orig, ",", &saveptr); 1386 1387 char buff[256]; 1388 char buff1[1024]; 1389 while (tmps != NULL) 1390 { 1391 int hasVal = -1; 1392 char *corig = zStrdup (tmps); 1393 if (strstr (corig, ".") != NULL) 1394 { 1395 1396 parseIdentifier (m, conf_dir, corig, buff1); 1397 map *tmpMap = getMapFromMaps (m, "lenv", "metapath"); 1398 if (tmpMap != NULL) 1399 addToMap (request_inputs, "metapath", tmpMap->value); 1400 map *tmpMapI = getMapFromMaps (m, "lenv", "Identifier"); 1401 1402 s1 = (service *) malloc (SERVICE_SIZE); 1403 t = readServiceFile (m, buff1, &s1, tmpMapI->value); 1404 if (t < 0) 1405 { 1406 map *tmp00 = getMapFromMaps (m, "lenv", "message"); 1407 char tmp01[1024]; 1408 if (tmp00 != NULL) 1409 sprintf (tmp01, 1410 _ 1411 ("Unable to parse the ZCFG file for the following ZOO-Service: %s. Message: %s"), 1412 tmps, tmp00->value); 1413 else 1414 sprintf (tmp01, 1415 _ 1416 ("Unable to parse the ZCFG file for the following ZOO-Service: %s."), 1417 tmps); 1418 dup2 (saved_stdout, fileno (stdout)); 1419 errorException (m, tmp01, "InvalidParameterValue", 1420 "identifier"); 1421 freeMaps (&m); 1422 free (m); 1423 if(zooRegistry!=NULL){ 1424 freeRegistry(&zooRegistry); 1425 free(zooRegistry); 1426 } 1427 free (REQUEST); 1428 free (corig); 1429 free (orig); 1430 free (SERVICE_URL); 1431 free (s1); 1432 closedir (dirp); 1433 xmlFreeDoc (doc); 1434 xmlCleanupParser (); 1435 zooXmlCleanupNs (); 1436 return 1; 1437 } 1438 #ifdef DEBUG 1439 dumpService (s1); 1440 #endif 1441 inheritance(zooRegistry,&s1); 1442 printDescribeProcessForProcess (m, n, s1); 1443 freeService (&s1); 1444 free (s1); 1445 s1 = NULL; 1446 scount++; 1447 hasVal = 1; 1448 setMapInMaps (m, "lenv", "level", "0"); 1449 } 1450 else 1451 { 1452 memset (buff, 0, 256); 1453 snprintf (buff, 256, "%s.zcfg", corig); 1454 memset (buff1, 0, 1024); 1455 #ifdef DEBUG 1456 printf ("\n#######%s\n########\n", buff); 1457 #endif 1458 while ((dp = readdir (dirp)) != NULL) 1459 { 1460 if (strcasecmp (dp->d_name, buff) == 0) 1461 { 1462 memset (buff1, 0, 1024); 1463 snprintf (buff1, 1024, "%s/%s", conf_dir, 1464 dp->d_name); 1465 s1 = (service *) malloc (SERVICE_SIZE); 1466 if (s1 == NULL) 1467 { 1468 dup2 (saved_stdout, fileno (stdout)); 1469 return errorException (m, 1470 _ 1471 ("Unable to allocate memory."), 1472 "InternalError", 1473 NULL); 1474 } 1475 #ifdef DEBUG 1476 printf 1477 ("#################\n(%s) %s\n#################\n", 1478 r_inputs->value, buff1); 1479 #endif 1480 char *tmp0 = zStrdup (dp->d_name); 1481 tmp0[strlen (tmp0) - 5] = 0; 1482 t = readServiceFile (m, buff1, &s1, tmp0); 1483 free (tmp0); 1484 if (t < 0) 1485 { 1486 map *tmp00 = 1487 getMapFromMaps (m, "lenv", "message"); 1488 char tmp01[1024]; 1489 if (tmp00 != NULL) 1490 sprintf (tmp01, 1491 _ 1492 ("Unable to parse the ZCFG file: %s (%s)"), 1493 dp->d_name, tmp00->value); 1494 else 1495 sprintf (tmp01, 1496 _ 1497 ("Unable to parse the ZCFG file: %s."), 1498 dp->d_name); 1499 dup2 (saved_stdout, fileno (stdout)); 1500 errorException (m, tmp01, "InternalError", 1501 NULL); 1502 freeMaps (&m); 1503 free (m); 1504 if(zooRegistry!=NULL){ 1505 freeRegistry(&zooRegistry); 1506 free(zooRegistry); 1507 } 1508 free (orig); 1509 free (REQUEST); 1510 closedir (dirp); 1511 xmlFreeDoc (doc); 1512 xmlCleanupParser (); 1513 zooXmlCleanupNs (); 1514 return 1; 1515 } 1516 #ifdef DEBUG 1517 dumpService (s1); 1518 #endif 1519 inheritance(zooRegistry,&s1); 1520 printDescribeProcessForProcess (m, n, s1); 1521 freeService (&s1); 1522 free (s1); 1523 s1 = NULL; 1524 scount++; 1525 hasVal = 1; 1526 } 1527 } 1528 } 1529 if (hasVal < 0) 1530 { 1531 map *tmp00 = getMapFromMaps (m, "lenv", "message"); 1532 char tmp01[1024]; 1533 if (tmp00 != NULL) 1534 sprintf (tmp01, 1535 _("Unable to parse the ZCFG file: %s (%s)"), 1536 buff, tmp00->value); 1537 else 1538 sprintf (tmp01, 1539 _("Unable to parse the ZCFG file: %s."), 1540 buff); 1541 dup2 (saved_stdout, fileno (stdout)); 1542 errorException (m, tmp01, "InvalidParameterValue", 1543 "Identifier"); 1544 freeMaps (&m); 1545 free (m); 1546 if(zooRegistry!=NULL){ 1547 freeRegistry(&zooRegistry); 1548 free(zooRegistry); 1549 } 1550 free (orig); 1551 free (REQUEST); 1552 closedir (dirp); 1553 xmlFreeDoc (doc); 1554 xmlCleanupParser (); 1555 zooXmlCleanupNs (); 1556 return 1; 1557 } 1558 rewinddir (dirp); 1559 tmps = strtok_r (NULL, ",", &saveptr); 1560 if (corig != NULL) 1561 free (corig); 1562 } 1563 } 1564 closedir (dirp); 1120 DescribeProcess(m,n,orig); 1565 1121 fflush (stdout); 1122 int saved_stdout; 1566 1123 dup2 (saved_stdout, fileno (stdout)); 1567 1124 free (orig); … … 1569 1126 freeMaps (&m); 1570 1127 free (m); 1571 if(zooRegistry!=NULL){1572 freeRegistry(&zooRegistry);1573 free(zooRegistry);1574 }1575 1128 free (REQUEST); 1576 1129 free (SERVICE_URL); … … 1623 1176 freeMaps (&m); 1624 1177 free (m); 1625 if(zooRegistry!=NULL){1626 freeRegistry(&zooRegistry);1627 free(zooRegistry);1628 }1629 1178 free (REQUEST); 1630 1179 free (SERVICE_URL); … … 1643 1192 freeMaps (&m); 1644 1193 free (m); 1645 if(zooRegistry!=NULL){1646 freeRegistry(&zooRegistry);1647 free(zooRegistry);1648 }1649 1194 free (REQUEST); 1650 1195 free (SERVICE_URL); … … 1654 1199 1655 1200 s1 = NULL; 1656 s1 = (service *) malloc (SERVICE_SIZE); 1201 r_inputs = getMap (request_inputs, "Identifier"); 1202 s1 = search_service (r_inputs->value); 1203 int saved_stdout = dup (fileno (stdout)); 1204 1205 1657 1206 if (s1 == NULL) 1658 {1659 freeMaps (&m);1660 free (m);1661 if(zooRegistry!=NULL){1662 freeRegistry(&zooRegistry);1663 free(zooRegistry);1664 }1665 free (REQUEST);1666 free (SERVICE_URL);1667 return errorException (m, _("Unable to allocate memory."),1668 "InternalError", NULL);1669 }1670 1671 r_inputs = getMap (request_inputs, "MetaPath");1672 if (r_inputs != NULL)1673 snprintf (tmps1, 1024, "%s/%s", ntmp, r_inputs->value);1674 else1675 snprintf (tmps1, 1024, "%s/", ntmp);1676 r_inputs = getMap (request_inputs, "Identifier");1677 char *ttmp = zStrdup (tmps1);1678 snprintf (tmps1, 1024, "%s/%s.zcfg", ttmp, r_inputs->value);1679 free (ttmp);1680 #ifdef DEBUG1681 fprintf (stderr, "Trying to load %s\n", tmps1);1682 #endif1683 if (strstr (r_inputs->value, ".") != NULL)1684 {1685 char *identifier = zStrdup (r_inputs->value);1686 parseIdentifier (m, conf_dir, identifier, tmps1);1687 map *tmpMap = getMapFromMaps (m, "lenv", "metapath");1688 if (tmpMap != NULL)1689 addToMap (request_inputs, "metapath", tmpMap->value);1690 free (identifier);1691 }1692 else1693 {1694 setMapInMaps (m, "lenv", "Identifier", r_inputs->value);1695 setMapInMaps (m, "lenv", "oIdentifier", r_inputs->value);1696 }1697 1698 r_inputs = getMapFromMaps (m, "lenv", "Identifier");1699 int saved_stdout = dup (fileno (stdout));1700 dup2 (fileno (stderr), fileno (stdout));1701 t = readServiceFile (m, tmps1, &s1, r_inputs->value);1702 inheritance(zooRegistry,&s1);1703 if(zooRegistry!=NULL){1704 freeRegistry(&zooRegistry);1705 free(zooRegistry);1706 }1707 fflush (stdout);1708 dup2 (saved_stdout, fileno (stdout));1709 if (t < 0)1710 1207 { 1711 1208 char *tmpMsg = (char *) malloc (2048 + strlen (r_inputs->value)); … … 1716 1213 errorException (m, tmpMsg, "InvalidParameterValue", "identifier"); 1717 1214 free (tmpMsg); 1718 free (s1);1719 1215 freeMaps (&m); 1720 1216 free (m); … … 1758 1254 free (SERVICE_URL); 1759 1255 InternetCloseHandle (&hInternet); 1760 freeService (&s1);1761 free (s1);1762 1256 return 0; 1763 1257 } … … 1841 1335 ("The status parameter cannot be set to true if storeExecuteResponse is set to false. Please modify your request parameters."), 1842 1336 "InvalidParameterValue", "storeExecuteResponse"); 1843 freeService (&s1);1337 //freeService (&s1); 1844 1338 free (s1); 1845 1339 freeMaps (&m); … … 1871 1365 freeMaps (&m); 1872 1366 free (m); 1873 if(zooRegistry!=NULL){1874 freeRegistry(&zooRegistry);1875 free(zooRegistry);1876 }1877 1367 freeMaps (&request_input_real_format); 1878 1368 free (request_input_real_format); … … 2057 1547 { 2058 1548 if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){ 2059 freeService (&s1);2060 1549 free (s1); 2061 1550 freeMaps (&m); … … 2217 1706 2218 1707 if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){ 2219 freeService (&s1);1708 //freeService (&s1); 2220 1709 free (s1); 2221 1710 freeMaps (&m); … … 2331 1820 } 2332 1821 2333 freeService (&s1);1822 //freeService (&s1); 2334 1823 free (s1); 2335 1824 freeMaps (&m);
Note: See TracChangeset
for help on using the changeset viewer.