From: Steven Hartland Date: Mon, 7 Oct 2013 11:21:37 +0000 (+0000) Subject: == Makefile / config fixes == X-Git-Tag: v1.5.0-rc1~168^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F423%2Fhead;p=thirdparty%2Frrdtool-1.x.git == Makefile / config fixes == * 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 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 --- diff --git a/MakeMakefile b/MakeMakefile index 4ef2a62e..9772bc75 100755 --- a/MakeMakefile +++ b/MakeMakefile @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Run this script after the first cvs checkout to build # makefiles and friends diff --git a/Makefile.am b/Makefile.am index 11d16d34..ec47c661 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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## diff --git a/autogen.sh b/autogen.sh index e9b7efff..97cebb53 100755 --- a/autogen.sh +++ b/autogen.sh @@ -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' ] diff --git a/bindings/lua/Makefile.am b/bindings/lua/Makefile.am index d71641f0..f24a9d84 100644 --- a/bindings/lua/Makefile.am +++ b/bindings/lua/Makefile.am @@ -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@ diff --git a/bindings/perl-shared/Makefile.PL b/bindings/perl-shared/Makefile.PL index 781682ca..42becf46 100644 --- a/bindings/perl-shared/Makefile.PL +++ b/bindings/perl-shared/Makefile.PL @@ -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)', diff --git a/bindings/perl-shared/RRDs.xs b/bindings/perl-shared/RRDs.xs index 830a779d..266b5e34 100644 --- a/bindings/perl-shared/RRDs.xs +++ b/bindings/perl-shared/RRDs.xs @@ -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 diff --git a/configure.ac b/configure.ac index 9882c6c8..f74060ad 100644 --- a/configure.ac +++ b/configure.ac @@ -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 ]], - [[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 ]], - [[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 ]], - [[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 ]], - [[malloc(1)]] - ), + [[malloc(1)]])], [ AC_MSG_RESULT([nope, works out of the box]) ], [ AC_LINK_IFELSE( - AC_LANG_PROGRAM( + [AC_LANG_PROGRAM( [[#include #include ]], - [[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])] ) diff --git a/examples/Makefile.am b/examples/Makefile.am index a91db8cc..a38b65ca 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index c6283952..f1a095b9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 index 00000000..c359b6fc --- /dev/null +++ b/src/mutex.c @@ -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 index 00000000..3861c8f9 --- /dev/null +++ b/src/mutex.h @@ -0,0 +1,33 @@ +/* + * mutex.h - Cross platform mutex + */ + +#ifndef MUTEX__H +#define MUTEX__H + +#ifdef WIN32 +#include +#include +#else +#include +#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 : + */ + diff --git a/src/rrd_cgi.c b/src/rrd_cgi.c index 9ae6bff7..ccd8e7c3 100644 --- a/src/rrd_cgi.c +++ b/src/rrd_cgi.c @@ -9,11 +9,6 @@ #include #endif -#ifdef WIN32 - #define strcasecmp stricmp - #define strcasencmp strnicmp -#endif - #define MEMBLK 1024 /*#define DEBUG_PARSER #define DEBUG_VARS*/ diff --git a/src/rrd_client.c b/src/rrd_client.c index 1828e3d0..d796a2bd 100644 --- a/src/rrd_client.c +++ b/src/rrd_client.c @@ -25,27 +25,36 @@ * Sebastian tokkee Harl **/ +#ifdef WIN32 +#include +#include +#include +#include +#include +#include +#include +#endif + #include "rrd.h" #include "rrd_tool.h" #include "rrd_client.h" +#include "mutex.h" #include #include #include -#include #include #include +#ifndef WIN32 +#include #include -#include #include #include #include -#include #include - -#ifndef ENODATA -#define ENODATA ENOENT #endif +#include +#include 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 */ diff --git a/src/rrd_client.h b/src/rrd_client.h index ee488f1e..81a7b221 100644 --- a/src/rrd_client.h +++ b/src/rrd_client.h @@ -31,22 +31,6 @@ # include # endif -# ifdef HAVE_INTTYPES_H -# include -# endif - -# if !(defined(HAVE_STDINT_H) || defined(HAVE_INTTYPES_H)) -# include - 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 @@ -58,15 +42,12 @@ #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; diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index 2fdef123..f87efa03 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -69,11 +69,11 @@ #include "unused.h" #include - -#ifndef WIN32 #ifdef HAVE_STDINT_H # include #endif + +#ifndef WIN32 #include #include #include @@ -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; diff --git a/src/rrd_flushcached.c b/src/rrd_flushcached.c index 93b0fb57..55d4e28a 100644 --- a/src/rrd_flushcached.c +++ b/src/rrd_flushcached.c @@ -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; diff --git a/src/rrd_getopt.c b/src/rrd_getopt.c index 7d157a0e..086c4dee 100644 --- a/src/rrd_getopt.c +++ b/src/rrd_getopt.c @@ -39,12 +39,7 @@ #endif #endif -#ifndef WIN32 -#ifdef HAVE_CONFIG_H -#include "../rrd_config.h" -#endif -#endif - +#include "rrd_config.h" #include "rrd_i18n.h" diff --git a/src/rrd_getopt1.c b/src/rrd_getopt1.c index ea9ed545..fb13a13a 100644 --- a/src/rrd_getopt1.c +++ b/src/rrd_getopt1.c @@ -28,12 +28,7 @@ #endif #endif -#ifndef WIN32 -#ifdef HAVE_CONFIG_H -#include "../rrd_config.h" -#endif -#endif - +#include "rrd_config.h" #include "rrd_getopt.h" #include diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 4d91793a..142cba1d 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -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 */ diff --git a/src/rrd_graph_helper.c b/src/rrd_graph_helper.c index 9b537bca..487bd3e7 100644 --- a/src/rrd_graph_helper.c +++ b/src/rrd_graph_helper.c @@ -6,7 +6,10 @@ ****************************************************************************/ #include +#include "rrd_config.h" +#ifdef HAVE_STDINT_H #include +#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 */ diff --git a/src/rrd_tool.c b/src/rrd_tool.c index ea585abd..3bcc7c8d 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -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 #include #include @@ -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]); } diff --git a/src/rrd_update.c b/src/rrd_update.c index 2ab9ccec..48ba7e47 100644 --- a/src/rrd_update.c +++ b/src/rrd_update.c @@ -14,7 +14,9 @@ #endif #include -#include +#ifdef HAVE_STDINT_H +# include +#endif #include "rrd_hw.h" #include "rrd_rpncalc.h" @@ -32,13 +34,6 @@ */ #include -#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 */ diff --git a/src/rrd_utils.c b/src/rrd_utils.c index add19c31..bab9ec8f 100644 --- a/src/rrd_utils.c +++ b/src/rrd_utils.c @@ -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 diff --git a/win32/Makefile.msc b/win32/Makefile.msc index 0936f729..5bd5df5e 100644 --- a/win32/Makefile.msc +++ b/win32/Makefile.msc @@ -1,43 +1,39 @@ TOP = . RRD_LIB_NAME=librrd-4 +ARCH_PATH_X86=contrib +ARCH_PATH_X64=contrib-x64 + !ifndef USE_64BIT LD_FLAGS=/RELEASE /MACHINE:X86 - -CPPFLAGS = /TP /EHsc /O2 /arch:SSE2 /Zi /Fd$(TOP)/win32/vc.pdb \ - /I $(TOP)/win32 /I $(TOP)/src \ - /I E:\var\vcs\git\osb\windows-x86-msvcrt\include \ - /I E:\var\vcs\git\osb\windows-x86-msvcrt\include\cairo \ - /I E:\var\vcs\git\osb\windows-x86-msvcrt\include\pango-1.0 \ - /I E:\var\vcs\git\osb\windows-x86-msvcrt\include\glib-2.0 \ - /I E:\var\vcs\git\osb\windows-x86-msvcrt\include\libxml2 - -THIRD_PARTY_LIB = /LIBPATH:E:\var\vcs\git\osb\windows-x86-msvcrt\lib \ - libpng.lib libxml2-2.lib \ - libglib-2.lib libgobject-2.lib \ - libpango-1.lib libpangocairo-1.lib libcairo-2.lib - +ARCH_PATH=$(ARCH_PATH_X86) +CPPFLAGS = /arch:SSE2 !else LD_FLAGS=/RELEASE /MACHINE:X64 +ARCH_PATH=$(ARCH_PATH_X64) +!endif -CPPFLAGS = /TP /EHsc /O2 /Zi /Fd$(TOP)/win32/vc.pdb \ +CPPFLAGS = $(CCPFLAGS) /TP /EHsc /O2 /Zi /Fd$(TOP)/win32/vc.pdb \ /I $(TOP)/win32 /I $(TOP)/src \ - /I E:\var\vcs\git\osb\windows-x64-msvcrt\include \ - /I E:\var\vcs\git\osb\windows-x64-msvcrt\include\cairo \ - /I E:\var\vcs\git\osb\windows-x64-msvcrt\include\pango-1.0 \ - /I E:\var\vcs\git\osb\windows-x64-msvcrt\include\glib-2.0 \ - /I E:\var\vcs\git\osb\windows-x64-msvcrt\include\libxml2 + /I $(ARCH_PATH)\include \ + /I $(ARCH_PATH)\include\cairo \ + /I $(ARCH_PATH)\include\pango-1.0 \ + /I $(ARCH_PATH)\include\glib-2.0 \ + /I $(ARCH_PATH)\lib\glib-2.0\include \ + /I $(ARCH_PATH)\include\libxml2 -THIRD_PARTY_LIB = /LIBPATH:E:\var\vcs\git\osb\windows-x64-msvcrt\lib \ - libpng.lib libxml2-2.lib \ - libglib-2.lib libgobject-2.lib \ - libpango-1.lib libpangocairo-1.lib libcairo-2.lib -!endif +THIRD_PARTY_LIB = /LIBPATH:$(ARCH_PATH)\lib \ + libpng.lib libxml2.lib \ + glib-2.0.lib gobject-2.0.lib \ + pango-1.0.lib pangocairo-1.0.lib cairo.lib \ + Ws2_32.lib RRD_LIB_OBJ_LIST = \ $(TOP)/src/hash_32.obj \ + $(TOP)/src/mutex.obj \ $(TOP)/src/plbasename.obj \ $(TOP)/src/pngsize.obj \ + $(TOP)/src/rrd_client.obj \ $(TOP)/src/rrd_create.obj \ $(TOP)/src/rrd_diff.obj \ $(TOP)/src/rrd_dump.obj \ diff --git a/win32/README b/win32/README index 238c605c..5d57e39b 100755 --- a/win32/README +++ b/win32/README @@ -3,26 +3,33 @@ Win32 Build Instructions: 1) See build-rrdtool.dot (build-rrdtool.svg or build-rrdtool.pdf) for build dependency. -2) If you do not want to build the build-dependencies, you can download these - software from the following address: +2) If you do not want to build the build-dependencies, you can download prebuilt + versions from the following address: + 32bit dependencies should then be extracted into the contrib directory: http://ftp.gnome.org/pub/gnome/binaries/win32/ http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/ + 64bit dependencies should then be extracted into the contrib-x64 directory: http://ftp.gnome.org/pub/gnome/binaries/win64/ http://ftp.gnome.org/pub/gnome/binaries/win64/dependencies/ -3) Adjust the include path, library path, and library names which in the + +3) If you don't already have stdint.h for your system you can download it + from the following address: + http://msinttypes.googlecode.com/svn/trunk/stdint.h + +4) Adjust the include path, library path, and library names which in the Makefile.msc, to correspond with your local path or names. -4) Run 'nmake -f win32\Makefile.msc' for 32 bit Windows target, +5) Run 'nmake -f win32\Makefile.msc' for 32 bit Windows target, Run 'nmake -f win32\Makefile.msc USE_64BIT=1' for 64 bit Windows target. Run 'nmake -f win32\Makefile.msc clean' to remove all generated files. -5) librrd-4.dll, librrd-4.lib, rrdtool.exe, rrdupdate.exe, rrdcgi.exe, and +6) librrd-4.dll, librrd-4.lib, rrdtool.exe, rrdupdate.exe, rrdcgi.exe, and these corresponding pdb files will be located in the win32 directory. -6) To install, copy these files which you required to their permanent location. +7) To install, copy these files which you required to their permanent location. -7) To build the binding module. Follow the instructions in the README file which +8) To build the binding module. Follow the instructions in the README file which under the subdirectory of 'binding/'. diff --git a/win32/rrd_config.h b/win32/rrd_config.h index 9211ea7b..a8f289fb 100644 --- a/win32/rrd_config.h +++ b/win32/rrd_config.h @@ -33,8 +33,24 @@ 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 @@ -72,20 +88,33 @@ /* 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 #include #include #include -#include #include #include +#include #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