Changeset 578
- Timestamp:
- Feb 12, 2015, 12:35:20 PM (10 years ago)
- Location:
- trunk/zoo-project/zoo-kernel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_internal.c
r577 r578 37 37 #endif 38 38 39 #ifndef WIN32 40 #include <dlfcn.h> 41 #endif 42 43 #define ERROR_MSG_MAX_LENGTH 1024 44 39 45 int isValidLang(maps* conf,const char *str){ 40 46 map *tmpMap=getMapFromMaps(conf,"main","lang"); … … 152 158 153 159 #ifdef DEBUG 154 fprintf(stderr,"Semaphore failed to create ! %s\n",GetLastError());160 fprintf(stderr,"Semaphore failed to create: %s\n", getLastErrorMessage()); 155 161 #endif 156 162 return NULL; … … 166 172 semid sem_id=getShmLockId(conf,1); 167 173 if (CloseHandle(sem_id) == 0) { 168 fprintf(stderr,"Unable to remove semaphore %s",GetLastError());174 fprintf(stderr,"Unable to remove semaphore: %s\n", getLastErrorMessage()); 169 175 return -1; 170 176 } … … 232 238 if (hMapObjectG == NULL){ 233 239 #ifdef DEBUG 234 fprintf(stderr,"Unable to create shared memory segment %d !! \n",GetLastError());240 fprintf(stderr,"Unable to create shared memory segment: %s\n", getLastErrorMessage()); 235 241 #endif 236 242 return -2; … … 292 298 #ifdef DEBUG 293 299 fprintf(stderr,"ERROR on line %d\n",__LINE__); 294 fprintf(stderr,"READING STRING S %s\n", GetLastError());300 fprintf(stderr,"READING STRING S %s\n", getLastErrorMessage()); 295 301 #endif 296 302 fIgnore = UnmapViewOfFile(lpvMem); … … 309 315 #ifdef DEBUG 310 316 fprintf(stderr,"READING STRING S %d\n",__LINE__); 311 fprintf(stderr,"READING STRING S %s\n", GetLastError());317 fprintf(stderr,"READING STRING S %s\n", getLastErrorMessage()); 312 318 #endif 313 319 return "-1"; … … 3733 3739 } 3734 3740 } 3741 3742 /* 3743 * The character string returned from getLastErrorMessage resides 3744 * in a static buffer. The application should not write to this 3745 * buffer or attempt to free() it. 3746 */ 3747 char* getLastErrorMessage() { 3748 #ifdef WIN32 3749 LPVOID lpMsgBuf; 3750 DWORD errCode = GetLastError(); 3751 static char msg[ERROR_MSG_MAX_LENGTH]; 3752 size_t i; 3753 3754 DWORD length = FormatMessage( 3755 FORMAT_MESSAGE_ALLOCATE_BUFFER | 3756 FORMAT_MESSAGE_FROM_SYSTEM | 3757 FORMAT_MESSAGE_IGNORE_INSERTS, 3758 NULL, 3759 errCode, 3760 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 3761 (LPTSTR) &lpMsgBuf, 3762 0, NULL ); 3763 3764 #ifdef UNICODE 3765 wcstombs_s( &i, msg, ERROR_MSG_MAX_LENGTH, 3766 (wchar_t*) lpMsgBuf, _TRUNCATE ); 3767 #else 3768 strcpy_s( msg, ERROR_MSG_MAX_LENGTH, 3769 (char *) lpMsgBuf ); 3770 #endif 3771 LocalFree(lpMsgBuf); 3772 3773 return msg; 3774 #else 3775 return dlerror(); 3776 #endif 3777 } -
trunk/zoo-project/zoo-kernel/service_internal.h
r576 r578 174 174 char* getInputValue( maps*,const char*,size_t*); 175 175 int setOutputValue( maps*, const char*, char*, size_t); 176 176 177 char* getLastErrorMessage(); 177 178 #ifdef __cplusplus 178 179 } -
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r576 r578 455 455 #endif 456 456 #ifdef WIN32 457 DWORD errstr; 458 errstr = GetLastError (); 457 char* errstr = getLastErrorMessage(); 459 458 #else 460 459 char *errstr; … … 462 461 #endif 463 462 #ifdef DEBUG 464 fprintf (stderr, "%s loaded (%d) \n", tmps1, errstr);463 fprintf (stderr, "%s loaded (%s) \n", tmps1, errstr); 465 464 #endif 466 465 if (so != NULL) … … 494 493 #ifdef DEBUG 495 494 #ifdef WIN32 496 errstr = GetLastError();495 errstr = getLastErrorMessage(); 497 496 #else 498 497 errstr = dlerror (); … … 529 528 #ifdef DEBUG 530 529 #ifdef WIN32 531 errstr = GetLastError();532 fprintf (stderr, "Function %s failed to load because of % d\n",530 errstr = getLastErrorMessage(); 531 fprintf (stderr, "Function %s failed to load because of %s\n", 533 532 r_inputs->value, errstr); 534 533 #endif … … 549 548 { 550 549 #ifdef WIN32 551 errstr = GetLastError();550 errstr = getLastErrorMessage(); 552 551 #else 553 552 errstr = dlerror (); … … 571 570 #ifdef DEBUG 572 571 #ifdef WIN32 573 errstr = GetLastError();572 errstr = getLastErrorMessage(); 574 573 #else 575 574 errstr = dlerror (); … … 604 603 char tmps[1024]; 605 604 #ifdef WIN32 606 DWORD errstr = GetLastError();605 errstr = getLastErrorMessage(); 607 606 #else 608 char *errstr = dlerror ();607 errstr = dlerror (); 609 608 #endif 610 609 sprintf (tmps, _("C Library can't be loaded %s"), errstr); … … 2843 2842 */ 2844 2843 map* errI=NULL; 2844 #ifdef DEBUG 2845 2845 dumpMaps(request_input_real_format); 2846 #endif 2846 2847 char *dfv = addDefaultValues (&request_input_real_format, s1->inputs, m, 0,&errI); 2848 #ifdef DEBUG 2847 2849 dumpMaps(request_input_real_format); 2850 #endif 2848 2851 maps *ptr = request_input_real_format; 2849 2852 while (ptr != NULL)
Note: See TracChangeset
for help on using the changeset viewer.