/*
logger.c -- logging code
- Copyright (C) 2004-2017 Guus Sliepen <guus@tinc-vpn.org>
+ Copyright (C) 2004-2022 Guus Sliepen <guus@tinc-vpn.org>
2004-2005 Ivo Timmermans
This program is free software; you can redistribute it and/or modify
static logmode_t logmode = LOGMODE_STDERR;
static pid_t logpid;
static FILE *logfile = NULL;
-#ifdef HAVE_MINGW
+#ifdef HAVE_WINDOWS
static HANDLE loghandle = NULL;
#endif
static const char *logident = NULL;
break;
case LOGMODE_SYSLOG:
-#ifdef HAVE_MINGW
+#ifdef HAVE_WINDOWS
{
const char *messages[] = {message};
ReportEvent(loghandle, priority, 0, 0, NULL, 1, 0, messages, NULL);
}
if(umbilical && do_detach) {
- write(umbilical, message, strlen(message));
- write(umbilical, "\n", 1);
+ size_t len = strlen(message);
+
+ if(write(umbilical, message, len) != (ssize_t)len || write(umbilical, "\n", 1) != 1) {
+ // Other end broken, nothing we can do about it.
+ }
}
}
- if(logcontrol && connection_list) {
+ if(logcontrol) {
suppress = true;
logcontrol = false;
- for list_each(connection_t, c, connection_list) {
+ for list_each(connection_t, c, &connection_list) {
if(!c->status.log) {
continue;
}
size_t len = strlen(message);
- if(send_request(c, "%d %d %zu", CONTROL, REQ_LOG, len)) {
+ if(send_request(c, "%d %d %lu", CONTROL, REQ_LOG, (unsigned long)len)) {
send_meta(c, message, len);
}
}
break;
case LOGMODE_SYSLOG:
-#ifdef HAVE_MINGW
+#ifdef HAVE_WINDOWS
loghandle = RegisterEventSource(NULL, logident);
if(!loghandle) {
}
}
-void reopenlogger() {
+void reopenlogger(void) {
if(logmode != LOGMODE_FILE) {
return;
}
break;
case LOGMODE_SYSLOG:
-#ifdef HAVE_MINGW
+#ifdef HAVE_WINDOWS
DeregisterEventSource(loghandle);
break;
#else