Index: branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/Makefile.in
===================================================================
--- branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/Makefile.in	(revision 672)
+++ branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/Makefile.in	(revision 677)
@@ -36,4 +36,7 @@
 	gcc -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c ulinet.c
 
+zoo_zcfg.o: zoo_zcfg.c service.h
+	g++ ${GLIB_CPPFLAGS} ${XML2CFLAGS} -c zoo_zcfg.c
+
 request_parser.o: request_parser.c request_parser.h
 	g++ -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c request_parser.c
@@ -46,5 +49,5 @@
 
 response_print.o: response_print.c response_print.h
-	g++ -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c response_print.c
+	g++ -fPIC ${GDAL_CFLAGS} ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c response_print.c
 
 server_internal.o: server_internal.c server_internal.h service.h mimetypes.h
@@ -96,7 +99,7 @@
 	gcc -shared  ${GDAL_CFLAGS} ${DEFAULT_OPTS} -fpic -o libzoo_service.${EXT} ${CFLAGS}  service_internal.o service.o sqlapi.o -lfcgi ${GDAL_LIBS}
 
-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}
+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}
 	g++ -g -O2 ${JSCFLAGS} ${PHPCFLAGS}  ${PERLCFLAGS} ${RUBYCFLAGS}  ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c  -fno-common -DPIC -o zoo_loader.o
-	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}
+	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}
 
 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}
Index: branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/ZOOMakefile.opts.in
===================================================================
--- branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/ZOOMakefile.opts.in	(revision 672)
+++ branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/ZOOMakefile.opts.in	(revision 677)
@@ -35,4 +35,7 @@
 XSLT_CFLAGS=@XSLT_CPPFLAGS@
 XSLT_LDFLAGS=@XSLT_LDFLAGS@
+
+GLIB_LDFLAGS=@GLIB_LDFLAGS@
+GLIB_CPPFLAGS=@GLIB_CPPFLAGS@
 
 GEOS_CFLAGS=@GEOS_CPPFLAGS@
@@ -93,5 +96,5 @@
 SAGA_FILE=@SAGA_FILE@
 
-CFLAGS=@RELY_ON_DB@ @DEB_DEF@ -fpic ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF
-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}
+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
+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}
 
Index: branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/configure.ac
===================================================================
--- branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/configure.ac	(revision 672)
+++ branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/configure.ac	(revision 677)
@@ -9,10 +9,12 @@
 
 # Checks for libraries.
-AC_CHECK_LIB([cgic], [cgiMain])
-AC_CHECK_LIB([curl], [curl_easy_init curl_easy_setopt curl_easy_cleanup curl_easy_perform])
-AC_CHECK_LIB([dl], [dlopen dlsym dlerror dlclose])
-AC_CHECK_LIB([fl], [main])
-AC_CHECK_LIB([pthread], [main])
-AC_CHECK_LIB([ssl], [main])
+AC_CHECK_LIB([curl], [curl_easy_init,curl_easy_setopt,curl_easy_cleanup,curl_easy_perform])
+AC_CHECK_LIB([dl], [dlopen,dlsym,dlerror,dlclose])
+AC_CHECK_LIB([crypto], [EVP_DigestInit,EVP_md5,EVP_DigestUpdate,BIO_f_base64,BIO_new])
+AC_CHECK_LIB([uuid], [uuid_generate_time])
+
+DEFAULT_LIBS="$LIBS"
+AC_SUBST([DEFAULT_LIBS])
+
 
 # Checks for header files.
@@ -165,4 +167,13 @@
 AC_SUBST([XML2_LDFLAGS])
 LIBS="$LIBS_SAVE"
+
+
+GLIB_LDFLAGS=`pkg-config --libs glib-2.0`
+GLIB_CPPFLAGS=`pkg-config --cflags glib-2.0`
+
+AC_SUBST([GLIB_CPPFLAGS])
+AC_SUBST([GLIB_LDFLAGS])
+
+
 
 
Index: branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/main.cfg
===================================================================
--- branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/main.cfg	(revision 672)
+++ branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/main.cfg	(revision 677)
@@ -8,4 +8,5 @@
 dataPath = /tmp/
 cacheDir = /tmp/
+
 
 [identification]
Index: branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/request_parser.h
===================================================================
--- branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/request_parser.h	(revision 672)
+++ branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/request_parser.h	(revision 677)
@@ -30,5 +30,5 @@
 #include "service.h"
 #include "ulinet.h"
-
+#include "cgic.h"
 #ifdef __cplusplus
 extern "C" {
Index: branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/response_print.c
===================================================================
--- branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/response_print.c	(revision 672)
+++ branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/response_print.c	(revision 677)
@@ -451,5 +451,4 @@
 	    xmlAddChild(nc,nc2);
 	    nc2 = xmlNewNode(ns_ows, BAD_CAST "ServiceTypeVersion");
-	    dumpMaps(m);
 	    map* tmpv=getMapFromMaps(m,"main","rversion");
 	    xmlAddChild(nc2,xmlNewText(BAD_CAST tmpv->value));
@@ -690,5 +689,5 @@
     map* tmp3=getMapFromMaps(m,"lenv","level");
     addPrefix(m,tmp3,serv);
-    printDescription(nc1,ns_ows,serv->name,serv->content,vid);
+    printDescription(nc1,ns_ows,serv->identifier,serv->content,vid);
     tmp1=serv->metadata;
     while(tmp1!=NULL){
@@ -781,5 +780,5 @@
   tmp1=getMapFromMaps(m,"lenv","level");
   addPrefix(m,tmp1,serv);
-  printDescription(nc,ns_ows,serv->name,serv->content,vid);
+  printDescription(nc,ns_ows,serv->identifier,serv->content,vid);
 
   tmp1=serv->metadata;
@@ -1914,9 +1913,18 @@
 	 strcasecmp(tmp->name,"datatype")==0 ||
 	 strcasecmp(tmp->name,"uom")==0) {
-
-	xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
-      }
+	
+	if(vid==0)
+	  xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
+	else{
+	  if(strcasecmp(tmp->name,"datatype")==0)
+	    xmlNewProp(nc2,BAD_CAST "mimeType",BAD_CAST "text/plain");
+	  else
+	    if(strcasecmp(tmp->name,"uom")!=0)
+	      xmlNewProp(nc2,BAD_CAST tmp->name,BAD_CAST tmp->value);
+	}
+      }
+      if(vid==0)
+	xmlAddChild(nc2,nc3);
       tmp=tmp->next;
-      xmlAddChild(nc2,nc3);
     }
     if(e!=NULL && e->format!=NULL && strcasecmp(e->format,"BoundingBoxData")==0) {
@@ -1970,12 +1978,12 @@
 	}
 	 
-	xmlAddChild(nc3,xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value))));  // base 64 encode in XML
+	xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value))));  // base 64 encode in XML
 		
 	if(tmp1==NULL || (tmp1!=NULL && strncmp(tmp1->value,"base64",6)!=0)) {
-	  xmlAttrPtr ap = xmlHasProp(nc3, BAD_CAST "encoding");
+	  xmlAttrPtr ap = xmlHasProp((vid==0?nc3:nc2), BAD_CAST "encoding");
 	  if (ap != NULL) {
 	    xmlRemoveProp(ap);
 	  }			
-	  xmlNewProp(nc3,BAD_CAST "encoding",BAD_CAST "base64");
+	  xmlNewProp((vid==0?nc3:nc2),BAD_CAST "encoding",BAD_CAST "base64");
 	}
 		
@@ -1990,5 +1998,5 @@
 	   strstr(tmp2->value, "ecmascript") != NULL
 	   ) {
-	  xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value)));
+	  xmlAddChild((vid==0?nc3:nc2),xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value)));
 	}   
 	else {                                                     // else
@@ -2002,13 +2010,13 @@
 	    xmlDocPtr doc = iDocs[li];
 	    xmlNodePtr ir = xmlDocGetRootElement(doc);
-	    xmlAddChild(nc3,ir);
+	    xmlAddChild((vid==0?nc3:nc2),ir);
 	  }
 	  else                                                     // else	
-	    xmlAddChild(nc3,xmlNewText(BAD_CAST tmp3->value));    //   add text node
+	    xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value));    //   add text node
 	}
 	xmlAddChild(nc2,nc3);
       }
       else {
-	xmlAddChild(nc3,xmlNewText(BAD_CAST tmp3->value));
+	xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value));
       }
 	  
Index: branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/response_print.h
===================================================================
--- branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/response_print.h	(revision 672)
+++ branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/response_print.h	(revision 677)
@@ -60,8 +60,6 @@
  */
 #define ZOO_LOCK_RELEASE_FAILED -6
-
 #include <sys/stat.h>
 #include <sys/types.h>
-#include "cgic.h"
 #ifndef WIN32
 #include <sys/ipc.h>
Index: branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/service.h
===================================================================
--- branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/service.h	(revision 672)
+++ branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/service.h	(revision 677)
@@ -160,5 +160,5 @@
  * The memory size to create a service
  */
-#define SERVICE_SIZE (ELEMENTS_SIZE*2)+(MAP_SIZE*2)+sizeof(char*)
+#define SERVICE_SIZE (ELEMENTS_SIZE*2)+(MAP_SIZE*2)+sizeof(char*)+sizeof(char*)+sizeof(char*)
 /**
  * The memory size to create a services
@@ -238,4 +238,6 @@
   typedef struct service{
     char* name; //!< the name
+    char* identifier; //!< service identifier Ex:  zcfg = /var/www/zoo/cgi-bin/gdal/ndvi/ExtractNDVI.zcfg  ===>  identifier = gdal.ndvi.ExtractNDVI
+    char * zcfg; // path to zcfg file
     struct map* content; //!< the content map
     struct map* metadata; //!< the metadata map
Index: branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/service_internal.h
===================================================================
--- branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/service_internal.h	(revision 672)
+++ branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/service_internal.h	(revision 677)
@@ -67,5 +67,4 @@
 #include <sys/stat.h>
 #include <sys/types.h>
-#include "cgic.h"
 #ifndef WIN32
 #include <sys/ipc.h>
Index: branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/zoo_loader.c
===================================================================
--- branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/zoo_loader.c	(revision 672)
+++ branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/zoo_loader.c	(revision 677)
@@ -38,5 +38,5 @@
 #include "service_internal.h"
 #include "response_print.h"
-
+#include "zoo_zcfg.h"
 
 #ifdef WIN32
@@ -89,5 +89,9 @@
   fflush(stderr);
 #endif
-  
+
+
+  init_services_conf ("/var/www/zoo-wps/cgi-bin","/var/www/zoo-wps/registry/");
+
+
   char *strQuery=NULL;
   if(cgiQueryString!=NULL)
@@ -115,10 +119,6 @@
        }
        delete[] buffer;
-       if(res==NULL && (strQuery==NULL || strlen(strQuery)==0)){
-	 return errorException(NULL,"ZOO-Kernel failed to process your request because the request was empty.","InternalError",NULL);
-       }else{
-	 if(strQuery==NULL || strlen(strQuery)==0)
-	   tmpMap=createMap("request",res);
-       }
+       if(res!=NULL && (strQuery==NULL || strlen(strQuery)==0))
+	 tmpMap=createMap("request",res);
        if(res!=NULL)
 	 free(res);
Index: branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 672)
+++ branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 677)
@@ -42,5 +42,5 @@
 #include <libxml/xpathInternals.h>
 }
-
+#include "zoo_zcfg.h"
 #include "ulinet.h"
 
@@ -184,237 +184,4 @@
     }
 }
-
-
-/**
- * Create the profile registry.
- *
- * The profile registry is optional (created only if the registry key is
- * available in the [main] section of the main.cfg file) and can be used to
- * store the profiles hierarchy. The registry is a directory which should
- * contain the following sub-directories: 
- *  * concept: direcotry containing .html files describing concept
- *  * generic: directory containing .zcfg files for wps:GenericProcess
- *  * implementation: directory containing .zcfg files for wps:Process
- *
- * @param m the conf maps containing the main.cfg settings
- * @param r the registry to update
- * @param reg_dir the resgitry 
- * @param saved_stdout the saved stdout identifier
- * @return 0 if the resgitry is null or was correctly updated, -1 on failure
- */
-int
-createRegistry (maps* m,registry ** r, char *reg_dir, int saved_stdout)
-{
-  struct dirent *dp;
-  int scount = 0;
-
-  if (reg_dir == NULL)
-    return 0;
-  DIR *dirp = opendir (reg_dir);
-  if (dirp == NULL)
-    {
-      return -1;
-    }
-  while ((dp = readdir (dirp)) != NULL){
-    if ((dp->d_type == DT_DIR || dp->d_type == DT_LNK) && dp->d_name[0] != '.')
-      {
-
-        char * tmpName =
-          (char *) malloc ((strlen (reg_dir) + strlen (dp->d_name) + 2) *
-                           sizeof (char));
-        sprintf (tmpName, "%s/%s", reg_dir, dp->d_name);
-	
-	DIR *dirp1 = opendir (tmpName);
-	struct dirent *dp1;
-	while ((dp1 = readdir (dirp1)) != NULL){
-	  char* extn = strstr(dp1->d_name, ".zcfg");
-	  if(dp1->d_name[0] != '.' && extn != NULL && strlen(extn) == 5)
-	    {
-	      int t;
-	      char *tmps1=
-		(char *) malloc ((strlen (tmpName) + strlen (dp1->d_name) + 2) *
-				 sizeof (char));
-	      sprintf (tmps1, "%s/%s", tmpName, dp1->d_name);
-	      char *tmpsn = zStrdup (dp1->d_name);
-	      tmpsn[strlen (tmpsn) - 5] = 0;
-	      service* s1 = (service *) malloc (SERVICE_SIZE);
-	      if (s1 == NULL)
-		{
-		  dup2 (saved_stdout, fileno (stdout));
-		  errorException (m, _("Unable to allocate memory."),
-				  "InternalError", NULL);
-		  return -1;
-		}
-	      t = readServiceFile (m, tmps1, &s1, tmpsn);
-	      free (tmpsn);
-	      if (t < 0)
-		{
-		  map *tmp00 = getMapFromMaps (m, "lenv", "message");
-		  char tmp01[1024];
-		  if (tmp00 != NULL)
-		    sprintf (tmp01, _("Unable to parse the ZCFG file: %s (%s)"),
-			     dp1->d_name, tmp00->value);
-		  else
-		    sprintf (tmp01, _("Unable to parse the ZCFG file: %s."),
-			     dp1->d_name);
-		  dup2 (saved_stdout, fileno (stdout));
-		  errorException (m, tmp01, "InternalError", NULL);
-		  return -1;
-		}
-#ifdef DEBUG
-	      dumpService (s1);
-	      fflush (stdout);
-	      fflush (stderr);
-#endif
-	      if(strncasecmp(dp->d_name,"implementation",14)==0){
-		inheritance(*r,&s1);
-	      }
-	      addServiceToRegistry(r,dp->d_name,s1);
-	      freeService (&s1);
-	      free (s1);
-	      scount++;
-	    }
-	}
-	(void) closedir (dirp1);
-      }
-  }
-  (void) closedir (dirp);
-  return 0;
-}
-
-/**
- * Recursivelly parse zcfg starting from the ZOO-Kernel cwd.
- * Call the func function given in arguments after parsing the ZCFG file.
- *
- * @param m the conf maps containing the main.cfg settings
- * @param r the registry containing profiles hierarchy
- * @param n the root XML Node to add the sub-elements
- * @param conf_dir the location of the main.cfg file (basically cwd)
- * @param prefix the current prefix if any, or NULL
- * @param saved_stdout the saved stdout identifier
- * @param level the current level (number of sub-directories to reach the
- * current path)
- * @see inheritance, readServiceFile
- */
-int
-recursReaddirF (maps * m, registry *r, xmlNodePtr n, char *conf_dir, char *prefix,
-                int saved_stdout, int level, void (func) (maps *, xmlNodePtr,
-                                                          service *))
-{
-  struct dirent *dp;
-  int scount = 0;
-
-  if (conf_dir == NULL)
-    return 1;
-  DIR *dirp = opendir (conf_dir);
-  if (dirp == NULL)
-    {
-      if (level > 0)
-        return 1;
-      else
-        return -1;
-    }
-  char tmp1[25];
-  sprintf (tmp1, "sprefix_%d", level);
-  char levels[17];
-  sprintf (levels, "%d", level);
-  setMapInMaps (m, "lenv", "level", levels);
-  while ((dp = readdir (dirp)) != NULL)
-    if ((dp->d_type == DT_DIR || dp->d_type == DT_LNK) && dp->d_name[0] != '.'
-        && strstr (dp->d_name, ".") == NULL)
-      {
-
-        char *tmp =
-          (char *) malloc ((strlen (conf_dir) + strlen (dp->d_name) + 2) *
-                           sizeof (char));
-        sprintf (tmp, "%s/%s", conf_dir, dp->d_name);
-
-        if (prefix != NULL)
-          {
-            prefix = NULL;
-          }
-        prefix = (char *) malloc ((strlen (dp->d_name) + 2) * sizeof (char));
-        sprintf (prefix, "%s.", dp->d_name);
-
-        //map* tmpMap=getMapFromMaps(m,"lenv",tmp1);
-
-        int res;
-        if (prefix != NULL)
-          {
-            setMapInMaps (m, "lenv", tmp1, prefix);
-            char levels1[17];
-            sprintf (levels1, "%d", level + 1);
-            setMapInMaps (m, "lenv", "level", levels1);
-            res =
-              recursReaddirF (m, r, n, tmp, prefix, saved_stdout, level + 1,
-                              func);
-            sprintf (levels1, "%d", level);
-            setMapInMaps (m, "lenv", "level", levels1);
-            free (prefix);
-            prefix = NULL;
-          }
-        else
-          res = -1;
-        free (tmp);
-        if (res < 0)
-          {
-            return res;
-          }
-      }
-    else
-      {
-        char* extn = strstr(dp->d_name, ".zcfg");
-        if(dp->d_name[0] != '.' && extn != NULL && strlen(extn) == 5)
-          {
-            int t;
-            char tmps1[1024];
-            memset (tmps1, 0, 1024);
-            snprintf (tmps1, 1024, "%s/%s", conf_dir, dp->d_name);
-            service *s1 = (service *) malloc (SERVICE_SIZE);
-            if (s1 == NULL)
-              {
-                dup2 (saved_stdout, fileno (stdout));
-                errorException (m, _("Unable to allocate memory."),
-                                "InternalError", NULL);
-                return -1;
-              }
-#ifdef DEBUG
-            fprintf (stderr, "#################\n%s\n#################\n",
-                     tmps1);
-#endif
-            char *tmpsn = zStrdup (dp->d_name);
-            tmpsn[strlen (tmpsn) - 5] = 0;
-            t = readServiceFile (m, tmps1, &s1, tmpsn);
-            free (tmpsn);
-            if (t < 0)
-              {
-                map *tmp00 = getMapFromMaps (m, "lenv", "message");
-                char tmp01[1024];
-                if (tmp00 != NULL)
-                  sprintf (tmp01, _("Unable to parse the ZCFG file: %s (%s)"),
-                           dp->d_name, tmp00->value);
-                else
-                  sprintf (tmp01, _("Unable to parse the ZCFG file: %s."),
-                           dp->d_name);
-                dup2 (saved_stdout, fileno (stdout));
-                errorException (m, tmp01, "InternalError", NULL);
-                return -1;
-              }
-#ifdef DEBUG
-            dumpService (s1);
-            fflush (stdout);
-            fflush (stderr);
-#endif
-	    inheritance(r,&s1);
-            func (m, n, s1);
-            freeService (&s1);
-            free (s1);
-            scount++;
-          }
-      }
-  (void) closedir (dirp);
-  return 1;
-}
-
 /**
  * Signal handling function which simply call exit(0).
@@ -520,15 +287,12 @@
 		sprintf (tmps1, "%s/%s", libp->value, r_inputs->value);
 	 }
-     else {	 
-        r_inputs = getMap (request_inputs, "metapath");
-        if (r_inputs != NULL)
-          sprintf (tmps1, "%s/%s", ntmp, r_inputs->value);
-        else
-          sprintf (tmps1, "%s/", ntmp);
-	  
-        char *altPath = zStrdup (tmps1);
+     else {
+        char *tmp_path = (char *) malloc ((strlen (s1->zcfg) + 1) * sizeof (char *));
+        sprintf (tmp_path, "%s", s1->zcfg);
+        char *dir = dirname (tmp_path);
         r_inputs = getMap (s1->content, "ServiceProvider");
-        sprintf (tmps1, "%s/%s", altPath, r_inputs->value);
-        free (altPath);
+        sprintf (tmps1, "%s/%s", dir, r_inputs->value);
+        free (tmp_path);
+
 	 }
 #ifdef DEBUG
@@ -620,14 +384,12 @@
 #endif
 #endif
-              r_inputs = getMapFromMaps (m, "lenv", "Identifier");
-#ifdef DEBUG
-              fprintf (stderr, "Try to load function %s\n", r_inputs->value);
-#endif
               typedef int (*execute_t) (maps **, maps **, maps **);
+
+              fprintf(stderr,"%s \n",s1->name);
 #ifdef WIN32
               execute_t execute =
-                (execute_t) GetProcAddress (so, r_inputs->value);
-#else
-              execute_t execute = (execute_t) dlsym (so, r_inputs->value);
+                (execute_t) GetProcAddress (so, s1->name);
+#else
+              execute_t execute = (execute_t) dlsym (so, s1->name);
 #endif
 
@@ -640,13 +402,13 @@
 #endif
                   char *tmpMsg =
-                    (char *) malloc (2048 + strlen (r_inputs->value));
+                    (char *) malloc (2048 + strlen (s1->name));
                   sprintf (tmpMsg,
                            _
                            ("Error occured while running the %s function: %s"),
-                           r_inputs->value, errstr);
+                           s1->name, errstr);
                   errorException (m, tmpMsg, "InternalError", NULL);
                   free (tmpMsg);
 #ifdef DEBUG
-                  fprintf (stderr, "Function %s error %s\n", r_inputs->value,
+                  fprintf (stderr, "Function %s error %s\n", s1->name,
                            errstr);
 #endif
@@ -1253,12 +1015,4 @@
     snprintf (conf_dir, 1024, "%s", ntmp);
 
-  map* reg = getMapFromMaps (m, "main", "registry");
-  registry* zooRegistry=NULL;
-  if(reg!=NULL){
-    int saved_stdout = dup (fileno (stdout));
-    dup2 (fileno (stderr), fileno (stdout));
-    createRegistry (m,&zooRegistry,reg->value,saved_stdout);
-    dup2 (saved_stdout, fileno (stdout));
-  }
 
   if (strncasecmp (REQUEST, "GetCapabilities", 15) == 0)
@@ -1269,8 +1023,10 @@
       xmlDocPtr doc = xmlNewDoc (BAD_CAST "1.0");
       xmlNodePtr n=printGetCapabilitiesHeader(doc,m,(version!=NULL?version->value:"1.0.0"));
+      CapabilitiesAllProcess(m,n);
       /**
        * Here we need to close stdout to ensure that unsupported chars 
        * has been found in the zcfg and then printed on stdout
        */
+      /*
       int saved_stdout = dup (fileno (stdout));
       dup2 (fileno (stderr), fileno (stdout));
@@ -1292,11 +1048,14 @@
       fflush (stdout);
       dup2 (saved_stdout, fileno (stdout));
+      */
       printDocument (m, doc, getpid ());
       freeMaps (&m);
       free (m);
+      /*
       if(zooRegistry!=NULL){
 	freeRegistry(&zooRegistry);
 	free(zooRegistry);
       }
+*/
       free (REQUEST);
       free (SERVICE_URL);
@@ -1313,8 +1072,4 @@
 	  freeMaps (&m);
 	  free (m);
-	  if(zooRegistry!=NULL){
-	    freeRegistry(&zooRegistry);
-	    free(zooRegistry);
-	  }
 	  free (REQUEST);
 	  free (SERVICE_URL);
@@ -1326,8 +1081,4 @@
 	    freeMaps (&m);
 	    free (m);
-	    if(zooRegistry!=NULL){
-	      freeRegistry(&zooRegistry);
-	      free(zooRegistry);
-	    }
 	    free (REQUEST);
 	    free (SERVICE_URL);
@@ -1348,8 +1099,4 @@
 	    freeMaps (&m);
 	    free (m);
-	    if(zooRegistry!=NULL){
-	      freeRegistry(&zooRegistry);
-	      free(zooRegistry);
-	    }
 	    free (REQUEST);
 	    free (SERVICE_URL);
@@ -1371,197 +1118,7 @@
 	    char *orig = zStrdup (r_inputs->value);
 
-	    int saved_stdout = dup (fileno (stdout));
-	    dup2 (fileno (stderr), fileno (stdout));
-	    if (strcasecmp ("all", orig) == 0)
-	      {
-		if (int res =
-		    recursReaddirF (m, zooRegistry, n, conf_dir, NULL, saved_stdout, 0,
-				    printDescribeProcessForProcess) < 0)
-		  return res;
-	      }
-	    else
-	      {
-		char *saveptr;
-		char *tmps = strtok_r (orig, ",", &saveptr);
-
-		char buff[256];
-		char buff1[1024];
-		while (tmps != NULL)
-		  {
-		    int hasVal = -1;
-		    char *corig = zStrdup (tmps);
-		    if (strstr (corig, ".") != NULL)
-		      {
-
-			parseIdentifier (m, conf_dir, corig, buff1);
-			map *tmpMap = getMapFromMaps (m, "lenv", "metapath");
-			if (tmpMap != NULL)
-			  addToMap (request_inputs, "metapath", tmpMap->value);
-			map *tmpMapI = getMapFromMaps (m, "lenv", "Identifier");
-
-			s1 = (service *) malloc (SERVICE_SIZE);
-			t = readServiceFile (m, buff1, &s1, tmpMapI->value);
-			if (t < 0)
-			  {
-			    map *tmp00 = getMapFromMaps (m, "lenv", "message");
-			    char tmp01[1024];
-			    if (tmp00 != NULL)
-			      sprintf (tmp01,
-				       _
-				       ("Unable to parse the ZCFG file for the following ZOO-Service: %s. Message: %s"),
-				       tmps, tmp00->value);
-			    else
-			      sprintf (tmp01,
-				       _
-				       ("Unable to parse the ZCFG file for the following ZOO-Service: %s."),
-				       tmps);
-			    dup2 (saved_stdout, fileno (stdout));
-			    errorException (m, tmp01, "InvalidParameterValue",
-					    "identifier");
-			    freeMaps (&m);
-			    free (m);
-			    if(zooRegistry!=NULL){
-			      freeRegistry(&zooRegistry);
-			      free(zooRegistry);
-			    }
-			    free (REQUEST);
-			    free (corig);
-			    free (orig);
-			    free (SERVICE_URL);
-			    free (s1);
-			    closedir (dirp);
-			    xmlFreeDoc (doc);
-			    xmlCleanupParser ();
-			    zooXmlCleanupNs ();
-			    return 1;
-			  }
-#ifdef DEBUG
-			dumpService (s1);
-#endif
-			inheritance(zooRegistry,&s1);
-			printDescribeProcessForProcess (m, n, s1);
-			freeService (&s1);
-			free (s1);
-			s1 = NULL;
-			scount++;
-			hasVal = 1;
-			setMapInMaps (m, "lenv", "level", "0");
-		      }
-		    else
-		      {
-			memset (buff, 0, 256);
-			snprintf (buff, 256, "%s.zcfg", corig);
-			memset (buff1, 0, 1024);
-#ifdef DEBUG
-			printf ("\n#######%s\n########\n", buff);
-#endif
-			while ((dp = readdir (dirp)) != NULL)
-			  {
-			    if (strcasecmp (dp->d_name, buff) == 0)
-			      {
-				memset (buff1, 0, 1024);
-				snprintf (buff1, 1024, "%s/%s", conf_dir,
-					  dp->d_name);
-				s1 = (service *) malloc (SERVICE_SIZE);
-				if (s1 == NULL)
-				  {
-				    dup2 (saved_stdout, fileno (stdout));
-				    return errorException (m,
-							   _
-							   ("Unable to allocate memory."),
-							   "InternalError",
-							   NULL);
-				  }
-#ifdef DEBUG
-				printf
-				  ("#################\n(%s) %s\n#################\n",
-				   r_inputs->value, buff1);
-#endif
-				char *tmp0 = zStrdup (dp->d_name);
-				tmp0[strlen (tmp0) - 5] = 0;
-				t = readServiceFile (m, buff1, &s1, tmp0);
-				free (tmp0);
-				if (t < 0)
-				  {
-				    map *tmp00 =
-				      getMapFromMaps (m, "lenv", "message");
-				    char tmp01[1024];
-				    if (tmp00 != NULL)
-				      sprintf (tmp01,
-					       _
-					       ("Unable to parse the ZCFG file: %s (%s)"),
-					       dp->d_name, tmp00->value);
-				    else
-				      sprintf (tmp01,
-					       _
-					       ("Unable to parse the ZCFG file: %s."),
-					       dp->d_name);
-				    dup2 (saved_stdout, fileno (stdout));
-				    errorException (m, tmp01, "InternalError",
-						    NULL);
-				    freeMaps (&m);
-				    free (m);
-				    if(zooRegistry!=NULL){
-				      freeRegistry(&zooRegistry);
-				      free(zooRegistry);
-				    }
-				    free (orig);
-				    free (REQUEST);
-				    closedir (dirp);
-				    xmlFreeDoc (doc);
-				    xmlCleanupParser ();
-				    zooXmlCleanupNs ();
-				    return 1;
-				  }
-#ifdef DEBUG
-				dumpService (s1);
-#endif
-				inheritance(zooRegistry,&s1);
-				printDescribeProcessForProcess (m, n, s1);
-				freeService (&s1);
-				free (s1);
-				s1 = NULL;
-				scount++;
-				hasVal = 1;
-			      }
-			  }
-		      }
-		    if (hasVal < 0)
-		      {
-			map *tmp00 = getMapFromMaps (m, "lenv", "message");
-			char tmp01[1024];
-			if (tmp00 != NULL)
-			  sprintf (tmp01,
-				   _("Unable to parse the ZCFG file: %s (%s)"),
-				   buff, tmp00->value);
-			else
-			  sprintf (tmp01,
-				   _("Unable to parse the ZCFG file: %s."),
-				   buff);
-			dup2 (saved_stdout, fileno (stdout));
-			errorException (m, tmp01, "InvalidParameterValue",
-					"Identifier");
-			freeMaps (&m);
-			free (m);
-			if(zooRegistry!=NULL){
-			  freeRegistry(&zooRegistry);
-			  free(zooRegistry);
-			}
-			free (orig);
-			free (REQUEST);
-			closedir (dirp);
-			xmlFreeDoc (doc);
-			xmlCleanupParser ();
-			zooXmlCleanupNs ();
-			return 1;
-		      }
-		    rewinddir (dirp);
-		    tmps = strtok_r (NULL, ",", &saveptr);
-		    if (corig != NULL)
-		      free (corig);
-		  }
-	      }
-	    closedir (dirp);
+        DescribeProcess(m,n,orig);
 	    fflush (stdout);
+        int saved_stdout;
 	    dup2 (saved_stdout, fileno (stdout));
 	    free (orig);
@@ -1569,8 +1126,4 @@
 	    freeMaps (&m);
 	    free (m);
-	    if(zooRegistry!=NULL){
-	      freeRegistry(&zooRegistry);
-	      free(zooRegistry);
-	    }
 	    free (REQUEST);
 	    free (SERVICE_URL);
@@ -1623,8 +1176,4 @@
 	    freeMaps (&m);
 	    free (m);
-	    if(zooRegistry!=NULL){
-	      freeRegistry(&zooRegistry);
-	      free(zooRegistry);
-	    }
 	    free (REQUEST);
 	    free (SERVICE_URL);
@@ -1643,8 +1192,4 @@
     freeMaps (&m);
     free (m);
-    if(zooRegistry!=NULL){
-      freeRegistry(&zooRegistry);
-      free(zooRegistry);
-    }
     free (REQUEST);
     free (SERVICE_URL);
@@ -1654,58 +1199,10 @@
   
   s1 = NULL;
-  s1 = (service *) malloc (SERVICE_SIZE);
+  r_inputs = getMap (request_inputs, "Identifier");
+  s1 = search_service (r_inputs->value);
+ int saved_stdout = dup (fileno (stdout));
+  
+  
   if (s1 == NULL)
-    {
-      freeMaps (&m);
-      free (m);
-      if(zooRegistry!=NULL){
-	freeRegistry(&zooRegistry);
-	free(zooRegistry);
-      }
-      free (REQUEST);
-      free (SERVICE_URL);
-      return errorException (m, _("Unable to allocate memory."),
-                             "InternalError", NULL);
-    }
-
-  r_inputs = getMap (request_inputs, "MetaPath");
-  if (r_inputs != NULL)
-    snprintf (tmps1, 1024, "%s/%s", ntmp, r_inputs->value);
-  else
-    snprintf (tmps1, 1024, "%s/", ntmp);
-  r_inputs = getMap (request_inputs, "Identifier");
-  char *ttmp = zStrdup (tmps1);
-  snprintf (tmps1, 1024, "%s/%s.zcfg", ttmp, r_inputs->value);
-  free (ttmp);
-#ifdef DEBUG
-  fprintf (stderr, "Trying to load %s\n", tmps1);
-#endif
-  if (strstr (r_inputs->value, ".") != NULL)
-    {
-      char *identifier = zStrdup (r_inputs->value);
-      parseIdentifier (m, conf_dir, identifier, tmps1);
-      map *tmpMap = getMapFromMaps (m, "lenv", "metapath");
-      if (tmpMap != NULL)
-        addToMap (request_inputs, "metapath", tmpMap->value);
-      free (identifier);
-    }
-  else
-    {
-      setMapInMaps (m, "lenv", "Identifier", r_inputs->value);
-      setMapInMaps (m, "lenv", "oIdentifier", r_inputs->value);
-    }
-
-  r_inputs = getMapFromMaps (m, "lenv", "Identifier");
-  int saved_stdout = dup (fileno (stdout));
-  dup2 (fileno (stderr), fileno (stdout));
-  t = readServiceFile (m, tmps1, &s1, r_inputs->value);
-  inheritance(zooRegistry,&s1);
-  if(zooRegistry!=NULL){
-    freeRegistry(&zooRegistry);
-    free(zooRegistry);
-  }
-  fflush (stdout);
-  dup2 (saved_stdout, fileno (stdout));
-  if (t < 0)
     {
       char *tmpMsg = (char *) malloc (2048 + strlen (r_inputs->value));
@@ -1716,5 +1213,4 @@
       errorException (m, tmpMsg, "InvalidParameterValue", "identifier");
       free (tmpMsg);
-      free (s1);
       freeMaps (&m);
       free (m);
@@ -1758,6 +1254,4 @@
     free (SERVICE_URL);
     InternetCloseHandle (&hInternet);
-    freeService (&s1);
-    free (s1);
     return 0;
   }
@@ -1841,5 +1335,5 @@
 			("The status parameter cannot be set to true if storeExecuteResponse is set to false. Please modify your request parameters."),
 			"InvalidParameterValue", "storeExecuteResponse");
-	freeService (&s1);
+	//freeService (&s1);
 	free (s1);
 	freeMaps (&m);
@@ -1871,8 +1365,4 @@
 	  freeMaps (&m);
 	  free (m);
-	  if(zooRegistry!=NULL){
-	    freeRegistry(&zooRegistry);
-	    free(zooRegistry);
-	  }
 	  freeMaps (&request_input_real_format);
 	  free (request_input_real_format);
@@ -2057,5 +1547,4 @@
     {
       if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
-	freeService (&s1);
 	free (s1);
 	freeMaps (&m);
@@ -2217,5 +1706,5 @@
 
 	  if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
-	    freeService (&s1);
+	    //freeService (&s1);
 	    free (s1);
 	    freeMaps (&m);
@@ -2331,5 +1820,5 @@
     }
 
-  freeService (&s1);
+  //freeService (&s1);
   free (s1);
   freeMaps (&m);
