X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Fcollectd.c;h=ae2d3270bc963cecbb7eba33acaa412f3f993994;hb=b7a906d0dafe2b6832536fe190e033bbc321bea8;hp=b4668e06bb67d9c6dfd91dedd0d5ef30fb968a04;hpb=0706e1c4c496962b92b7bd2149bb651ef05b0acf;p=collectd.git diff --git a/src/daemon/collectd.c b/src/daemon/collectd.c index b4668e06..ae2d3270 100644 --- a/src/daemon/collectd.c +++ b/src/daemon/collectd.c @@ -28,9 +28,9 @@ #include "cmd.h" #include "collectd.h" -#include "common.h" #include "configfile.h" #include "plugin.h" +#include "utils/common/common.h" #include #include @@ -51,6 +51,14 @@ #define COLLECTD_LOCALE "C" #endif +#ifdef WIN32 +#undef COLLECT_DAEMON +#include +#undef gethostname +#include +#include +#endif + static int loop; static int init_hostname(void) { @@ -60,10 +68,14 @@ static int init_hostname(void) { return 0; } +#ifdef WIN32 + long hostname_len = NI_MAXHOST; +#else long hostname_len = sysconf(_SC_HOST_NAME_MAX); if (hostname_len == -1) { hostname_len = NI_MAXHOST; } +#endif /* WIN32 */ char hostname[hostname_len]; if (gethostname(hostname, hostname_len) != 0) { @@ -295,7 +307,7 @@ static int do_shutdown(void) { static void read_cmdline(int argc, char **argv, struct cmdline_config *config) { /* read options */ while (1) { - int c = getopt(argc, argv, "htTC:" + int c = getopt(argc, argv, "BhtTC:" #if COLLECT_DAEMON "fP:" #endif @@ -345,8 +357,7 @@ static int configure_collectd(struct cmdline_config *config) { * Also, this will automatically load modules. */ if (cf_read(config->configfile)) { - fprintf(stderr, "Error: Reading the config file failed!\n" - "Read the logs for details.\n"); + fprintf(stderr, "Error: Parsing the config file failed!\n"); return 1; }