Index: trunk/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal.c	(revision 577)
+++ trunk/zoo-project/zoo-kernel/service_internal.c	(revision 578)
@@ -37,4 +37,10 @@
 #endif
 
+#ifndef WIN32
+#include <dlfcn.h>
+#endif
+
+#define ERROR_MSG_MAX_LENGTH 1024
+
 int isValidLang(maps* conf,const char *str){
   map *tmpMap=getMapFromMaps(conf,"main","lang");
@@ -152,5 +158,5 @@
 
 #ifdef DEBUG
-      fprintf(stderr,"Semaphore failed to create ! %s\n",GetLastError());
+      fprintf(stderr,"Semaphore failed to create: %s\n", getLastErrorMessage());
 #endif
       return NULL;
@@ -166,5 +172,5 @@
   semid sem_id=getShmLockId(conf,1);
   if (CloseHandle(sem_id) == 0) {
-    fprintf(stderr,"Unable to remove semaphore %s",GetLastError());
+    fprintf(stderr,"Unable to remove semaphore: %s\n", getLastErrorMessage());
     return -1;
   }
@@ -232,5 +238,5 @@
   if (hMapObjectG == NULL){
 #ifdef DEBUG
-    fprintf(stderr,"Unable to create shared memory segment %d !! \n",GetLastError());
+    fprintf(stderr,"Unable to create shared memory segment: %s\n", getLastErrorMessage());
 #endif
     return -2;
@@ -292,5 +298,5 @@
 #ifdef DEBUG
     fprintf(stderr,"ERROR on line %d\n",__LINE__);
-    fprintf(stderr,"READING STRING S %s\n",GetLastError());
+    fprintf(stderr,"READING STRING S %s\n", getLastErrorMessage());
 #endif
     fIgnore = UnmapViewOfFile(lpvMem); 
@@ -309,5 +315,5 @@
 #ifdef DEBUG
     fprintf(stderr,"READING STRING S %d\n",__LINE__);
-    fprintf(stderr,"READING STRING S %s\n",GetLastError());
+    fprintf(stderr,"READING STRING S %s\n", getLastErrorMessage());
 #endif
     return "-1"; 
@@ -3733,2 +3739,39 @@
   }
 }
+
+/* 
+ * The character string returned from getLastErrorMessage resides
+ * in a static buffer. The application should not write to this
+ * buffer or attempt to free() it.
+ */ 
+char* getLastErrorMessage() {                                                                                                                                                    
+#ifdef WIN32	
+	LPVOID lpMsgBuf;
+	DWORD errCode = GetLastError();
+	static char msg[ERROR_MSG_MAX_LENGTH];
+	size_t i;
+
+	DWORD length = FormatMessage(
+					 FORMAT_MESSAGE_ALLOCATE_BUFFER | 
+					 FORMAT_MESSAGE_FROM_SYSTEM |
+					 FORMAT_MESSAGE_IGNORE_INSERTS,
+					 NULL,
+					 errCode,
+					 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+					 (LPTSTR) &lpMsgBuf,
+					 0, NULL );	
+	
+	#ifdef UNICODE		
+		wcstombs_s( &i, msg, ERROR_MSG_MAX_LENGTH,
+					(wchar_t*) lpMsgBuf, _TRUNCATE );
+	#else
+		strcpy_s( msg, ERROR_MSG_MAX_LENGTH,
+	              (char *) lpMsgBuf );		
+	#endif	
+	LocalFree(lpMsgBuf);
+	
+	return msg;
+#else
+	return dlerror();
+#endif
+}
Index: trunk/zoo-project/zoo-kernel/service_internal.h
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal.h	(revision 577)
+++ trunk/zoo-project/zoo-kernel/service_internal.h	(revision 578)
@@ -174,5 +174,6 @@
   char* getInputValue( maps*,const char*,size_t*);
   int  setOutputValue( maps*, const char*, char*, size_t);
-
+  
+  char* getLastErrorMessage();
 #ifdef __cplusplus
 }
Index: trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 577)
+++ trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 578)
@@ -455,6 +455,5 @@
 #endif
 #ifdef WIN32
-      DWORD errstr;
-      errstr = GetLastError ();
+      char* errstr = getLastErrorMessage();
 #else
       char *errstr;
@@ -462,5 +461,5 @@
 #endif
 #ifdef DEBUG
-      fprintf (stderr, "%s loaded (%d) \n", tmps1, errstr);
+	  fprintf (stderr, "%s loaded (%s) \n", tmps1, errstr);
 #endif
       if (so != NULL)
@@ -494,5 +493,5 @@
 #ifdef DEBUG
 #ifdef WIN32
-              errstr = GetLastError ();
+			  errstr = getLastErrorMessage();
 #else
               errstr = dlerror ();
@@ -529,6 +528,6 @@
 #ifdef DEBUG
 #ifdef WIN32
-              errstr = GetLastError ();
-              fprintf (stderr, "Function %s failed to load because of %d\n",
+			  errstr = getLastErrorMessage();
+              fprintf (stderr, "Function %s failed to load because of %s\n",
                        r_inputs->value, errstr);
 #endif
@@ -549,5 +548,5 @@
                 {
 #ifdef WIN32
-                  errstr = GetLastError ();
+				  errstr = getLastErrorMessage();
 #else
                   errstr = dlerror ();
@@ -571,5 +570,5 @@
 #ifdef DEBUG
 #ifdef WIN32
-              errstr = GetLastError ();
+			  errstr = getLastErrorMessage();
 #else
               errstr = dlerror ();
@@ -604,7 +603,7 @@
           char tmps[1024];
 #ifdef WIN32
-          DWORD errstr = GetLastError ();
+		  errstr = getLastErrorMessage();
 #else
-          char *errstr = dlerror ();
+	      errstr = dlerror ();
 #endif
           sprintf (tmps, _("C Library can't be loaded %s"), errstr);
@@ -2843,7 +2842,11 @@
    */
   map* errI=NULL;
+#ifdef DEBUG  
   dumpMaps(request_input_real_format);
+#endif  
   char *dfv = addDefaultValues (&request_input_real_format, s1->inputs, m, 0,&errI);
+#ifdef DEBUG  
   dumpMaps(request_input_real_format);
+#endif  
   maps *ptr = request_input_real_format;
   while (ptr != NULL)
