com php-src: Use wide char API for the event log: win32/wsyslog.c
| From: | Anatol Belski | Date: | Sat, 19 Aug 2017 15:08:43 +0000 |
| Subject: | com php-src: Use wide char API for the event log: win32/wsyslog.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99112@lists.php.net to get a copy of this message | ||
Commit: e33259f3104188f1d02122fde2b0ccdcf8a16c2b
Author: Anatol Belski <ab@php.net> Sat, 19 Aug 2017 17:03:37 +0200
Parents: 504bf1110e308a507a7181bd21b913791fa78037
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e33259f3104188f1d02122fde2b0ccdcf8a16c2b
Log:
Use wide char API for the event log
Changed paths:
M win32/wsyslog.c
Diff:
diff --git a/win32/wsyslog.c b/win32/wsyslog.c
index b14fc1c..e13ef05 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);
}