diff options
author | Anatol Belski <ab@php.net> | 2017-08-19 17:03:37 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2017-08-19 17:08:43 +0200 |
commit | e33259f3104188f1d02122fde2b0ccdcf8a16c2b (patch) | |
tree | 25d27423646847902b17591c32fad813f3b7733f /win32/wsyslog.c | |
parent | 504bf1110e308a507a7181bd21b913791fa78037 (diff) | |
download | php-git-e33259f3104188f1d02122fde2b0ccdcf8a16c2b.tar.gz |
Use wide char API for the event log
Diffstat (limited to 'win32/wsyslog.c')
-rw-r--r-- | win32/wsyslog.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/win32/wsyslog.c b/win32/wsyslog.c index b14fc1cc61..e13ef05d87 100644 --- a/win32/wsyslog.c +++ b/win32/wsyslog.c @@ -58,6 +58,7 @@ #include "php_win32_globals.h" #include "wsyslog.h" +#include "codepage.h" void closelog(void) { @@ -92,6 +93,7 @@ void vsyslog(int priority, const char *message, va_list args) unsigned short etype; char *tmp = NULL; DWORD evid; + wchar_t *strsw[2]; /* default event source */ if (INVALID_HANDLE_VALUE == PW32G(log_source)) @@ -110,11 +112,28 @@ void vsyslog(int priority, const char *message, va_list args) etype = EVENTLOG_WARNING_TYPE; evid = PHP_SYSLOG_WARNING_TYPE; } + vspprintf(&tmp, 0, message, args); /* build message */ + + strsw[0] = php_win32_cp_any_to_w(PW32G(log_header)); + strsw[1] = php_win32_cp_any_to_w(tmp); + + /* report the event */ + if (strsw[0] && strsw[1]) { + ReportEventW(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, strsw, NULL); + free(strsw[0]); + free(strsw[1]); + efree(tmp); + return; + } + + free(strsw[0]); + free(strsw[1]); + strs[0] = PW32G(log_header); /* write header */ strs[1] = tmp; /* then the message */ - /* report the event */ - ReportEvent(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, strs, NULL); + + ReportEventA(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, strs, NULL); efree(tmp); } |