libcollectdclient: Add defines for Windows compatibility.
[collectd.git] / src / libcollectdclient / client.c
index 726f25d..c725182 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * libcollectdclient - src/libcollectdclient/client.c
- * Copyright (C) 2008-2012  Florian octo Forster
+ * Copyright (C) 2008-2014  Florian octo Forster
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
 
 #include "collectd/lcc_features.h"
 
+#if WIN32
+
+#include <winsock2.h>
+#include <wspiapi.h>
+#include <windows.h>
+#include <io.h>
+#include <stdio.h>
+#include <math.h>
+#include <assert.h>
+
+#else
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -46,6 +58,8 @@
 #include <math.h>
 #include <netdb.h>
 
+#endif
+
 #include "collectd/client.h"
 
 /* NI_MAXHOST has been obsoleted by RFC 3493 which is a reason for SunOS 5.11
@@ -378,6 +392,7 @@ static int lcc_sendreceive (lcc_connection_t *c, /* {{{ */
   return (status);
 } /* }}} int lcc_sendreceive */
 
+#if !WIN32
 static int lcc_open_unixsocket (lcc_connection_t *c, const char *path) /* {{{ */
 {
   struct sockaddr_un sa;
@@ -419,6 +434,7 @@ static int lcc_open_unixsocket (lcc_connection_t *c, const char *path) /* {{{ */
 
   return (0);
 } /* }}} int lcc_open_unixsocket */
+#endif /* !WIN32 */
 
 static int lcc_open_netsocket (lcc_connection_t *c, /* {{{ */
     const char *addr_orig)
@@ -545,11 +561,13 @@ static int lcc_open_socket (lcc_connection_t *c, const char *addr) /* {{{ */
   assert (c->fh == NULL);
   assert (addr != NULL);
 
+#if !WIN32
   if (strncmp ("unix:", addr, strlen ("unix:")) == 0)
     status = lcc_open_unixsocket (c, addr + strlen ("unix:"));
   else if (addr[0] == '/')
     status = lcc_open_unixsocket (c, addr);
   else
+#endif
     status = lcc_open_netsocket (c, addr);
 
   return (status);