]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
== Makefile / config fixes == 423/head
authorSteven Hartland <steven.hartland@multiplay.co.uk>
Mon, 7 Oct 2013 11:21:37 +0000 (11:21 +0000)
committerSteven Hartland <steven.hartland@multiplay.co.uk>
Mon, 7 Oct 2013 11:21:37 +0000 (11:21 +0000)
* Fixed invalid AC_LANG_PROGRAM usage.
* Fixed AUTOMAKE_OPTIONS not defining subdir-objects which caused warnings
* Switched from legacy INCLUDES to AM_CPPFLAGS
* Added Makefile clean targets to ensure all autogenerated targets are removed
* Updated Makefile.PL to be more portable and less hardcoded for Win32
* Switched bash scripts to use #!/usr/bin/env bash for compatibility with none Linux OS's
* Cleaned up win32/Makefile.msc variable defines for easy updating
* Updated defines of SIZEOF_TIME_T to take into account the variances in Windows.

== Code Enhancements / fixes ==
* Added support for rrdcached client methods to windows builds
* Fixed invalid type warning for atoi assignment to a enum
* Fixed malloc cast warnings
* Fixed illegal use of this for variable
* Fixed getsockname cast warning
* Removed HAVE_CONFIG_H checks as all platforms now have it
* Removed unused skip variable from rrd_graph data_fetch
* Fixed unused var warnings for newGraphDescription params
* Fixed unused var st warning in HandleInputLine
* Fixed all includes for <stdint.h> to check HAVE_STDINT_H
* Fixed use of uninitialsed base_dir in rrd_mkdir_p on Win32
* Updated win32/README with details of obtaining stdint.h as well as locations
  for dependencies

26 files changed:
MakeMakefile
Makefile.am
autogen.sh
bindings/lua/Makefile.am
bindings/perl-shared/Makefile.PL
bindings/perl-shared/RRDs.xs
configure.ac
examples/Makefile.am
src/Makefile.am
src/mutex.c [new file with mode: 0644]
src/mutex.h [new file with mode: 0644]
src/rrd_cgi.c
src/rrd_client.c
src/rrd_client.h
src/rrd_daemon.c
src/rrd_flushcached.c
src/rrd_getopt.c
src/rrd_getopt1.c
src/rrd_graph.c
src/rrd_graph_helper.c
src/rrd_tool.c
src/rrd_update.c
src/rrd_utils.c
win32/Makefile.msc
win32/README
win32/rrd_config.h

index 4ef2a62eed4839c77eb11abe1647e8658d5c5611..9772bc75eed5aa1a4b7241bb0969d9022956a53f 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Run this script after the first cvs checkout to build
 # makefiles and friends
index 11d16d34eb5776f0296f8d8618fc7f53e7f29338..ec47c661d64332c8774f3cab065c349f1bb9751c 100644 (file)
@@ -13,8 +13,8 @@ EXTRA_DIST = COPYRIGHT CHANGES WIN32-BUILD-TIPS.txt TODO CONTRIBUTORS THREADS \
              libtool \
              netware/Makefile  \
              etc/rrdcached-default etc/rrdcached-init \
-             win32/Makefile  win32/config.h  win32/rrdlib.vcproj  win32/rrdtool.vcproj  win32/rrdupdate.vcproj \
-             win32/README    win32/rrd.sln   win32/rrdtool.sln    win32/rrdupdate.sln 
+             win32/Makefile  win32/rrd_config.h  win32/rrdlib.vcproj  win32/rrdtool.vcproj  win32/rrdupdate.vcproj \
+             win32/README    win32/rrd.sln   win32/rrdtool.sln    win32/rrdupdate.sln  win32/Makefile.msc
 
 CLEANFILES = config.cache
 
@@ -51,4 +51,7 @@ site-python-install: all
 indent:
        find ./ -name "*.[ch]" | xargs indent
 
+clean-local:
+       -rm -f config.h bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
+
 ##END##
index e9b7efff3a9bdaa8f4fc7a2c4a9e2e55d9f3bee2..97cebb535aa62b2e449bad7bef77d0d746ab9781 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # On MAC OS X, GNU libtoolize is named 'glibtoolize':
 if [ `(uname -s) 2>/dev/null` == 'Darwin' ]
index d71641f03f09b00da03b57304ab725a1e9ec36f3..f24a9d844bbf8390679105fbd3b7567ac9bea3d7 100644 (file)
@@ -3,6 +3,8 @@
 # it's not already installed.
 EXTRA_DIST = README test.lua.bottom compat-5.1r5/compat-5.1.lua
 
+AUTOMAKE_OPTIONS = subdir-objects
+
 LIB_VERSION_INFO=0:0:0
 
 LUA                 = @LUA@
index 781682ca5cc71729c14d29f9e4a3f67f8e4693b5..42becf4678e75ee8b2ff16ef4f5e03b477085165 100644 (file)
@@ -4,15 +4,22 @@ use Config;
 # the contents of the Makefile that is written.
 
 if (($Config{'osname'} eq 'MSWin32' && $ENV{'OSTYPE'} eq '')) {
+       my ($perlver) = ($] =~ /(\d+\.\d{3})/);
+       $perlver =~ s/[.0]//g;
+
+       my $perl_core_dir = "$Config{privlib}/CORE";
+       my $vc_dir = $ENV{'VSINSTALLDIR'} || 'C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC';
+       my $sdk_dir = $ENV{'WindowsSdkDir'} || 'C:/Program Files/Microsoft SDKs/Windows/v6.0A';
+
        WriteMakefile(
                'NAME'         => 'RRDs',
                'VERSION_FROM' => 'RRDs.pm',
                'DEFINE'       => "-DPERLPATCHLEVEL=$Config{PATCHLEVEL} -D_CRT_SECURE_NO_WARNINGS -DWIN32",
-               'INC'          => '-I../../src/ "-IC:/Perl/lib/CORE" -I"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include" -I"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include"',
-               'LDDLFLAGS'    => '-dll -nologo -opt:ref,icf -ltcg -libpath:"C:\Perl\lib\CORE" -machine:X86',
-               'LDFLAGS'      => '-nologo -opt:ref,icf -ltcg -libpath:"C:\Perl\lib\CORE" -machine:X86',
+               'INC'          => '-I../../src -I../../win32 "-I$perl_core_dir" -I"$vc_dir/include" -I"$sdk_dir/Include"',
+               'LDDLFLAGS'    => '-dll -nologo -opt:ref,icf -ltcg -libpath:"$perl_core_dir" -machine:X86',
+               'LDFLAGS'      => '-nologo -opt:ref,icf -ltcg -libpath:"$perl_core_dir" -machine:X86',
                'OPTIMIZE'     => '-O2 -MD',
-               'LIBS'         => '"..\..\win32\Release\rrdlib.lib" "..\..\win32\Release" "C:\Perl\lib\CORE\perl514.lib" -L../../contrib/lib -L"C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib" -L"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib" -L"C:\Perl\lib\CORE"',
+               'LIBS'         => qq{"../../win32/librrd-4.lib" "perl$perlver.lib" -L../../contrib/lib -L../../win32 -L"$sdk_dir/lib" -L"$vc_dir/lib" -L"$perl_core_dir"},
                'realclean'    => {FILES => 't/demo?.rrd t/demo?.png' },
                ($] ge '5.005') ? (
                        'AUTHOR'   => 'Tobias Oetiker (tobi@oetiker.ch)',
index 830a779d5f0f090c395cfeed3c0a445aa0b8b4f2..266b5e3423a88995e66f0f72442da348fff02f16 100644 (file)
@@ -434,7 +434,6 @@ rrd_restore(...)
        OUTPUT:
                RETVAL
 
-#ifndef WIN32
 int
 rrd_flushcached(...)
        PROTOTYPE: @
@@ -445,5 +444,3 @@ rrd_flushcached(...)
                rrdcode(rrd_flushcached);
        OUTPUT:
                RETVAL
-
-#endif
index 9882c6c8687db1c3eeaa25a52fa5687f58bdf772..f74060ad978da11e9af640aadb3c2b8316d2a551 100644 (file)
@@ -409,25 +409,22 @@ AC_LANG_PUSH(C)
 dnl solaris has some odd defines it needs in order to propperly compile ctime_r
 AC_MSG_CHECKING([if ctime_r need special care to act posixly correct])
 AC_LINK_IFELSE(
-    AC_LANG_PROGRAM(
+    [AC_LANG_PROGRAM(
            [[#include <time.h>]],
-           [[ctime_r(NULL,NULL,0)]]
-                   ),
+           [[ctime_r(NULL,NULL,0)]])],
     [ CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
       AC_LINK_IFELSE(
-          AC_LANG_PROGRAM(
+          [AC_LANG_PROGRAM(
                 [[#include <time.h>]],
-                [[ctime_r(NULL,NULL)]]
-                        ),
+                [[ctime_r(NULL,NULL)]])],
           [AC_MSG_RESULT([yes, this seems to be solaris style])],
           [AC_MSG_ERROR([Can't figure how to compile ctime_r])]
       )
     ],  
     [ AC_LINK_IFELSE(
-          AC_LANG_PROGRAM(
+          [AC_LANG_PROGRAM(
                 [[#include <time.h>]],
-                [[ctime_r(NULL,NULL)]]
-                        ),
+                [[ctime_r(NULL,NULL)]])],
           [AC_MSG_RESULT(no)],
           [AC_MSG_ERROR([Can't figure how to compile ctime_r])]
       )
@@ -462,18 +459,16 @@ AC_LANG_PUSH(C)
 dnl see if we have to include malloc/malloc.h
 AC_MSG_CHECKING([do we need malloc/malloc.h])
 AC_LINK_IFELSE(
-    AC_LANG_PROGRAM(
+    [AC_LANG_PROGRAM(
            [[#include <stdlib.h>]],
-           [[malloc(1)]]
-                   ),
+           [[malloc(1)]])],
     [ AC_MSG_RESULT([nope, works out of the box]) ],
     [ AC_LINK_IFELSE(
-          AC_LANG_PROGRAM(
+          [AC_LANG_PROGRAM(
                 [[#include <stdlib.h>
                   #include <malloc/malloc.h>]],
-                [[malloc(1)]]
-                        ),[
-           AC_DEFINE([MUST_HAVE_MALLOC_MALLOC_H])
+                [[malloc(1)]])],
+         [AC_DEFINE([MUST_HAVE_MALLOC_MALLOC_H])
            AC_MSG_RESULT([yes we do])],
           [AC_MSG_ERROR([Can not figure how to compile malloc])]
       )
index a91db8cc68e4f75026d1107bf48a273bd2e3cc05..a38b65ca99c6a8d6e026311a793cb59b9a6a362c 100644 (file)
@@ -16,3 +16,5 @@ cgi-demo.cgi: @srcdir@/cgi-demo.cgi.in $(top_builddir)/config.status
        sed 's,@''exec_prefix@,$(exec_prefix),' @srcdir@/cgi-demo.cgi.in > $@
        chmod a+x $@
 
+clean-local:
+       -rm -f cgi-demo.cgi
index c62839525a33708965dd17711108b0e355d5dee6..f1a095b9bc0d90c0fcc5cea9686aaf1b3b4de222 100644 (file)
@@ -9,13 +9,15 @@ if STATIC_PROGRAMS
 AM_LDFLAGS = -all-static
 endif
 
-INCLUDES = -DLOCALEDIR="\"$(datadir)/locale\""
 RRD_DEFAULT_FONT=@RRD_DEFAULT_FONT@
-AM_CPPFLAGS = -DRRD_DEFAULT_FONT=\"$(RRD_DEFAULT_FONT)\" -DNUMVERS=@NUMVERS@
+AM_CPPFLAGS = -DLOCALEDIR="\"$(datadir)/locale\"" \
+       -DRRD_DEFAULT_FONT=\"$(RRD_DEFAULT_FONT)\" \
+       -DNUMVERS=@NUMVERS@
 AM_CFLAGS = @CFLAGS@ -I$(top_srcdir)
 ## no including this by default @WERROR@
 
 UPD_C_FILES =          \
+       mutex.c         \
        rrd_create.c    \
        hash_32.c       \
        rrd_parsetime.c \
@@ -56,6 +58,7 @@ endif
 noinst_HEADERS = \
        unused.h \
         gettext.h \
+       mutex.h \
        rrd_getopt.h rrd_parsetime.h \
        rrd_config_bottom.h rrd_i18n.h \
        rrd_format.h rrd_tool.h rrd_xport.h rrd.h rrd_rpncalc.h \
@@ -132,3 +135,6 @@ librrd.sym: librrd.sym.in
 
 install-exec-hook:
        (cd $(DESTDIR)$(bindir) && $(LN_S) rrdupdate rrdcreate && $(LN_S) rrdupdate rrdinfo) || true
+
+distclean-local:
+       -rm -rf rrd_config.h librrd.sym
diff --git a/src/mutex.c b/src/mutex.c
new file mode 100644 (file)
index 0000000..c359b6f
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ *
+ * mutex.c
+ *
+ * Cross platform mutex
+ *
+ */
+
+#include "mutex.h"
+
+int mutex_init(mutex_t *mutex)
+{
+#ifdef WIN32
+  *mutex = CreateMutex(NULL, FALSE, NULL);
+  return (*mutex == NULL);
+#else
+  return pthread_mutex_init(mutex, NULL);;
+#endif
+}
+
+int mutex_lock(mutex_t *mutex)
+{
+#ifdef WIN32
+  if (*mutex == NULL) { /* static initializer? */
+    HANDLE p = CreateMutex(NULL, FALSE, NULL);
+    if (InterlockedCompareExchangePointer((PVOID*)mutex, (PVOID)p, NULL) != NULL)
+      CloseHandle(p);
+  }
+  return (WaitForSingleObject(*mutex, INFINITE) == WAIT_FAILED);
+#else
+  return pthread_mutex_lock(mutex);
+#endif
+}
+
+int mutex_unlock(mutex_t *mutex)
+{
+#ifdef WIN32
+  return (ReleaseMutex(*mutex) == 0);
+#else
+  return pthread_mutex_unlock(mutex);
+#endif
+}
+
+int mutex_cleanup(mutex_t *mutex)
+{
+#ifdef WIN32
+  return (CloseHandle(mutex) == 0);
+#else
+  return pthread_mutex_destroy(mutex);
+#endif
+}
+
+/*
+ * vim: set sw=2 sts=2 ts=8 et fdm=marker :
+ */
+
diff --git a/src/mutex.h b/src/mutex.h
new file mode 100644 (file)
index 0000000..3861c8f
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  mutex.h - Cross platform mutex
+ */
+
+#ifndef MUTEX__H
+#define MUTEX__H
+
+#ifdef WIN32
+#include <windows.h>
+#include <process.h>
+#else
+#include <pthread.h>
+#endif
+
+#ifndef WIN32
+#define mutex_t            pthread_mutex_t
+#define MUTEX_INITIALIZER  PTHREAD_MUTEX_INITIALIZER
+#else
+#define mutex_t            HANDLE
+#define MUTEX_INITIALIZER  NULL
+#endif
+
+int mutex_init(mutex_t *mutex);
+int mutex_lock(mutex_t *mutex);
+int mutex_unlock(mutex_t *mutex);
+int mutex_cleanup(mutex_t *mutex);
+
+#endif /* MUTEX__H */
+
+/*
+ * vim: set sw=2 sts=2 ts=8 et fdm=marker :
+ */
+
index 9ae6bff7dafd1c81e6557f278edd0804db74aa61..ccd8e7c360bd0e933c4cc240150b8eaa8dd2a53c 100644 (file)
@@ -9,11 +9,6 @@
 #include <stdlib.h>
 #endif
 
-#ifdef WIN32
-   #define strcasecmp stricmp
-   #define strcasencmp strnicmp
-#endif
-
 #define MEMBLK 1024
 /*#define DEBUG_PARSER
 #define DEBUG_VARS*/
index 1828e3d07646d843eb0b94198b95501756d2cf65..d796a2bdf7939ed060b3e887ad7d8ea829a6d8d6 100644 (file)
  *   Sebastian tokkee Harl <sh at tokkee.org>
  **/
 
+#ifdef WIN32
+#include <time.h>
+#include <ws2tcpip.h>
+#include <winsock2.h>
+#include <io.h>
+#include <fcntl.h>
+#include <tchar.h>
+#include <locale.h>
+#endif
+
 #include "rrd.h"
 #include "rrd_tool.h"
 #include "rrd_client.h"
+#include "mutex.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <strings.h>
 #include <errno.h>
 #include <assert.h>
+#ifndef WIN32
+#include <strings.h>
 #include <pthread.h>
-#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <netdb.h>
-#include <limits.h>
 #include <locale.h>
-
-#ifndef ENODATA
-#define ENODATA ENOENT
 #endif
+#include <sys/types.h>
+#include <limits.h>
 
 struct rrdc_response_s
 {
@@ -56,11 +65,14 @@ struct rrdc_response_s
 };
 typedef struct rrdc_response_s rrdc_response_t;
 
-static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+static mutex_t lock = MUTEX_INITIALIZER;
 static int sd = -1;
-static FILE *sh = NULL;
 static char *sd_path = NULL; /* cache the path for sd */
 
+static char _inbuf[RRD_CMD_MAX];
+static char *inbuf = _inbuf;
+static size_t inbuf_used = 0;
+
 /* get_path: Return a path name appropriate to be sent to the daemon.
  *
  * When talking to a local daemon (thru a UNIX socket), relative path names
@@ -171,19 +183,27 @@ static int parse_ulong_header (char *line, /* {{{ */
 static int parse_char_array_header (char *line, /* {{{ */
     char **ret_key, char **array, size_t array_len, int alloc)
 {
-  char *tmp_array[array_len];
+  char **tmp_array;
   char *value;
   size_t num;
   int status;
 
+  if ((tmp_array = (char**)malloc(array_len * sizeof (char*))) == NULL)
+    return (-1);
+
   value = NULL;
   status = parse_header (line, ret_key, &value);
-  if (status != 0)
+  if (status != 0) {
+    free(tmp_array);
     return (-1);
+  }
 
   num = strsplit (value, tmp_array, array_len);
   if (num != array_len)
+  {
+    free(tmp_array);
     return (-1);
+  }
 
   if (alloc == 0)
   {
@@ -197,6 +217,8 @@ static int parse_char_array_header (char *line, /* {{{ */
       array[i] = strdup (tmp_array[i]);
   }
 
+  free(tmp_array);
+
   return (0);
 } /* }}} int parse_char_array_header */
 
@@ -204,23 +226,30 @@ static int parse_value_array_header (char *line, /* {{{ */
     time_t *ret_time, rrd_value_t *array, size_t array_len)
 {
   char *str_key;
-  char *str_array[array_len];
+  char **str_array;
   char *endptr;
   char *old_locale;
   int status;
   size_t i;
 
+  if ((str_array = (char**)malloc(array_len * sizeof (char*))) == NULL)
+    return (-1);
+
   str_key = NULL;
   status = parse_char_array_header (line, &str_key,
       str_array, array_len, /* alloc = */ 0);
-  if (status != 0)
+  if (status != 0) {
+    free(str_array);
     return (-1);
+  }
 
   errno = 0;
   endptr = NULL;
   *ret_time = (time_t) strtol (str_key, &endptr, /* base = */ 10);
-  if ((endptr == str_key) || (errno != 0))
+  if ((endptr == str_key) || (errno != 0)) {
+    free(str_array);
     return (-1);
+  }
 
   /* Enforce the "C" locale so that parsing of the response is not dependent on
    * the locale. For example, when using a German locale the strtod() function
@@ -234,26 +263,27 @@ static int parse_value_array_header (char *line, /* {{{ */
     if ((endptr == str_array[i]) || (errno != 0))
     {
       (void) setlocale (LC_NUMERIC, old_locale);
+      free(str_array);
       return (-1);
     }
   }
 
   (void) setlocale (LC_NUMERIC, old_locale);
+  free(str_array);
   return (0);
 } /* }}} int parse_value_array_header */
 
 /* One must hold `lock' when calling `close_connection'. */
 static void close_connection (void) /* {{{ */
 {
-  if (sh != NULL)
-  {
-    fclose (sh);
-    sh = NULL;
-    sd = -1;
-  }
-  else if (sd >= 0)
+  if (sd >= 0)
   {
+#ifdef WIN32
+    closesocket(sd);
+    WSACleanup();
+#else
     close (sd);
+#endif
     sd = -1;
   }
 
@@ -378,19 +408,77 @@ static void response_free (rrdc_response_t *res) /* {{{ */
   free (res);
 } /* }}} void response_free */
 
+static int recvline (char *buf, size_t n) /* {{{ */
+{
+  size_t len;
+  char *s, *p, *t;
+
+  /* Sanity check */
+  if (n <= 0)
+    return (-1);
+
+  s = buf;
+  n--; /* leave space for the NULL */
+  while (n != 0)
+  {
+    /*
+         * If the buffer is empty, refill it.
+         */
+    if ((len = inbuf_used) <= 0)
+    {
+      inbuf = _inbuf;
+      inbuf_used = recv (sd, inbuf, RRD_CMD_MAX, 0);
+      if (inbuf_used <= 0)
+      {
+        if (s == buf)
+        {
+          /* EOF/error: stop with partial or no line */
+          return (-1);
+        }
+      }
+      len = inbuf_used;
+    }
+    p = inbuf;
+    /*
+         * Scan through at most n bytes of the current buffer,
+         * looking for '\n'.  If found, copy up to and including
+         * newline, and stop.  Otherwise, copy entire chunk
+         * and loop.
+         */
+    if (len > n)
+      len = n;
+    t = (char*)memchr((void *)p, '\n', len);
+    if (t != NULL)
+    {
+      len = ++t - p;
+      inbuf_used -= len;
+      inbuf = t;
+      (void)memcpy((void *)s, (void *)p, len);
+      s[len] = 0;
+      return (1);
+    }
+    inbuf_used -= len;
+    inbuf += len;
+    (void)memcpy((void *)s, (void *)p, len);
+    s += len;
+    n -= len;
+  }
+  *s = 0;
+  return (1);
+} /* }}} int recvline */
+
 static int response_read (rrdc_response_t **ret_response) /* {{{ */
 {
   rrdc_response_t *ret = NULL;
   int status = 0;
 
   char buffer[RRD_CMD_MAX];
-  char *buffer_ptr;
 
   size_t i;
 
 #define DIE(code) do { status = code; goto err_out; } while(0)
 
-  if (sh == NULL)
+  if (sd == -1)
     DIE(-1);
 
   ret = (rrdc_response_t *) malloc (sizeof (rrdc_response_t));
@@ -400,8 +488,7 @@ static int response_read (rrdc_response_t **ret_response) /* {{{ */
   ret->lines = NULL;
   ret->lines_num = 0;
 
-  buffer_ptr = fgets (buffer, sizeof (buffer), sh);
-  if (buffer_ptr == NULL)
+  if (recvline (buffer, sizeof (buffer)) == -1)
     DIE(-3);
 
   chomp (buffer);
@@ -429,8 +516,7 @@ static int response_read (rrdc_response_t **ret_response) /* {{{ */
 
   for (i = 0; i < ret->lines_num; i++)
   {
-    buffer_ptr = fgets (buffer, sizeof (buffer), sh);
-    if (buffer_ptr == NULL)
+    if (recvline (buffer, sizeof (buffer)) == -1)
       DIE(-6);
 
     chomp (buffer);
@@ -442,7 +528,6 @@ static int response_read (rrdc_response_t **ret_response) /* {{{ */
 
 out:
   *ret_response = ret;
-  fflush(sh);
   return (status);
 
 err_out:
@@ -454,24 +539,39 @@ err_out:
 
 } /* }}} rrdc_response_t *response_read */
 
+static int sendall (const char *msg, size_t len) /* {{{ */
+{
+  int ret = 0;
+  char *bufp = (char*)msg;
+
+  while (ret != -1 && len > 0) {
+    ret = send(sd, msg, len, 0);
+    if (ret > 0) {
+      bufp += ret;
+      len -= ret;
+    }
+  }
+
+  return ret;
+} /* }}} int sendall */
+
 static int request (const char *buffer, size_t buffer_size, /* {{{ */
     rrdc_response_t **ret_response)
 {
   int status;
   rrdc_response_t *res;
 
-  if (sh == NULL)
+  if (sd == -1)
     return (ENOTCONN);
 
-  status = (int) fwrite (buffer, buffer_size, /* nmemb = */ 1, sh);
-  if (status != 1)
+  status = sendall (buffer, buffer_size);
+  if (status == -1)
   {
     close_connection ();
     rrd_set_error("request: socket error (%d) while talking to rrdcached",
                   status);
     return (-1);
   }
-  fflush (sh);
 
   res = NULL;
   status = response_read (&res);
@@ -517,6 +617,9 @@ int rrdc_is_connected(const char *daemon_addr) /* {{{ */
 
 static int rrdc_connect_unix (const char *path) /* {{{ */
 {
+#ifdef WIN32
+  return (WSAEPROTONOSUPPORT);
+#else
   struct sockaddr_un sa;
   int status;
 
@@ -542,15 +645,8 @@ static int rrdc_connect_unix (const char *path) /* {{{ */
     return (status);
   }
 
-  sh = fdopen (sd, "r+");
-  if (sh == NULL)
-  {
-    status = errno;
-    close_connection ();
-    return (status);
-  }
-
   return (0);
+#endif
 } /* }}} int rrdc_connect_unix */
 
 static int rrdc_connect_network (const char *addr_orig) /* {{{ */
@@ -605,7 +701,7 @@ static int rrdc_connect_network (const char *addr_orig) /* {{{ */
   } /* if (*addr == '[') */
   else
   {
-    port = rindex(addr, ':');
+    port = strrchr(addr, ':');
     if (port != NULL)
     {
       *port = 0;
@@ -613,15 +709,28 @@ static int rrdc_connect_network (const char *addr_orig) /* {{{ */
     }
   }
 
+#ifdef WIN32
+  WORD wVersionRequested;
+  WSADATA wsaData;
+
+  wVersionRequested = MAKEWORD(2, 0);
+  status = WSAStartup(wVersionRequested, &wsaData);
+  if (status != 0)
+  {
+    rrd_set_error("failed to initialise socket library %d", status);
+    return (-1);
+  }
+#endif
+
   ai_res = NULL;
   status = getaddrinfo (addr,
                         port == NULL ? RRDCACHED_DEFAULT_PORT : port,
                         &ai_hints, &ai_res);
   if (status != 0)
   {
-    rrd_set_error ("failed to resolve address `%s' (port %s): %s",
+    rrd_set_error ("failed to resolve address '%s' (port %s): %s (%d)",
         addr, port == NULL ? RRDCACHED_DEFAULT_PORT : port,
-        gai_strerror (status));
+        gai_strerror (status), status);
     return (-1);
   }
 
@@ -642,15 +751,6 @@ static int rrdc_connect_network (const char *addr_orig) /* {{{ */
       close_connection();
       continue;
     }
-
-    sh = fdopen (sd, "r+");
-    if (sh == NULL)
-    {
-      status = errno;
-      close_connection ();
-      continue;
-    }
-
     assert (status == 0);
     break;
   } /* for (ai_ptr) */
@@ -673,12 +773,12 @@ int rrdc_connect (const char *addr) /* {{{ */
     return 0;
   }
 
-  pthread_mutex_lock(&lock);
+  mutex_lock (&lock);
 
   if (sd >= 0 && sd_path != NULL && strcmp(addr, sd_path) == 0)
   {
     /* connection to the same daemon; use cached connection */
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     return (0);
   }
   else
@@ -710,17 +810,17 @@ int rrdc_connect (const char *addr) /* {{{ */
       free (err);
   }
 
-  pthread_mutex_unlock (&lock);
+  mutex_unlock (&lock);
   return (status);
 } /* }}} int rrdc_connect */
 
 int rrdc_disconnect (void) /* {{{ */
 {
-  pthread_mutex_lock (&lock);
+  mutex_lock (&lock);
 
   close_connection();
 
-  pthread_mutex_unlock (&lock);
+  mutex_unlock (&lock);
 
   return (0);
 } /* }}} int rrdc_disconnect */
@@ -745,18 +845,18 @@ int rrdc_update (const char *filename, int values_num, /* {{{ */
   if (status != 0)
     return (ENOBUFS);
 
-  pthread_mutex_lock (&lock);
+  mutex_lock (&lock);
   filename = get_path (filename, file_path);
   if (filename == NULL)
   {
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     return (-1);
   }
 
   status = buffer_add_string (filename, &buffer_ptr, &buffer_free);
   if (status != 0)
   {
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     return (ENOBUFS);
   }
 
@@ -765,7 +865,7 @@ int rrdc_update (const char *filename, int values_num, /* {{{ */
     status = buffer_add_value (values[i], &buffer_ptr, &buffer_free);
     if (status != 0)
     {
-      pthread_mutex_unlock (&lock);
+      mutex_unlock (&lock);
       return (ENOBUFS);
     }
   }
@@ -777,7 +877,7 @@ int rrdc_update (const char *filename, int values_num, /* {{{ */
 
   res = NULL;
   status = request (buffer, buffer_size, &res);
-  pthread_mutex_unlock (&lock);
+  mutex_unlock (&lock);
 
   if (status != 0)
     return (status);
@@ -809,18 +909,18 @@ int rrdc_flush (const char *filename) /* {{{ */
   if (status != 0)
     return (ENOBUFS);
 
-  pthread_mutex_lock (&lock);
+  mutex_lock (&lock);
   filename = get_path (filename, file_path);
   if (filename == NULL)
   {
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     return (-1);
   }
 
   status = buffer_add_string (filename, &buffer_ptr, &buffer_free);
   if (status != 0)
   {
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     return (ENOBUFS);
   }
 
@@ -831,7 +931,7 @@ int rrdc_flush (const char *filename) /* {{{ */
 
   res = NULL;
   status = request (buffer, buffer_size, &res);
-  pthread_mutex_unlock (&lock);
+  mutex_unlock (&lock);
 
   if (status != 0)
     return (status);
@@ -872,18 +972,18 @@ rrd_info_t * rrdc_info (const char *filename) /* {{{ */
     return (NULL);
   }
 
-  pthread_mutex_lock (&lock);
+  mutex_lock (&lock);
   filename = get_path (filename, file_path);
   if (filename == NULL)
   {
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     return (NULL);
   }
 
   status = buffer_add_string (filename, &buffer_ptr, &buffer_free);
   if (status != 0)
   {
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     rrd_set_error ("rrdc_info: out of memory");
     return (NULL);
   }
@@ -895,7 +995,7 @@ rrd_info_t * rrdc_info (const char *filename) /* {{{ */
 
   res = NULL;
   status = request (buffer, buffer_size, &res);
-  pthread_mutex_unlock (&lock);
+  mutex_unlock (&lock);
 
   if (status != 0) {
     rrd_set_error ("rrdcached: %s", res->message);
@@ -908,7 +1008,7 @@ rrd_info_t * rrdc_info (const char *filename) /* {{{ */
       if(*s == ' ') { *s = 0; s++; break; }
        }
     if(!s || !*s) break;
-       itype = atoi(s); /* extract type code */
+       itype = (rrd_info_type_t)atoi(s); /* extract type code */
        for(;*s;s++) { if(*s == ' ') { *s = 0; s++; break; } }
     if(!*s) break;
     /* finally, we're pointing to the value */
@@ -933,7 +1033,7 @@ rrd_info_t * rrdc_info (const char *filename) /* {{{ */
         rrd_set_error ("rrdc_info: Unsupported info type %d",itype);
         return (NULL);
     }
-       
+
     cd = rrd_info_push(cd, sprintf_alloc("%s",k), itype, info);
        if(!data) data = cd;
   }
@@ -968,18 +1068,18 @@ time_t rrdc_last (const char *filename) /* {{{ */
     return (-1);
   }
 
-  pthread_mutex_lock (&lock);
+  mutex_lock (&lock);
   filename = get_path (filename, file_path);
   if (filename == NULL)
   {
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     return (-1);
   }
 
   status = buffer_add_string (filename, &buffer_ptr, &buffer_free);
   if (status != 0)
   {
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     rrd_set_error ("rrdc_last: out of memory");
     return (-1);
   }
@@ -991,7 +1091,7 @@ time_t rrdc_last (const char *filename) /* {{{ */
 
   res = NULL;
   status = request (buffer, buffer_size, &res);
-  pthread_mutex_unlock (&lock);
+  mutex_unlock (&lock);
 
   if (status != 0) {
     rrd_set_error ("rrdcached: %s", res->message);
@@ -1029,25 +1129,25 @@ time_t rrdc_first (const char *filename, int rraindex) /* {{{ */
     return (-1);
   }
 
-  pthread_mutex_lock (&lock);
+  mutex_lock (&lock);
   filename = get_path (filename, file_path);
   if (filename == NULL)
   {
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     return (-1);
   }
 
   status = buffer_add_string (filename, &buffer_ptr, &buffer_free);
   if (status != 0)
   {
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     rrd_set_error ("rrdc_first: out of memory");
     return (-1);
   }
   status = buffer_add_ulong (rraindex, &buffer_ptr, &buffer_free);
   if (status != 0)
   {
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     rrd_set_error ("rrdc_first: out of memory");
     return (-1);
   }
@@ -1059,7 +1159,7 @@ time_t rrdc_first (const char *filename, int rraindex) /* {{{ */
 
   res = NULL;
   status = request (buffer, buffer_size, &res);
-  pthread_mutex_unlock (&lock);
+  mutex_unlock (&lock);
 
   if (status != 0) {
     rrd_set_error ("rrdcached: %s", res->message);
@@ -1102,11 +1202,11 @@ int rrdc_create (const char *filename, /* {{{ */
     return (-1);
   }
 
-  pthread_mutex_lock (&lock);
+  mutex_lock (&lock);
   filename = get_path (filename, file_path);
   if (filename == NULL)
   {
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     return (-1);
   }
 
@@ -1120,7 +1220,7 @@ int rrdc_create (const char *filename, /* {{{ */
   }
   if (status != 0)
   {
-    pthread_mutex_unlock (&lock);
+    mutex_unlock (&lock);
     rrd_set_error ("rrdc_create: out of memory");
     return (-1);
   }
@@ -1130,7 +1230,7 @@ int rrdc_create (const char *filename, /* {{{ */
       status = buffer_add_string (argv[i], &buffer_ptr, &buffer_free);
       if (status != 0)
       {
-        pthread_mutex_unlock (&lock);
+        mutex_unlock (&lock);
         rrd_set_error ("rrdc_create: out of memory");
         return (-1);
       }
@@ -1145,7 +1245,7 @@ int rrdc_create (const char *filename, /* {{{ */
 
   res = NULL;
   status = request (buffer, buffer_size, &res);
-  pthread_mutex_unlock (&lock);
+  mutex_unlock (&lock);
 
   if (status != 0) {
     rrd_set_error ("rrdcached: %s", res->message);
@@ -1310,9 +1410,9 @@ int rrdc_fetch (const char *filename, /* {{{ */
   READ_NUMERIC_FIELD ("DSCount", unsigned long, ds_num);
   if (ds_num < 1)
     BAIL_OUT (-1, "Invalid number for DSCount: %lu", ds_num);
-  
+
   /* It's time to allocate some memory */
-  ds_names = calloc ((size_t) ds_num, sizeof (*ds_names));
+  ds_names = (char **)calloc ((size_t) ds_num, sizeof (*ds_names));
   if (ds_names == NULL)
     BAIL_OUT (-1, "Out of memory");
 
@@ -1332,10 +1432,10 @@ int rrdc_fetch (const char *filename, /* {{{ */
     BAIL_OUT (-1, "Got %zu lines, expected %zu",
         res->lines_num, (6 + (data_size / ds_num)));
 
-  data = calloc (data_size, sizeof (*data));
+  data = (rrd_value_t *)calloc (data_size, sizeof (*data));
   if (data == NULL)
     BAIL_OUT (-1, "Out of memory");
-  
+
 
   data_fill = 0;
   for (t = start + step; t <= end; t += step, current_line++)
@@ -1419,9 +1519,9 @@ int rrdc_stats_get (rrdc_stats_t **ret_stats) /* {{{ */
    * }}} */
 
   res = NULL;
-  pthread_mutex_lock (&lock);
+  mutex_lock (&lock);
   status = request ("STATS\n", strlen ("STATS\n"), &res);
-  pthread_mutex_unlock (&lock);
+  mutex_unlock (&lock);
 
   if (status != 0)
     return (status);
@@ -1517,23 +1617,23 @@ int rrdc_stats_get (rrdc_stats_t **ret_stats) /* {{{ */
 
 void rrdc_stats_free (rrdc_stats_t *ret_stats) /* {{{ */
 {
-  rrdc_stats_t *this;
+  rrdc_stats_t *stats;
 
-  this = ret_stats;
-  while (this != NULL)
+  stats = ret_stats;
+  while (stats != NULL)
   {
     rrdc_stats_t *next;
 
-    next = this->next;
+    next = stats->next;
 
-    if (this->name != NULL)
+    if (stats->name != NULL)
     {
-      free ((char *)this->name);
-      this->name = NULL;
+      free ((char *)stats->name);
+      stats->name = NULL;
     }
-    free (this);
+    free (stats);
 
-    this = next;
+    stats = next;
   } /* while (this != NULL) */
 } /* }}} void rrdc_stats_free */
 
index ee488f1e4ab566e1a39c596b39d0d784bd448752..81a7b221f02adef0970a89262888042e2674a879 100644 (file)
 #  include <stdint.h>
 # endif
 
-# ifdef HAVE_INTTYPES_H
-#  include <inttypes.h>
-# endif
-
-# if !(defined(HAVE_STDINT_H) || defined(HAVE_INTTYPES_H))
-#      include <stdlib.h>
-       typedef signed char     int8_t;
-       typedef unsigned char   uint8_t;
-       typedef signed int      int16_t;
-       typedef unsigned int    uint16_t;
-       typedef signed long int         int32_t;
-       typedef unsigned long int       uint32_t;
-       typedef signed long long int    int64_t;
-       typedef unsigned long long int  uint64_t;
-# endif
-
 /* max length of socket command or response */
 #define RRD_CMD_MAX 4096
 
 #define ENV_RRDCACHED_ADDRESS "RRDCACHED_ADDRESS"
 
 
-// Windows version has no daemon/client support
-
-#ifndef WIN32
 int rrdc_connect (const char *addr);
 int rrdc_is_connected(const char *daemon_addr);
 int rrdc_disconnect (void);
 
 int rrdc_update (const char *filename, int values_num,
-        const char * const *values);
+    const char * const *values);
 
 rrd_info_t * rrdc_info (const char *filename);
 time_t rrdc_last (const char *filename);
@@ -90,19 +71,6 @@ int rrdc_fetch (const char *filename,
     char ***ret_ds_names,
     rrd_value_t **ret_data);
 
-#else
-#   define rrdc_create(a,b,c,d,e,f) 0
-#      define rrdc_flush_if_daemon(a,b) 0
-#      define rrdc_connect(a) 0
-#      define rrdc_is_connected(a) 0
-#      define rrdc_flush(a) 0
-#      define rrdc_update(a,b,c) 0
-#   define rrdc_last(a) 0
-#   define rrdc_first(a,b) 0
-#   define rrdc_fetch(a,b,c,d,e,f,g,h) 0
-#   define rrdc_info(a) 0
-#endif
-
 struct rrdc_stats_s
 {
   const char *name;
index 2fdef1237dd293a2cec139a08a82476e437443da..f87efa03f294b34a694bba5d000db407d0bbf991 100644 (file)
 #include "unused.h"
 
 #include <stdlib.h>
-
-#ifndef WIN32
 #ifdef HAVE_STDINT_H
 #  include <stdint.h>
 #endif
+
+#ifndef WIN32
 #include <unistd.h>
 #include <strings.h>
 #include <inttypes.h>
@@ -3023,7 +3023,7 @@ static int open_listen_sockets_systemd(void) /* {{{ */
 
     l = sizeof(sa);
     memset(&sa, 0, l);
-    if (getsockname(sd_fd, &sa, &l) < 0)
+    if (getsockname(sd_fd, (struct sockaddr *)&sa, &l) < 0)
     {
       fprintf(stderr, "open_listen_sockets_systemd: problem getting fd %d: %s\n", sd_fd, rrd_strerror (errno));
       return i;
index 93b0fb57b05f32d356d2afd6145974fd88b8dbdd..55d4e28a942ae2f93e61a470241494e9f8925d62 100644 (file)
@@ -78,9 +78,10 @@ int rrd_flushcached (int argc, char **argv)
 
     if (! rrdc_is_connected(opt_daemon))
     {
-        rrd_set_error ("Daemon address unknown. Please use the \"--daemon\" "
+        rrd_set_error ("Daemon address \"%s\" unknown. Please use the \"--daemon\" "
                 "option to set an address on the command line or set the "
                 "\"%s\" environment variable.",
+                 opt_daemon,
                 ENV_RRDCACHED_ADDRESS);
         status = -1;
         goto out;
index 7d157a0ee41bd0efe5760b7a8fc4d0e1ea8723fc..086c4deecb563a85cf61c11cfc013f966d521268 100644 (file)
 #endif
 #endif
 
-#ifndef WIN32
-#ifdef HAVE_CONFIG_H
-#include "../rrd_config.h"
-#endif
-#endif
-
+#include "rrd_config.h"
 #include "rrd_i18n.h"
 
 
index ea9ed54568bc731b5e7da29efd5ea89691205e9f..fb13a13aa7ea72683d80d270b30f20f38a9e0804 100644 (file)
 #endif
 #endif
 
-#ifndef WIN32
-#ifdef HAVE_CONFIG_H
-#include "../rrd_config.h"
-#endif
-#endif
-
+#include "rrd_config.h"
 #include "rrd_getopt.h"
 
 #include <stdio.h>
index 4d91793a0271a08a212cf6d3730b531b8d8004ee..142cba1d623779098d486fa4564dd02909882a0a 100644 (file)
@@ -847,7 +847,6 @@ int data_fetch(
     image_desc_t *im)
 {
     int       i, ii;
-    int       skip;
     /* pull the data from the rrd files ... */
     for (i = 0; i < (int) im->gdes_c; i++) {
         /* only GF_DEF elements fetch data */
index 9b537bca10f05c7bbf7fba9d87d5ceba47aacb79..487bd3e7097538d356a7f0260f8382f7184a8f11 100644 (file)
@@ -6,7 +6,10 @@
  ****************************************************************************/
 
 #include <locale.h>
+#include "rrd_config.h"
+#ifdef HAVE_STDINT_H
 #include <stdint.h>
+#endif
 
 #include "rrd_graph.h"
 
@@ -531,6 +534,8 @@ static graph_desc_t* newGraphDescription(image_desc_t *const im,enum gf_en gf,pa
       if ((start)&&(parsetime_error = rrd_parsetime(start, &start_tv))) {
        rrd_set_error("start time: %s", parsetime_error);return NULL; }
       dprintfparsed("got start: %s\n",start);
+    } else {
+       start = NULL;
     }
     /* now end */
     char* end;
@@ -543,6 +548,8 @@ static graph_desc_t* newGraphDescription(image_desc_t *const im,enum gf_en gf,pa
       if ((end)&&(parsetime_error = rrd_parsetime(end, &end_tv))) {
        rrd_set_error("end time: %s", parsetime_error); return NULL; }
       dprintfparsed("got end: %s\n",end);
+    } else {
+       end = NULL;
     }
     /* and now put the pieces together (relative times like start=end-2days) */
     time_t    start_tmp = 0, end_tmp = 0;
@@ -838,6 +845,11 @@ int parse_axis(enum gf_en gf,parsedargs_t*pa,image_desc_t *const im){
   /* and other stuff */
   a->bounds.lowertxt=getKeyValueArgument("min",1,pa);
   a->bounds.uppertxt=getKeyValueArgument("max",1,pa);
+#else
+  /* prevent unused warnings */
+  (void)gf;
+  (void)pa;
+  (void)im;
 #endif
 
   /* and return */
index ea585abd5dbe4d0450e76b0a909489c346c4c9b6..3bcc7c8d8a6c2fb91098e6524370d48d51c7d961 100644 (file)
@@ -6,7 +6,7 @@
 
 #include "rrd_config.h"
 
-#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) && !defined(HAVE_CONFIG_H)
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <io.h>
@@ -533,9 +533,6 @@ int HandleInputLine(
     DIR      *curdir;   /* to read current dir with ls */
     struct dirent *dent;
 #endif
-#if defined(HAVE_SYS_STAT_H)
-    struct stat st;
-#endif
 
     /* Reset errno to 0 before we start.
      */
@@ -547,7 +544,7 @@ int HandleInputLine(
             }
             exit(0);
         }
-#if defined(HAVE_OPENDIR) && defined(HAVE_READDIR) && defined(HAVE_CHDIR)
+#if defined(HAVE_OPENDIR) && defined(HAVE_READDIR) && defined(HAVE_CHDIR) && defined(HAVE_SYS_STAT_H)
         if (argc > 1 && strcmp("cd", argv[1]) == 0) {
             if (argc != 3) {
                 printf("ERROR: invalid parameter count for cd\n");
@@ -607,6 +604,7 @@ int HandleInputLine(
                 return (1);
             }
             if ((curdir = opendir(".")) != NULL) {
+                struct stat st;
                 while ((dent = readdir(curdir)) != NULL) {
                     if (!stat(dent->d_name, &st)) {
                         if (S_ISDIR(st.st_mode)) {
@@ -765,10 +763,8 @@ int HandleInputLine(
 #endif
     } else if (strcmp("tune", argv[1]) == 0)
         rrd_tune(argc - 1, &argv[1]);
-#ifndef WIN32
     else if (strcmp("flushcached", argv[1]) == 0)
         rrd_flushcached(argc - 1, &argv[1]);
-#endif
     else {
         rrd_set_error("unknown function '%s'", argv[1]);
     }
index 2ab9ccecba7333346c47280fe18b9d79c1cdd034..48ba7e47b603f6087e5b3af24feb43558298522c 100644 (file)
@@ -14,7 +14,9 @@
 #endif
 
 #include <locale.h>
-#include <stdint.h>
+#ifdef HAVE_STDINT_H
+#  include <stdint.h>
+#endif
 
 #include "rrd_hw.h"
 #include "rrd_rpncalc.h"
  */
 #include <sys/timeb.h>
 
-#ifndef __MINGW32__
-struct timeval {
-    time_t    tv_sec;   /* seconds */
-    long      tv_usec;  /* microseconds */
-};
-#endif
-
 struct __timezone {
     int       tz_minuteswest;   /* minutes W of Greenwich */
     int       tz_dsttime;   /* type of dst correction */
index add19c31af61027762f10aa3e658e9e5419a2066..bab9ec8f9904b855fd13fcbe743ac6f1cf007d6e 100644 (file)
@@ -183,23 +183,24 @@ int rrd_mkdir_p(const char *pathname, mode_t mode)
         return -1;
     }
 #else
+    if (NULL == (base_dir = strdup(pathname_copy))) {
+        free(pathname_copy);
+        return -1;
+    }
+
     _splitpath(pathname_copy, NULL, base_dir, NULL, NULL);
 #endif
 
     if (0 != rrd_mkdir_p(base_dir, mode)) {
         int orig_errno = errno;
         free(pathname_copy);
-#ifndef _MSC_VER
         free(base_dir);
-#endif
         errno = orig_errno;
         return -1;
     }
 
     free(pathname_copy);
-#ifndef _MSC_VER
     free(base_dir);
-#endif
 
     /* keep errno as set by mkdir() */
 #ifdef _MSC_VER
index 0936f7295e71ca5b109f7be9a8e2a7a4bb252d5e..5bd5df5e38709dd199f47259c3ece0e446ecb413 100644 (file)
@@ -1,43 +1,39 @@
 TOP = .\r
 RRD_LIB_NAME=librrd-4\r
+ARCH_PATH_X86=contrib\r
+ARCH_PATH_X64=contrib-x64\r
+\r
 \r
 !ifndef USE_64BIT\r
 LD_FLAGS=/RELEASE /MACHINE:X86\r
-\r
-CPPFLAGS = /TP /EHsc /O2 /arch:SSE2 /Zi /Fd$(TOP)/win32/vc.pdb \\r
-        /I $(TOP)/win32 /I $(TOP)/src \\r
-        /I E:\var\vcs\git\osb\windows-x86-msvcrt\include \\r
-        /I E:\var\vcs\git\osb\windows-x86-msvcrt\include\cairo \\r
-        /I E:\var\vcs\git\osb\windows-x86-msvcrt\include\pango-1.0 \\r
-        /I E:\var\vcs\git\osb\windows-x86-msvcrt\include\glib-2.0 \\r
-        /I E:\var\vcs\git\osb\windows-x86-msvcrt\include\libxml2\r
-\r
-THIRD_PARTY_LIB = /LIBPATH:E:\var\vcs\git\osb\windows-x86-msvcrt\lib \\r
-        libpng.lib libxml2-2.lib \\r
-        libglib-2.lib libgobject-2.lib \\r
-        libpango-1.lib libpangocairo-1.lib libcairo-2.lib\r
-\r
+ARCH_PATH=$(ARCH_PATH_X86)\r
+CPPFLAGS = /arch:SSE2\r
 !else\r
 LD_FLAGS=/RELEASE /MACHINE:X64\r
+ARCH_PATH=$(ARCH_PATH_X64)\r
+!endif\r
 \r
-CPPFLAGS = /TP /EHsc /O2 /Zi /Fd$(TOP)/win32/vc.pdb \\r
+CPPFLAGS = $(CCPFLAGS) /TP /EHsc /O2 /Zi /Fd$(TOP)/win32/vc.pdb \\r
         /I $(TOP)/win32 /I $(TOP)/src \\r
-        /I E:\var\vcs\git\osb\windows-x64-msvcrt\include \\r
-        /I E:\var\vcs\git\osb\windows-x64-msvcrt\include\cairo \\r
-        /I E:\var\vcs\git\osb\windows-x64-msvcrt\include\pango-1.0 \\r
-        /I E:\var\vcs\git\osb\windows-x64-msvcrt\include\glib-2.0 \\r
-        /I E:\var\vcs\git\osb\windows-x64-msvcrt\include\libxml2\r
+        /I $(ARCH_PATH)\include \\r
+        /I $(ARCH_PATH)\include\cairo \\r
+        /I $(ARCH_PATH)\include\pango-1.0 \\r
+        /I $(ARCH_PATH)\include\glib-2.0 \\r
+        /I $(ARCH_PATH)\lib\glib-2.0\include \\r
+        /I $(ARCH_PATH)\include\libxml2\r
 \r
-THIRD_PARTY_LIB = /LIBPATH:E:\var\vcs\git\osb\windows-x64-msvcrt\lib \\r
-        libpng.lib libxml2-2.lib \\r
-        libglib-2.lib libgobject-2.lib \\r
-        libpango-1.lib libpangocairo-1.lib libcairo-2.lib\r
-!endif\r
+THIRD_PARTY_LIB = /LIBPATH:$(ARCH_PATH)\lib \\r
+        libpng.lib libxml2.lib \\r
+        glib-2.0.lib gobject-2.0.lib \\r
+        pango-1.0.lib pangocairo-1.0.lib cairo.lib \\r
+               Ws2_32.lib\r
 \r
 RRD_LIB_OBJ_LIST = \\r
         $(TOP)/src/hash_32.obj \\r
+        $(TOP)/src/mutex.obj \\r
         $(TOP)/src/plbasename.obj \\r
         $(TOP)/src/pngsize.obj \\r
+        $(TOP)/src/rrd_client.obj \\r
         $(TOP)/src/rrd_create.obj \\r
         $(TOP)/src/rrd_diff.obj \\r
         $(TOP)/src/rrd_dump.obj \\r
index 238c605cbcb7410b677e47357f4be76baf098c8b..5d57e39b9d283bdd60df62a47340eef18617206f 100755 (executable)
@@ -3,26 +3,33 @@ Win32 Build Instructions:
 1) See build-rrdtool.dot (build-rrdtool.svg or build-rrdtool.pdf) for build\r
    dependency.\r
 \r
-2) If you do not want to build the build-dependencies, you can download these\r
-   software from the following address:\r
+2) If you do not want to build the build-dependencies, you can download prebuilt\r
+   versions from the following address:\r
 \r
+   32bit dependencies should then be extracted into the contrib directory:\r
    http://ftp.gnome.org/pub/gnome/binaries/win32/\r
    http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/\r
 \r
+   64bit dependencies should then be extracted into the contrib-x64 directory:\r
    http://ftp.gnome.org/pub/gnome/binaries/win64/\r
    http://ftp.gnome.org/pub/gnome/binaries/win64/dependencies/\r
 \r
-3) Adjust the include path, library path, and library names which in the\r
+\r
+3) If you don't already have stdint.h for your system you can download it\r
+   from the following address:\r
+   http://msinttypes.googlecode.com/svn/trunk/stdint.h\r
+\r
+4) Adjust the include path, library path, and library names which in the\r
    Makefile.msc, to correspond with your local path or names.\r
 \r
-4) Run 'nmake -f win32\Makefile.msc' for 32 bit Windows target,\r
+5) Run 'nmake -f win32\Makefile.msc' for 32 bit Windows target,\r
    Run 'nmake -f win32\Makefile.msc USE_64BIT=1' for 64 bit Windows target.\r
    Run 'nmake -f win32\Makefile.msc clean' to remove all generated files.\r
 \r
-5) librrd-4.dll, librrd-4.lib, rrdtool.exe, rrdupdate.exe, rrdcgi.exe, and\r
+6) librrd-4.dll, librrd-4.lib, rrdtool.exe, rrdupdate.exe, rrdcgi.exe, and\r
    these corresponding pdb files will be located in the win32 directory.\r
 \r
-6) To install, copy these files which you required to their permanent location.\r
+7) To install, copy these files which you required to their permanent location.\r
 \r
-7) To build the binding module. Follow the instructions in the README file which\r
+8) To build the binding module. Follow the instructions in the README file which\r
    under the subdirectory of 'binding/'.\r
index 9211ea7b4f20ad67ebc5a2adaa7ed7890686e9dd..a8f289fbef4c45a4b5d0168df0203c502fb4b4d0 100644 (file)
     Linux x64 gcc, Windows x64 gcc, Visual C++ 2005 or later
  */
 
-/* The size of `time_t', as computed by sizeof. */
-#define SIZEOF_TIME_T 8 /* Visual C++ 2005 or later */
+/*
+ * The size of `time_t', as computed by sizeof.
+ * VS2005 and later dafault size for time_t is 64-bit, unless
+ * _USE_32BIT_TIME_T has been defined to use a 32-bit time_t.
+ */
+#if defined(_MSC_VER) && (_MSC_VER >= 1400)
+#  ifndef _USE_32BIT_TIME_T
+#    define SIZEOF_TIME_T 8
+#  else
+#    define SIZEOF_TIME_T 4
+#  endif
+#else
+#  ifdef _WIN64
+#    define SIZEOF_TIME_T 8
+#  else
+#    define SIZEOF_TIME_T 4
+#  endif
+#endif
 
 /* Define to 1 if you have the `chdir' function. */
 #define HAVE_CHDIR 1
 /* Define to 1 if you have the `tzset' function. */
 #define HAVE_TZSET 1
 
+/* Misc Missing Windows defines */
+#define PATH_MAX 1024
+
+/*
+ * Windows Sockets errors redefined as regular Berkeley error constants.
+ */
+#define ENOBUFS WSAENOBUFS
+#define ENOTCONN WSAENOTCONN
+
 #include <ctype.h>
 #include <direct.h>
 #include <float.h>
 #include <math.h>
-#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <WinSock.h>
 
 #define isinf(a) (_fpclass(a) == _FPCLASS_NINF || _fpclass(a) == _FPCLASS_PINF)
 #define isnan _isnan
 #define finite _finite
 #define snprintf _snprintf
 #define rrd_realloc(a,b) ( (a) == NULL ? malloc( (b) ) : realloc( (a) , (b) ))
+#define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
+#define strcasecmp _stricmp
+#define strcasencmp _strnicmp
 
+#pragma warning(disable: 4244)
 __inline int round(double a){ return (int) (a + 0.5); }
 
 #endif