diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2010-05-23 11:45:32 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2010-05-23 11:45:32 +0200 |
commit | 3b381609dddb8f4f9c3668681e4e475501b3f38f (patch) | |
tree | 2860cdf78ed1379d7b402eefa4b0aea2ed505f44 /include | |
parent | cc19486d5cc448647961918ebd73e2aced5eb803 (diff) | |
download | wolfbones-3b381609dddb8f4f9c3668681e4e475501b3f38f.tar.gz wolfbones-3b381609dddb8f4f9c3668681e4e475501b3f38f.tar.bz2 |
removed FormatMessage/Win32 macro from log.h and added a
more portable wolf_system_error_msg in errors module
Diffstat (limited to 'include')
-rw-r--r-- | include/wolf/errors.h | 13 | ||||
-rw-r--r-- | include/wolf/library/loader.h | 2 | ||||
-rw-r--r-- | include/wolf/log/log.h | 28 |
3 files changed, 14 insertions, 29 deletions
diff --git a/include/wolf/errors.h b/include/wolf/errors.h index 96b6e2f..c33d619 100644 --- a/include/wolf/errors.h +++ b/include/wolf/errors.h @@ -60,6 +60,19 @@ typedef enum { */ char *wolf_error_msg( const wolf_error_t error, char *buf, size_t buflen ); +/** + * Converts the last system error into a human readable message. + * On Windows this is done with FormatMessage and GetLastError, on + * Unix with strerror_r and errno. + * + * @param error the error to retrieve the textual representation for + * @param buf the buffer which will hold the error message + * @param buflen the size of the buffer + * + * @returns a pointer to buf for convenience + */ +char *wolf_system_error_msg( char *buf, size_t buflen ); + #ifdef __cplusplus } #endif diff --git a/include/wolf/library/loader.h b/include/wolf/library/loader.h index 437fa1b..b62b350 100644 --- a/include/wolf/library/loader.h +++ b/include/wolf/library/loader.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2010 Andreas Baumann <abaumann@yahoo.com> + Copyright (C) 2008 Andreas Baumann <abaumann@yahoo.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/wolf/log/log.h b/include/wolf/log/log.h index 78e2b63..e8f1878 100644 --- a/include/wolf/log/log.h +++ b/include/wolf/log/log.h @@ -288,34 +288,6 @@ void wolf_log_reopenlogtoeventlog( void ); */ void wolf_log( wolf_log_level_t level, int category_id, int message_id, const char *format, ... ); -#ifdef _WIN32 - -#define WOLF_LOG_GET_LAST_ERROR( last_error, errbuf, errbuf_size ) \ -{ \ - LPVOID wolf_log_errbuf; \ - DWORD wolf_log_buf_size; \ - DWORD wolf_log_res; \ - \ - wolf_log_res = FormatMessage( \ - FORMAT_MESSAGE_ALLOCATE_BUFFER | \ - FORMAT_MESSAGE_FROM_SYSTEM | \ - FORMAT_MESSAGE_IGNORE_INSERTS | \ - FORMAT_MESSAGE_MAX_WIDTH_MASK, \ - NULL, /* message is from system */ \ - last_error, /* there is a message with that id */ \ - 0, /* default language preference */ \ - (LPTSTR)&wolf_log_errbuf,/* buffer allocated internally with LocalAlloc */ \ - 0, /* minimum allocation size */ \ - NULL ); /* no arguments */ \ - \ - if( wolf_log_res == 0 ) { \ - strlcpy( errbuf, _( "No message available" ), errbuf_size ); \ - } \ - \ - strlcpy( errbuf, wolf_log_errbuf, errbuf_size ); \ -} -#endif - #ifdef __cplusplus } #endif |