diff -Nrub php-5.3.1/ext/standard/syslog.c php-5.3.1.new/ext/standard/syslog.c --- php-5.3.1/ext/standard/syslog.c 2008-12-31 20:15:49.000000000 +0900 +++ php-5.3.1.new/ext/standard/syslog.c 2010-02-04 11:09:48.000000000 +0900 @@ -269,7 +269,16 @@ return; } +#ifdef PHP_WIN32 + /* If using wide character with syslog(), call ReportEventW() */ + if (INI_INT("syslog_widechar")) { + wsyslog(priority, "%s", message); + } else { php_syslog(priority, "%s", message); + } +#else + php_syslog(priority, "%s", message); +#endif RETURN_TRUE; } /* }}} */ diff -Nrub php-5.3.1/main/main.c php-5.3.1.new/main/main.c --- php-5.3.1/main/main.c 2009-10-29 00:19:32.000000000 +0900 +++ php-5.3.1.new/main/main.c 2010-02-04 11:01:27.000000000 +0900 @@ -527,6 +527,9 @@ STD_PHP_INI_ENTRY("user_ini.filename", ".user.ini", PHP_INI_SYSTEM, OnUpdateString, user_ini_filename, php_core_globals, core_globals) STD_PHP_INI_ENTRY("user_ini.cache_ttl", "300", PHP_INI_SYSTEM, OnUpdateLong, user_ini_cache_ttl, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("exit_on_timeout", "0", PHP_INI_ALL, OnUpdateBool, exit_on_timeout, php_core_globals, core_globals) +#ifdef PHP_WIN32 + PHP_INI_ENTRY("syslog_widechar", NULL, PHP_INI_ALL, NULL) +#endif PHP_INI_END() /* }}} */ diff -Nrub php-5.3.1/win32/syslog.h php-5.3.1.new/win32/syslog.h --- php-5.3.1/win32/syslog.h 2008-12-31 20:15:49.000000000 +0900 +++ php-5.3.1.new/win32/syslog.h 2010-02-03 15:50:10.000000000 +0900 @@ -26,7 +26,7 @@ #define LOG_EMERG 1 #define LOG_ALERT 1 #define LOG_CRIT 1 -#define LOG_ERR 4 +#define LOG_ERR 1 #define LOG_WARNING 5 #define LOG_NOTICE 6 #define LOG_INFO 6 diff -Nrub php-5.3.1/win32/wsyslog.c php-5.3.1.new/win32/wsyslog.c --- php-5.3.1/win32/wsyslog.c 2006-01-16 23:26:07.000000000 +0900 +++ php-5.3.1.new/win32/wsyslog.c 2010-02-04 11:07:05.000000000 +0900 @@ -114,6 +114,52 @@ efree(tmp); } +/* Use unicode as message string + * This is a alternative choise of syslog() function for multi-byte users + */ +void wsyslog(int priority, const char *message, ...) +{ + va_list args; + LPWSTR wstrs[2]; /* for wide characters such as UTF-8 */ + int required_size; /* message length as wide characters */ + unsigned short etype; + char *tmp = NULL; + DWORD evid; + TSRMLS_FETCH(); + + /* default event source */ + if (!PW32G(log_source)) + openlog("php", LOG_PID, LOG_SYSLOG); + + switch (priority) { /* translate UNIX type into NT type */ + case LOG_ALERT: + etype = EVENTLOG_ERROR_TYPE; + evid = PHP_SYSLOG_ERROR_TYPE; + break; + case LOG_INFO: + etype = EVENTLOG_INFORMATION_TYPE; + evid = PHP_SYSLOG_INFO_TYPE; + break; + default: + etype = EVENTLOG_WARNING_TYPE; + evid = PHP_SYSLOG_WARNING_TYPE; + } + va_start(args, message); /* initialize vararg mechanism */ + vspprintf(&tmp, 0, message, args); /* build message */ + /* Convert multi-byte internal strings to WSTR with UTF8 codepage */ + required_size = MultiByteToWideChar(CP_UTF8, 0, PW32G(log_header), -1, NULL, 0); + wstrs[0] = (LPWSTR)emalloc(sizeof(WCHAR) * required_size); + MultiByteToWideChar(CP_UTF8, 0, PW32G(log_header), -1, wstrs[0], required_size); + required_size = MultiByteToWideChar(CP_UTF8, 0, tmp, -1, NULL, 0); + wstrs[1] = (LPWSTR)emalloc(sizeof(WCHAR) * required_size); + MultiByteToWideChar(CP_UTF8, 0, tmp, -1, wstrs[1], required_size); + /* report the event with unicode API */ + ReportEventW(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, wstrs, NULL); + va_end(args); + efree(tmp); + efree(wstrs[0]); + efree(wstrs[1]); +} /* Emulator for BSD openlog() routine * Accepts: identity