mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
move logLastError
This commit is contained in:
parent
dfd61caf25
commit
783b3a2860
3 changed files with 38 additions and 37 deletions
|
@ -101,4 +101,39 @@ logRect( const char* comment, const RECT* rect )
|
|||
|
||||
#undef CASE_STR
|
||||
|
||||
void
|
||||
logLastError( const char* comment )
|
||||
{
|
||||
LPVOID lpMsgBuf;
|
||||
DWORD lastErr = GetLastError();
|
||||
XP_UCHAR msg[256];
|
||||
XP_U16 len;
|
||||
XP_U16 lenSoFar;
|
||||
|
||||
sprintf( msg, "%s (err: %ld): ", comment, lastErr );
|
||||
lenSoFar = strlen( msg );
|
||||
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
lastErr,
|
||||
0, // Default language
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
|
||||
len = wcslen( lpMsgBuf );
|
||||
if ( len >= sizeof(msg)-lenSoFar ) {
|
||||
len = sizeof(msg) - lenSoFar - 1;
|
||||
}
|
||||
WideCharToMultiByte( CP_ACP, 0, lpMsgBuf, len + 1,
|
||||
msg + lenSoFar, len + 1, NULL, NULL );
|
||||
LocalFree( lpMsgBuf );
|
||||
|
||||
XP_LOGF( "system error: %s", msg );
|
||||
} /* logLastError */
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
|
|
@ -27,8 +27,11 @@ void logRect( const char* comment, const RECT* rect );
|
|||
|
||||
#ifdef DEBUG
|
||||
void XP_LOGW( const XP_UCHAR* prefix, const wchar_t* arg );
|
||||
void logLastError( const char* comment );
|
||||
void messageToBuf( UINT message, char* buf, int bufSize );
|
||||
#else
|
||||
# define XP_LOGW( prefix, arg )
|
||||
# define logLastError(c)
|
||||
#endif
|
||||
|
||||
#endif /* _CEDEBUG_H_ */
|
||||
|
|
|
@ -775,43 +775,6 @@ ceInitAndStartBoard( CEAppGlobals* globals, XP_Bool newGame,
|
|||
}
|
||||
} /* ceInitAndStartBoard */
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
logLastError( const char* comment )
|
||||
{
|
||||
LPVOID lpMsgBuf;
|
||||
DWORD lastErr = GetLastError();
|
||||
XP_UCHAR msg[256];
|
||||
XP_U16 len;
|
||||
XP_U16 lenSoFar;
|
||||
|
||||
sprintf( msg, "%s (err: %ld): ", comment, lastErr );
|
||||
lenSoFar = strlen( msg );
|
||||
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
lastErr,
|
||||
0, // Default language
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
|
||||
len = wcslen( lpMsgBuf );
|
||||
if ( len >= sizeof(msg)-lenSoFar ) {
|
||||
len = sizeof(msg) - lenSoFar - 1;
|
||||
}
|
||||
WideCharToMultiByte( CP_ACP, 0, lpMsgBuf, len + 1,
|
||||
msg + lenSoFar, len + 1, NULL, NULL );
|
||||
LocalFree( lpMsgBuf );
|
||||
|
||||
XP_LOGF( "system error: %s", msg );
|
||||
} /* logLastError */
|
||||
#endif
|
||||
|
||||
static void
|
||||
ceSavePrefs( CEAppGlobals* globals )
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue