Plugin compile fixes for windows systems.

This commit is contained in:
Jan Vidar Krey 2012-10-02 21:42:58 +02:00
parent ab9dda1c61
commit 62d14a9c52
2 changed files with 17 additions and 3 deletions

View File

@ -1,6 +1,6 @@
/* /*
* uhub - A tiny ADC p2p connection hub * uhub - A tiny ADC p2p connection hub
* Copyright (C) 2007-2011, Jan Vidar Krey * Copyright (C) 2007-2012, Jan Vidar Krey
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,7 +26,9 @@
#include "util/misc.h" #include "util/misc.h"
#include "util/config_token.h" #include "util/config_token.h"
#ifndef WIN32
#include <syslog.h> #include <syslog.h>
#endif
struct ip_addr_encap; struct ip_addr_encap;
@ -60,11 +62,13 @@ static int log_open_file(struct plugin_handle* plugin, struct log_data* data)
return (data->fd != -1); return (data->fd != -1);
} }
#ifndef WIN32
static int log_open_syslog(struct plugin_handle* plugin) static int log_open_syslog(struct plugin_handle* plugin)
{ {
openlog("uhub", 0, LOG_USER); openlog("uhub", 0, LOG_USER);
return 1; return 1;
} }
#endif
static struct log_data* parse_config(const char* line, struct plugin_handle* plugin) static struct log_data* parse_config(const char* line, struct plugin_handle* plugin)
{ {
@ -94,6 +98,7 @@ static struct log_data* parse_config(const char* line, struct plugin_handle* plu
data->logfile = strdup(cfg_settings_get_value(setting)); data->logfile = strdup(cfg_settings_get_value(setting));
data->logmode = mode_file; data->logmode = mode_file;
} }
#ifndef WIN32
else if (strcmp(cfg_settings_get_key(setting), "syslog") == 0) else if (strcmp(cfg_settings_get_key(setting), "syslog") == 0)
{ {
int use_syslog = 0; int use_syslog = 0;
@ -102,6 +107,7 @@ static struct log_data* parse_config(const char* line, struct plugin_handle* plu
data->logmode = (use_syslog) ? mode_syslog : mode_file; data->logmode = (use_syslog) ? mode_syslog : mode_file;
} }
} }
#endif
else else
{ {
set_error_message(plugin, "Unknown startup parameters given"); set_error_message(plugin, "Unknown startup parameters given");
@ -134,6 +140,7 @@ static struct log_data* parse_config(const char* line, struct plugin_handle* plu
return 0; return 0;
} }
} }
#ifndef WIN32
else else
{ {
if (!log_open_syslog(plugin)) if (!log_open_syslog(plugin))
@ -144,7 +151,7 @@ static struct log_data* parse_config(const char* line, struct plugin_handle* plu
return 0; return 0;
} }
} }
#endif
return data; return data;
} }
@ -155,10 +162,12 @@ static void log_close(struct log_data* data)
hub_free(data->logfile); hub_free(data->logfile);
close(data->fd); close(data->fd);
} }
#ifndef WIN32
else else
{ {
closelog(); closelog();
} }
#endif
hub_free(data); hub_free(data);
} }
@ -186,19 +195,25 @@ static void log_message(struct log_data* data, const char *format, ...)
} }
else else
{ {
#ifdef WIN32
_commit(data->fd);
#else
#if defined _POSIX_SYNCHRONIZED_IO && _POSIX_SYNCHRONIZED_IO > 0 #if defined _POSIX_SYNCHRONIZED_IO && _POSIX_SYNCHRONIZED_IO > 0
fdatasync(data->fd); fdatasync(data->fd);
#else #else
fsync(data->fd); fsync(data->fd);
#endif
#endif #endif
} }
} }
#ifndef WIN32
else else
{ {
va_start(args, format); va_start(args, format);
vsyslog(LOG_INFO, format, args); vsyslog(LOG_INFO, format, args);
va_end(args); va_end(args);
} }
#endif
} }
static void log_user_login(struct plugin_handle* plugin, struct plugin_user* user) static void log_user_login(struct plugin_handle* plugin, struct plugin_user* user)

View File

@ -28,7 +28,6 @@
#include "util/misc.h" #include "util/misc.h"
#include "util/config_token.h" #include "util/config_token.h"
#include <syslog.h>
#define MAX_WELCOME_SIZE 16384 #define MAX_WELCOME_SIZE 16384