Re-tweaks for accommodating the windows build and systems that do not have strnlen

This commit is contained in:
Damien Stuart
2012-11-30 23:40:24 -05:00
parent eaba5813f3
commit 1ec9f4ae94
4 changed files with 41 additions and 8 deletions

View File

@@ -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***/

View File

@@ -57,13 +57,29 @@
#endif
#ifdef WIN32
#include <io.h>
#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 <stdint.h>
@@ -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 */

View File

@@ -33,11 +33,13 @@
#include "fko_message.h"
#include "fko.h"
/* for inet_aton() IP validation
*/
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#ifndef WIN32
/* for inet_aton() IP validation
*/
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
static int
have_allow_ip(const char *msg)

View File

@@ -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