From 1ec9f4ae94a76365a0293f50fe1b8475a2d57dcd Mon Sep 17 00:00:00 2001 From: Damien Stuart Date: Fri, 30 Nov 2012 23:40:24 -0500 Subject: [PATCH] Re-tweaks for accommodating the windows build and systems that do not have strnlen --- common/common.h | 6 ++++++ lib/fko_common.h | 28 +++++++++++++++++++++++++--- lib/fko_message.c | 12 +++++++----- win32/config.h | 3 +++ 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/common/common.h b/common/common.h index f064240a..daddec7c 100644 --- a/common/common.h +++ b/common/common.h @@ -147,6 +147,12 @@ enum { x == '#' || x == '\n' || x == '\r' || x == ';' || x == '\0' \ ) +/* Work-around for not having strnlen +*/ +#if !HAVE_STRNLEN + #define strnlen(s, l) (strlen(s) < l ? strlen(s) : l) +#endif + #endif /* _COMMON_H */ /***EOF***/ diff --git a/lib/fko_common.h b/lib/fko_common.h index bf1bad25..fdf3bb92 100644 --- a/lib/fko_common.h +++ b/lib/fko_common.h @@ -57,13 +57,29 @@ #endif #ifdef WIN32 + #include + #define strcasecmp _stricmp + #define strncasecmp _strnicmp + #define snprintf _snprintf + #define strdup _strdup + #define unlink _unlink + #define open _open + #define close _close + #define write _write + #define O_WRONLY _O_WRONLY + #define O_RDONLY _O_RDONLY + #define O_RDWR _O_RDWR + #define O_CREAT _O_CREAT + #define O_EXCL _O_EXCL + #define S_IRUSR _S_IREAD + #define S_IWUSR _S_IWRITE + #define PATH_SEP '\\' + /* These are needed for the digest code under windows. */ typedef unsigned __int8 uint8_t; typedef unsigned __int32 uint32_t; typedef unsigned __int64 uint64_t; - - #define strdup _strdup #else #if HAVE_STDINT_H #include @@ -126,7 +142,13 @@ /* Try to cover for those that do not have bzero. */ #if !HAVE_BZERO && HAVE_MEMSET -# define bzero(buf, bytes) ((void) memset (buf, 0, bytes)) + #define bzero(buf, bytes) ((void) memset (buf, 0, bytes)) +#endif + +/* Work-around for not having strnlen +*/ +#if !HAVE_STRNLEN + #define strnlen(s, l) (strlen(s) < l ? strlen(s) : l) #endif #endif /* FKO_COMMON_H */ diff --git a/lib/fko_message.c b/lib/fko_message.c index 6b2ee124..98587c03 100644 --- a/lib/fko_message.c +++ b/lib/fko_message.c @@ -33,11 +33,13 @@ #include "fko_message.h" #include "fko.h" -/* for inet_aton() IP validation -*/ -#include -#include -#include +#ifndef WIN32 + /* for inet_aton() IP validation + */ + #include + #include + #include +#endif static int have_allow_ip(const char *msg) diff --git a/win32/config.h b/win32/config.h index 4dc0c90c..2965ab16 100644 --- a/win32/config.h +++ b/win32/config.h @@ -101,6 +101,9 @@ /* Define to 1 if you have the `strndup' function. */ #define HAVE_STRNDUP 1 +/* Define to 1 if you have the `strnlen' function. */ +#define HAVE_STRNLEN 1 + /* Define to 1 if you have the `strrchr' function. */ #define HAVE_STRRCHR 1