Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2011-03-29 15:18:10 +0400
committerCorinna Vinschen <corinna@vinschen.de>2011-03-29 15:18:10 +0400
commitda0086338992af1ca0cb8dfdab3199a36473611b (patch)
treeffb179a44fc1d47b15e6466b68ec18de25526f59 /winsup/cygwin/syslog.cc
parent39735c85f2bc07871aee587a9aecd0af50252f29 (diff)
* cygtls.h (struct _local_storage): Redefine process_ident as wchar_t
pointer. * syslog.cc (CYGWIN_LOG_NAME): Convert to wide char constant. (openlog): Convert incoming ident string to wide char. Fix formatting. (vsyslog): Print ident string as wide char string. Convert message string to wide char and call UNICODE Win32 Event functions to make sure to use correct codeset. * tlsoffset.h: Regenerate.
Diffstat (limited to 'winsup/cygwin/syslog.cc')
-rw-r--r--winsup/cygwin/syslog.cc37
1 files changed, 20 insertions, 17 deletions
diff --git a/winsup/cygwin/syslog.cc b/winsup/cygwin/syslog.cc
index 1aafbd313..d81210535 100644
--- a/winsup/cygwin/syslog.cc
+++ b/winsup/cygwin/syslog.cc
@@ -28,7 +28,7 @@ details. */
#include "cygtls.h"
#include "tls_pbuf.h"
-#define CYGWIN_LOG_NAME "Cygwin"
+#define CYGWIN_LOG_NAME L"Cygwin"
/* openlog: save the passed args. Don't open the system log or /dev/log yet. */
extern "C" void
@@ -44,13 +44,13 @@ openlog (const char *ident, int logopt, int facility)
}
if (ident)
{
- _my_tls.locals.process_ident = (char *) malloc (strlen (ident) + 1);
+ sys_mbstowcs_alloc (&_my_tls.locals.process_ident, HEAP_NOTHEAP, ident);
if (!_my_tls.locals.process_ident)
{
- debug_printf ("failed to allocate memory for _my_tls.locals.process_ident");
+ debug_printf ("failed to allocate memory for "
+ "_my_tls.locals.process_ident");
return;
}
- strcpy (_my_tls.locals.process_ident, ident);
}
_my_tls.locals.process_logopt = logopt;
_my_tls.locals.process_facility = facility;
@@ -378,7 +378,7 @@ vsyslog (int priority, const char *message, va_list ap)
/* Deal with ident_string */
if (_my_tls.locals.process_ident != NULL)
{
- if (pass.print ("%s: ", _my_tls.locals.process_ident) == -1)
+ if (pass.print ("%ls: ", _my_tls.locals.process_ident) == -1)
return;
}
if (_my_tls.locals.process_logopt & LOG_PID)
@@ -392,14 +392,11 @@ vsyslog (int priority, const char *message, va_list ap)
return;
}
- const char *msg_strings[1];
char *total_msg = pass.get_message ();
int len = strlen (total_msg);
if (len != 0 && (total_msg[len - 1] == '\n'))
total_msg[--len] = '\0';
- msg_strings[0] = total_msg;
-
if (_my_tls.locals.process_logopt & LOG_PERROR)
{
write (STDERR_FILENO, total_msg, len);
@@ -410,17 +407,23 @@ vsyslog (int priority, const char *message, va_list ap)
if ((fd = try_connect_syslogd (priority, total_msg, len + 1)) < 0)
{
/* If syslogd isn't present, open the event log and send the message */
- HANDLE hEventSrc = RegisterEventSourceA (NULL, (_my_tls.locals.process_ident != NULL) ?
- _my_tls.locals.process_ident : CYGWIN_LOG_NAME);
- if (hEventSrc == NULL)
+ HANDLE hEventSrc;
+
+ hEventSrc = RegisterEventSourceW (NULL, _my_tls.locals.process_ident
+ ?: CYGWIN_LOG_NAME);
+ if (!hEventSrc)
+ debug_printf ("RegisterEventSourceW, %E");
+ else
{
- debug_printf ("RegisterEventSourceA failed with %E");
- return;
+ wchar_t *msg_strings[1];
+ tmp_pathbuf tp;
+ msg_strings[0] = tp.w_get ();
+ sys_mbstowcs (msg_strings[0], NT_MAX_PATH, total_msg);
+ if (!ReportEventW (hEventSrc, eventType, 0, 0, cygheap->user.sid (),
+ 1, 0, (const wchar_t **) msg_strings, NULL))
+ debug_printf ("ReportEventW, %E");
+ DeregisterEventSource (hEventSrc);
}
- if (!ReportEventA (hEventSrc, eventType, 0, 0,
- cygheap->user.sid (), 1, 0, msg_strings, NULL))
- debug_printf ("ReportEventA failed with %E");
- DeregisterEventSource (hEventSrc);
}
}