Changeset 677


Ignore:
Timestamp:
Jun 19, 2015, 4:02:34 PM (9 years ago)
Author:
david
Message:
  • add add zcfg files loading
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  
    3636        gcc -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c ulinet.c
    3737
     38zoo_zcfg.o: zoo_zcfg.c service.h
     39        g++ ${GLIB_CPPFLAGS} ${XML2CFLAGS} -c zoo_zcfg.c
     40
    3841request_parser.o: request_parser.c request_parser.h
    3942        g++ -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c request_parser.c
     
    4649
    4750response_print.o: response_print.c response_print.h
    48         g++ -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c response_print.c
     51        g++ -fPIC ${GDAL_CFLAGS} ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c response_print.c
    4952
    5053server_internal.o: server_internal.c server_internal.h service.h mimetypes.h
     
    9699        gcc -shared  ${GDAL_CFLAGS} ${DEFAULT_OPTS} -fpic -o libzoo_service.${EXT} ${CFLAGS}  service_internal.o service.o sqlapi.o -lfcgi ${GDAL_LIBS}
    97100
    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}
     101zoo_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}
    99102        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}
    101104
    102105zcfg2yaml: 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  
    3535XSLT_CFLAGS=@XSLT_CPPFLAGS@
    3636XSLT_LDFLAGS=@XSLT_LDFLAGS@
     37
     38GLIB_LDFLAGS=@GLIB_LDFLAGS@
     39GLIB_CPPFLAGS=@GLIB_CPPFLAGS@
    3740
    3841GEOS_CFLAGS=@GEOS_CPPFLAGS@
     
    9396SAGA_FILE=@SAGA_FILE@
    9497
    95 CFLAGS=@RELY_ON_DB@ @DEB_DEF@ -fpic ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF
    96 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}
     98CFLAGS=@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
     99LDFLAGS=-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}
    97100
  • branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/configure.ac

    r652 r677  
    99
    1010# 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])
     11AC_CHECK_LIB([curl], [curl_easy_init,curl_easy_setopt,curl_easy_cleanup,curl_easy_perform])
     12AC_CHECK_LIB([dl], [dlopen,dlsym,dlerror,dlclose])
     13AC_CHECK_LIB([crypto], [EVP_DigestInit,EVP_md5,EVP_DigestUpdate,BIO_f_base64,BIO_new])
     14AC_CHECK_LIB([uuid], [uuid_generate_time])
     15
     16DEFAULT_LIBS="$LIBS"
     17AC_SUBST([DEFAULT_LIBS])
     18
    1719
    1820# Checks for header files.
     
    165167AC_SUBST([XML2_LDFLAGS])
    166168LIBS="$LIBS_SAVE"
     169
     170
     171GLIB_LDFLAGS=`pkg-config --libs glib-2.0`
     172GLIB_CPPFLAGS=`pkg-config --cflags glib-2.0`
     173
     174AC_SUBST([GLIB_CPPFLAGS])
     175AC_SUBST([GLIB_LDFLAGS])
     176
     177
    167178
    168179
  • branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/main.cfg

    r539 r677  
    88dataPath = /tmp/
    99cacheDir = /tmp/
     10
    1011
    1112[identification]
  • branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/request_parser.h

    r640 r677  
    3030#include "service.h"
    3131#include "ulinet.h"
    32 
     32#include "cgic.h"
    3333#ifdef __cplusplus
    3434extern "C" {
  • branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/response_print.c

    r666 r677  
    451451            xmlAddChild(nc,nc2);
    452452            nc2 = xmlNewNode(ns_ows, BAD_CAST "ServiceTypeVersion");
    453             dumpMaps(m);
    454453            map* tmpv=getMapFromMaps(m,"main","rversion");
    455454            xmlAddChild(nc2,xmlNewText(BAD_CAST tmpv->value));
     
    690689    map* tmp3=getMapFromMaps(m,"lenv","level");
    691690    addPrefix(m,tmp3,serv);
    692     printDescription(nc1,ns_ows,serv->name,serv->content,vid);
     691    printDescription(nc1,ns_ows,serv->identifier,serv->content,vid);
    693692    tmp1=serv->metadata;
    694693    while(tmp1!=NULL){
     
    781780  tmp1=getMapFromMaps(m,"lenv","level");
    782781  addPrefix(m,tmp1,serv);
    783   printDescription(nc,ns_ows,serv->name,serv->content,vid);
     782  printDescription(nc,ns_ows,serv->identifier,serv->content,vid);
    784783
    785784  tmp1=serv->metadata;
     
    19141913         strcasecmp(tmp->name,"datatype")==0 ||
    19151914         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);
    19191928      tmp=tmp->next;
    1920       xmlAddChild(nc2,nc3);
    19211929    }
    19221930    if(e!=NULL && e->format!=NULL && strcasecmp(e->format,"BoundingBoxData")==0) {
     
    19701978        }
    19711979         
    1972         xmlAddChild(nc3,xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value))));  // base 64 encode in XML
     1980        xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value))));  // base 64 encode in XML
    19731981               
    19741982        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");
    19761984          if (ap != NULL) {
    19771985            xmlRemoveProp(ap);
    19781986          }                     
    1979           xmlNewProp(nc3,BAD_CAST "encoding",BAD_CAST "base64");
     1987          xmlNewProp((vid==0?nc3:nc2),BAD_CAST "encoding",BAD_CAST "base64");
    19801988        }
    19811989               
     
    19901998           strstr(tmp2->value, "ecmascript") != NULL
    19911999           ) {
    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)));
    19932001        }   
    19942002        else {                                                     // else
     
    20022010            xmlDocPtr doc = iDocs[li];
    20032011            xmlNodePtr ir = xmlDocGetRootElement(doc);
    2004             xmlAddChild(nc3,ir);
     2012            xmlAddChild((vid==0?nc3:nc2),ir);
    20052013          }
    20062014          else                                                     // else     
    2007             xmlAddChild(nc3,xmlNewText(BAD_CAST tmp3->value));    //   add text node
     2015            xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value));    //   add text node
    20082016        }
    20092017        xmlAddChild(nc2,nc3);
    20102018      }
    20112019      else {
    2012         xmlAddChild(nc3,xmlNewText(BAD_CAST tmp3->value));
     2020        xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value));
    20132021      }
    20142022         
  • branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/response_print.h

    r654 r677  
    6060 */
    6161#define ZOO_LOCK_RELEASE_FAILED -6
    62 
    6362#include <sys/stat.h>
    6463#include <sys/types.h>
    65 #include "cgic.h"
    6664#ifndef WIN32
    6765#include <sys/ipc.h>
  • branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/service.h

    r640 r677  
    160160 * The memory size to create a service
    161161 */
    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*)
    163163/**
    164164 * The memory size to create a services
     
    238238  typedef struct service{
    239239    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
    240242    struct map* content; //!< the content map
    241243    struct map* metadata; //!< the metadata map
  • branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/service_internal.h

    r654 r677  
    6767#include <sys/stat.h>
    6868#include <sys/types.h>
    69 #include "cgic.h"
    7069#ifndef WIN32
    7170#include <sys/ipc.h>
  • branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/zoo_loader.c

    r658 r677  
    3838#include "service_internal.h"
    3939#include "response_print.h"
    40 
     40#include "zoo_zcfg.h"
    4141
    4242#ifdef WIN32
     
    8989  fflush(stderr);
    9090#endif
    91  
     91
     92
     93  init_services_conf ("/var/www/zoo-wps/cgi-bin","/var/www/zoo-wps/registry/");
     94
     95
    9296  char *strQuery=NULL;
    9397  if(cgiQueryString!=NULL)
     
    115119       }
    116120       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);
    123123       if(res!=NULL)
    124124         free(res);
  • branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/zoo_service_loader.c

    r667 r677  
    4242#include <libxml/xpathInternals.h>
    4343}
    44 
     44#include "zoo_zcfg.h"
    4545#include "ulinet.h"
    4646
     
    184184    }
    185185}
    186 
    187 
    188 /**
    189  * Create the profile registry.
    190  *
    191  * The profile registry is optional (created only if the registry key is
    192  * available in the [main] section of the main.cfg file) and can be used to
    193  * store the profiles hierarchy. The registry is a directory which should
    194  * contain the following sub-directories:
    195  *  * concept: direcotry containing .html files describing concept
    196  *  * generic: directory containing .zcfg files for wps:GenericProcess
    197  *  * implementation: directory containing .zcfg files for wps:Process
    198  *
    199  * @param m the conf maps containing the main.cfg settings
    200  * @param r the registry to update
    201  * @param reg_dir the resgitry
    202  * @param saved_stdout the saved stdout identifier
    203  * @return 0 if the resgitry is null or was correctly updated, -1 on failure
    204  */
    205 int
    206 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                   else
    258                     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 DEBUG
    265               dumpService (s1);
    266               fflush (stdout);
    267               fflush (stderr);
    268 #endif
    269               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 settings
    290  * @param r the registry containing profiles hierarchy
    291  * @param n the root XML Node to add the sub-elements
    292  * @param conf_dir the location of the main.cfg file (basically cwd)
    293  * @param prefix the current prefix if any, or NULL
    294  * @param saved_stdout the saved stdout identifier
    295  * @param level the current level (number of sub-directories to reach the
    296  * current path)
    297  * @see inheritance, readServiceFile
    298  */
    299 int
    300 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       else
    315         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         else
    357           res = -1;
    358         free (tmp);
    359         if (res < 0)
    360           {
    361             return res;
    362           }
    363       }
    364     else
    365       {
    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 DEBUG
    382             fprintf (stderr, "#################\n%s\n#################\n",
    383                      tmps1);
    384 #endif
    385             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                 else
    397                   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 DEBUG
    404             dumpService (s1);
    405             fflush (stdout);
    406             fflush (stderr);
    407 #endif
    408             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 
    419186/**
    420187 * Signal handling function which simply call exit(0).
     
    520287                sprintf (tmps1, "%s/%s", libp->value, r_inputs->value);
    521288         }
    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);
    530293        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
    533297         }
    534298#ifdef DEBUG
     
    620384#endif
    621385#endif
    622               r_inputs = getMapFromMaps (m, "lenv", "Identifier");
    623 #ifdef DEBUG
    624               fprintf (stderr, "Try to load function %s\n", r_inputs->value);
    625 #endif
    626386              typedef int (*execute_t) (maps **, maps **, maps **);
     387
     388              fprintf(stderr,"%s \n",s1->name);
    627389#ifdef WIN32
    628390              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);
    632394#endif
    633395
     
    640402#endif
    641403                  char *tmpMsg =
    642                     (char *) malloc (2048 + strlen (r_inputs->value));
     404                    (char *) malloc (2048 + strlen (s1->name));
    643405                  sprintf (tmpMsg,
    644406                           _
    645407                           ("Error occured while running the %s function: %s"),
    646                            r_inputs->value, errstr);
     408                           s1->name, errstr);
    647409                  errorException (m, tmpMsg, "InternalError", NULL);
    648410                  free (tmpMsg);
    649411#ifdef DEBUG
    650                   fprintf (stderr, "Function %s error %s\n", r_inputs->value,
     412                  fprintf (stderr, "Function %s error %s\n", s1->name,
    651413                           errstr);
    652414#endif
     
    12531015    snprintf (conf_dir, 1024, "%s", ntmp);
    12541016
    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   }
    12631017
    12641018  if (strncasecmp (REQUEST, "GetCapabilities", 15) == 0)
     
    12691023      xmlDocPtr doc = xmlNewDoc (BAD_CAST "1.0");
    12701024      xmlNodePtr n=printGetCapabilitiesHeader(doc,m,(version!=NULL?version->value:"1.0.0"));
     1025      CapabilitiesAllProcess(m,n);
    12711026      /**
    12721027       * Here we need to close stdout to ensure that unsupported chars
    12731028       * has been found in the zcfg and then printed on stdout
    12741029       */
     1030      /*
    12751031      int saved_stdout = dup (fileno (stdout));
    12761032      dup2 (fileno (stderr), fileno (stdout));
     
    12921048      fflush (stdout);
    12931049      dup2 (saved_stdout, fileno (stdout));
     1050      */
    12941051      printDocument (m, doc, getpid ());
    12951052      freeMaps (&m);
    12961053      free (m);
     1054      /*
    12971055      if(zooRegistry!=NULL){
    12981056        freeRegistry(&zooRegistry);
    12991057        free(zooRegistry);
    13001058      }
     1059*/
    13011060      free (REQUEST);
    13021061      free (SERVICE_URL);
     
    13131072          freeMaps (&m);
    13141073          free (m);
    1315           if(zooRegistry!=NULL){
    1316             freeRegistry(&zooRegistry);
    1317             free(zooRegistry);
    1318           }
    13191074          free (REQUEST);
    13201075          free (SERVICE_URL);
     
    13261081            freeMaps (&m);
    13271082            free (m);
    1328             if(zooRegistry!=NULL){
    1329               freeRegistry(&zooRegistry);
    1330               free(zooRegistry);
    1331             }
    13321083            free (REQUEST);
    13331084            free (SERVICE_URL);
     
    13481099            freeMaps (&m);
    13491100            free (m);
    1350             if(zooRegistry!=NULL){
    1351               freeRegistry(&zooRegistry);
    1352               free(zooRegistry);
    1353             }
    13541101            free (REQUEST);
    13551102            free (SERVICE_URL);
     
    13711118            char *orig = zStrdup (r_inputs->value);
    13721119
    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);
    15651121            fflush (stdout);
     1122        int saved_stdout;
    15661123            dup2 (saved_stdout, fileno (stdout));
    15671124            free (orig);
     
    15691126            freeMaps (&m);
    15701127            free (m);
    1571             if(zooRegistry!=NULL){
    1572               freeRegistry(&zooRegistry);
    1573               free(zooRegistry);
    1574             }
    15751128            free (REQUEST);
    15761129            free (SERVICE_URL);
     
    16231176            freeMaps (&m);
    16241177            free (m);
    1625             if(zooRegistry!=NULL){
    1626               freeRegistry(&zooRegistry);
    1627               free(zooRegistry);
    1628             }
    16291178            free (REQUEST);
    16301179            free (SERVICE_URL);
     
    16431192    freeMaps (&m);
    16441193    free (m);
    1645     if(zooRegistry!=NULL){
    1646       freeRegistry(&zooRegistry);
    1647       free(zooRegistry);
    1648     }
    16491194    free (REQUEST);
    16501195    free (SERVICE_URL);
     
    16541199 
    16551200  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 
    16571206  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   else
    1675     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 DEBUG
    1681   fprintf (stderr, "Trying to load %s\n", tmps1);
    1682 #endif
    1683   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   else
    1693     {
    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)
    17101207    {
    17111208      char *tmpMsg = (char *) malloc (2048 + strlen (r_inputs->value));
     
    17161213      errorException (m, tmpMsg, "InvalidParameterValue", "identifier");
    17171214      free (tmpMsg);
    1718       free (s1);
    17191215      freeMaps (&m);
    17201216      free (m);
     
    17581254    free (SERVICE_URL);
    17591255    InternetCloseHandle (&hInternet);
    1760     freeService (&s1);
    1761     free (s1);
    17621256    return 0;
    17631257  }
     
    18411335                        ("The status parameter cannot be set to true if storeExecuteResponse is set to false. Please modify your request parameters."),
    18421336                        "InvalidParameterValue", "storeExecuteResponse");
    1843         freeService (&s1);
     1337        //freeService (&s1);
    18441338        free (s1);
    18451339        freeMaps (&m);
     
    18711365          freeMaps (&m);
    18721366          free (m);
    1873           if(zooRegistry!=NULL){
    1874             freeRegistry(&zooRegistry);
    1875             free(zooRegistry);
    1876           }
    18771367          freeMaps (&request_input_real_format);
    18781368          free (request_input_real_format);
     
    20571547    {
    20581548      if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
    2059         freeService (&s1);
    20601549        free (s1);
    20611550        freeMaps (&m);
     
    22171706
    22181707          if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
    2219             freeService (&s1);
     1708            //freeService (&s1);
    22201709            free (s1);
    22211710            freeMaps (&m);
     
    23311820    }
    23321821
    2333   freeService (&s1);
     1822  //freeService (&s1);
    23341823  free (s1);
    23351824  freeMaps (&m);
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png