Index: branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 524)
+++ branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 531)
@@ -38,4 +38,5 @@
 #include <libxml/xpathInternals.h>
 #include "service_zcfg.h"
+#include <libgen.h>
 }
 #include "ulinet.h"
@@ -211,4 +212,5 @@
 }
 
+/**
 int
 recursReaddirF (maps * m, xmlNodePtr n, char *conf_dir, char *prefix,
@@ -334,5 +336,5 @@
   return 1;
 }
-
+**/
 xmlXPathObjectPtr
 extractFromDoc (xmlDocPtr doc, const char *search)
@@ -408,9 +410,4 @@
    */
   map *r_inputs = NULL;
-#ifndef WIN32
-  getcwd (ntmp, 1024);
-#else
-  _getcwd (ntmp, 1024);
-#endif
   r_inputs = getMap (s1->content, "serviceType");
 #ifdef DEBUG
@@ -421,13 +418,11 @@
       && strncasecmp (r_inputs->value, "C", 1) == 0)
     {
-      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);
+      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
       fprintf (stderr, "Trying to load %s\n", tmps1);
@@ -1264,9 +1259,9 @@
       sprintf (tmpMsg,
                _
-               ("The value for <indetifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request."),
+               ("The value for <identifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request."),
                r_inputs->value);
       errorException (m, tmpMsg, "InvalidParameterValue", "identifier");
       free (tmpMsg);
-      free (s1);
+      //free (s1);
       freeMaps (&m);
       free (m);
@@ -1460,5 +1455,5 @@
           InternetCloseHandle (&hInternet);
           //freeService (&s1);
-          free (s1);
+          //free (s1);
           return 0;
         }
@@ -1624,5 +1619,5 @@
                           InternetCloseHandle (&hInternet);
                           //freeService (&s1);
-                          free (s1);
+                          //free (s1);
                           return 0;
                         }
@@ -1646,5 +1641,5 @@
                               InternetCloseHandle (&hInternet);
                               //freeService (&s1);
-                              free (s1);
+                              //free (s1);
                               return 0;
                             }
@@ -1681,5 +1676,5 @@
                               InternetCloseHandle (&hInternet);
                               //freeService (&s1);
-                              free (s1);
+                              //free (s1);
                               return 0;
                             }
@@ -1749,6 +1744,5 @@
                     {
                       xmlChar *val = xmlNodeListGetString (doc,
-                                                           cur2->
-                                                           xmlChildrenNode,
+                                                           cur2->xmlChildrenNode,
                                                            1);
                       if (tmpmaps == NULL)
@@ -1779,6 +1773,5 @@
                     {
                       xmlChar *val = xmlNodeListGetString (doc,
-                                                           cur2->
-                                                           xmlChildrenNode,
+                                                           cur2->xmlChildrenNode,
                                                            1);
                       if (tmpmaps == NULL)
@@ -1866,5 +1859,5 @@
                                           InternetCloseHandle (&hInternet);
                                           //freeService (&s1);
-                                          free (s1);
+                                          //free (s1);
                                           return 0;
                                         }
@@ -2216,5 +2209,6 @@
                             {
                               xmlChar *mv = xmlNodeListGetString (doc,
-                                                                  cur4->xmlChildrenNode,
+                                                                  cur4->
+                                                                  xmlChildrenNode,
                                                                   1);
                               map *ltmp = getMap (tmpmaps->content,
@@ -2262,5 +2256,6 @@
                             {
                               xmlChar *tmp = xmlNodeListGetRawString (doc,
-                                                                      cur4->xmlChildrenNode,
+                                                                      cur4->
+                                                                      xmlChildrenNode,
                                                                       0);
                               addToMap (tmpmaps->content,
@@ -2331,5 +2326,5 @@
                             InternetCloseHandle (&hInternet);
                             //freeService (&s1);
-                            free (s1);
+                            //free (s1);
                             return 0;
                           }
@@ -2429,6 +2424,5 @@
                     {
                       xmlChar *val = xmlNodeListGetString (NULL,
-                                                           cur2->
-                                                           xmlChildrenNode,
+                                                           cur2->xmlChildrenNode,
                                                            1);
                       free (tmpmaps->name);
@@ -2517,6 +2511,5 @@
                       {
                         xmlChar *val = xmlNodeListGetString (doc,
-                                                             cur1->
-                                                             xmlChildrenNode,
+                                                             cur1->xmlChildrenNode,
                                                              1);
                         if (tmpmaps == NULL)
@@ -2578,6 +2571,5 @@
                       {
                         xmlChar *val = xmlNodeListGetString (doc,
-                                                             cur1->
-                                                             xmlChildrenNode,
+                                                             cur1->xmlChildrenNode,
                                                              1);
                         if (tmpmaps == NULL)
@@ -2655,5 +2647,6 @@
                               {
                                 xmlChar *val = xmlNodeListGetString (doc,
-                                                                     cur2->xmlChildrenNode,
+                                                                     cur2->
+                                                                     xmlChildrenNode,
                                                                      1);
                                 if (tmpmaps == NULL)
@@ -2695,5 +2688,6 @@
                               {
                                 xmlChar *val = xmlNodeListGetString (doc,
-                                                                     cur2->xmlChildrenNode,
+                                                                     cur2->
+                                                                     xmlChildrenNode,
                                                                      1);
                                 if (tmpmaps == NULL)
@@ -2797,5 +2791,5 @@
               printExceptionReportResponse (m, tmpe);
               //freeService (&s1);
-              free (s1);
+              //free (s1);
               freeMap (&tmpe);
               free (tmpe);
@@ -3027,5 +3021,5 @@
                       "InvalidParameterValue", "storeExecuteResponse");
       //freeService (&s1);
-      free (s1);
+      //free (s1);
       freeMaps (&m);
       free (m);
@@ -3349,5 +3343,5 @@
 
   //freeService (&s1);
-  free (s1);
+  //free (s1);
   freeMaps (&m);
   free (m);
