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);
|
ShowLocalizedMsg(IDS_ERR_OPEN_DEBUG_FILE, DEBUG_FILE);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
PrintDebug("Starting OpenVPN GUI v%s", PACKAGE_VERSION);
|
PrintDebug(_T("Starting OpenVPN GUI v%S"), PACKAGE_VERSION);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
PrintDebug("Shell32.dll version: 0x%lx", shell32_version);
|
PrintDebug(_T("Shell32.dll version: 0x%lx"), shell32_version);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -497,15 +497,15 @@ void CloseApplication(HWND hwnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void PrintDebugMsg(char *msg)
|
void PrintDebugMsg(TCHAR *msg)
|
||||||
{
|
{
|
||||||
time_t log_time;
|
time_t log_time;
|
||||||
struct tm *time_struct;
|
struct tm *time_struct;
|
||||||
char date[30];
|
TCHAR date[30];
|
||||||
|
|
||||||
log_time = time(NULL);
|
log_time = time(NULL);
|
||||||
time_struct = localtime(&log_time);
|
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_year + 1900,
|
||||||
time_struct->tm_mon + 1,
|
time_struct->tm_mon + 1,
|
||||||
time_struct->tm_mday,
|
time_struct->tm_mday,
|
||||||
|
@ -513,14 +513,14 @@ void PrintDebugMsg(char *msg)
|
||||||
time_struct->tm_min,
|
time_struct->tm_min,
|
||||||
time_struct->tm_sec);
|
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);
|
fflush(o.debug_fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintErrorDebug(char *msg)
|
void PrintErrorDebug(TCHAR *msg)
|
||||||
{
|
{
|
||||||
LPVOID lpMsgBuf;
|
LPVOID lpMsgBuf;
|
||||||
char *buf;
|
TCHAR *buf;
|
||||||
|
|
||||||
/* Get last error message */
|
/* Get last error message */
|
||||||
if (!FormatMessage(
|
if (!FormatMessage(
|
||||||
|
@ -535,15 +535,17 @@ void PrintErrorDebug(char *msg)
|
||||||
NULL ))
|
NULL ))
|
||||||
{
|
{
|
||||||
/* FormatMessage failed! */
|
/* FormatMessage failed! */
|
||||||
PrintDebug("FormatMessage() failed. %s ", msg);
|
PrintDebug(_T("FormatMessage() failed. %s "), msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cut of CR/LFs */
|
/* Cut of CR/LFs */
|
||||||
buf = (char *)lpMsgBuf;
|
buf = (TCHAR *)lpMsgBuf;
|
||||||
buf[strlen(buf) - 3] = '\0';
|
buf[_tcslen(buf) - 3] = '\0';
|
||||||
|
|
||||||
PrintDebug("%s %s", msg, (LPCTSTR)lpMsgBuf);
|
PrintDebug(_T("%s %s"), msg, (LPCTSTR)lpMsgBuf);
|
||||||
|
|
||||||
|
LocalFree(lpMsgBuf);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -965,7 +965,7 @@ CheckVersion()
|
||||||
else if (ReadLineFromStdOut(hStdOutRead, line, sizeof(line)))
|
else if (ReadLineFromStdOut(hStdOutRead, line, sizeof(line)))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
PrintDebug("VersionString: %s", line);
|
PrintDebug(_T("VersionString: %S"), line);
|
||||||
#endif
|
#endif
|
||||||
CloseHandle(pi.hThread);
|
CloseHandle(pi.hThread);
|
||||||
CloseHandle(pi.hProcess);
|
CloseHandle(pi.hProcess);
|
||||||
|
|
Loading…
Reference in New Issue