Changeset 578 for trunk/zoo-project/zoo-kernel/service_internal.c
- Timestamp:
- Feb 12, 2015, 12:35:20 PM (9 years ago)
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.