mirror of https://github.com/OpenVPN/openvpn-gui
debug: fix debug under unicode
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com> edit: use _tsizeof for array element countpull/1/head
parent
45421c2514
commit
6eef880c8f
26
main.c
26
main.c
|
@ -119,7 +119,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
|||
ShowLocalizedMsg(IDS_ERR_OPEN_DEBUG_FILE, DEBUG_FILE);
|
||||
exit(1);
|
||||
}
|
||||
PrintDebug("Starting OpenVPN GUI v%s", PACKAGE_VERSION);
|
||||
PrintDebug(_T("Starting OpenVPN GUI v%S"), PACKAGE_VERSION);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -145,7 +145,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
|||
exit(1);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
PrintDebug("Shell32.dll version: 0x%lx", shell32_version);
|
||||
PrintDebug(_T("Shell32.dll version: 0x%lx"), shell32_version);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -497,15 +497,15 @@ void CloseApplication(HWND hwnd)
|
|||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void PrintDebugMsg(char *msg)
|
||||
void PrintDebugMsg(TCHAR *msg)
|
||||
{
|
||||
time_t log_time;
|
||||
struct tm *time_struct;
|
||||
char date[30];
|
||||
TCHAR date[30];
|
||||
|
||||
log_time = time(NULL);
|
||||
time_struct = localtime(&log_time);
|
||||
snprintf(date, sizeof(date), "%d-%.2d-%.2d %.2d:%.2d:%.2d",
|
||||
_sntprintf(date, _tsizeof(date), _T("%d-%.2d-%.2d %.2d:%.2d:%.2d"),
|
||||
time_struct->tm_year + 1900,
|
||||
time_struct->tm_mon + 1,
|
||||
time_struct->tm_mday,
|
||||
|
@ -513,14 +513,14 @@ void PrintDebugMsg(char *msg)
|
|||
time_struct->tm_min,
|
||||
time_struct->tm_sec);
|
||||
|
||||
fprintf(o.debug_fp, "%s %s\n", date, msg);
|
||||
_ftprintf(o.debug_fp, _T("%s %s\n"), date, msg);
|
||||
fflush(o.debug_fp);
|
||||
}
|
||||
|
||||
void PrintErrorDebug(char *msg)
|
||||
void PrintErrorDebug(TCHAR *msg)
|
||||
{
|
||||
LPVOID lpMsgBuf;
|
||||
char *buf;
|
||||
TCHAR *buf;
|
||||
|
||||
/* Get last error message */
|
||||
if (!FormatMessage(
|
||||
|
@ -535,15 +535,17 @@ void PrintErrorDebug(char *msg)
|
|||
NULL ))
|
||||
{
|
||||
/* FormatMessage failed! */
|
||||
PrintDebug("FormatMessage() failed. %s ", msg);
|
||||
PrintDebug(_T("FormatMessage() failed. %s "), msg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Cut of CR/LFs */
|
||||
buf = (char *)lpMsgBuf;
|
||||
buf[strlen(buf) - 3] = '\0';
|
||||
buf = (TCHAR *)lpMsgBuf;
|
||||
buf[_tcslen(buf) - 3] = '\0';
|
||||
|
||||
PrintDebug("%s %s", msg, (LPCTSTR)lpMsgBuf);
|
||||
PrintDebug(_T("%s %s"), msg, (LPCTSTR)lpMsgBuf);
|
||||
|
||||
LocalFree(lpMsgBuf);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue