From bfbc67c65ff0f5e4c5be9d1f9a460a805ef1eef0 Mon Sep 17 00:00:00 2001 From: "epg@pretzelnet.org" <> Date: Sun, 8 Mar 2009 01:16:30 -0800 Subject: [PATCH 1/1] Drop gratuitous differences from 3.1.0 . Earlier I said this was based on 3.1.3, but actually it's 3.1.0 . * config.h Add this, as libspamc.c expects to include it. Define autoconf macros it expects. Move includes and declarations for my code here. * libspamc.c Drop gratuitous differences. * libspamc.h Only declare libspamc_log if libspamc_log isn't defined as macro (in config.h), same as libspamc.c . --- config.h | 15 +++++++++++++++ libspamc.c | 40 ++++++++++++++++++++++++++++++---------- libspamc.h | 2 ++ 3 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 config.h diff --git a/config.h b/config.h new file mode 100644 index 0000000..ca950a6 --- /dev/null +++ b/config.h @@ -0,0 +1,15 @@ +/* Define autoconf macros libspamc.c expects. */ +#define HAVE_SYSEXITS_H 1 +#define HAVE_ERRNO_H 1 +#define HAVE_TIME_H 1 +#define HAVE_H_ERRNO 1 +#define HAVE_EX__MAX 1 + +/* Includes for my code. */ +#include +#include +#include + +/* Swap in my logging replacement. */ +void _err(int, bool, char *, int, char *, ...); +#define libspamc_log(flags, level, ...) _err(-1, false, __FILE__, __LINE__, __VA_ARGS__) diff --git a/libspamc.c b/libspamc.c index 44ab02b..b4d1936 100644 --- a/libspamc.c +++ b/libspamc.c @@ -15,18 +15,22 @@ * */ +#include "config.h" #include "libspamc.h" #include "utils.h" -#include -#include - -#include #include #include #include #include -#include +#ifdef _WIN32 +#define snprintf _snprintf +#define vsnprintf _vsnprintf +#define strcasecmp stricmp +#define sleep Sleep +#include +#else +#include #include #include #include @@ -35,16 +39,23 @@ #include #include #define closesocket(x) close(x) +#endif +#ifdef HAVE_SYSEXITS_H #include +#endif +#ifdef HAVE_ERRNO_H #include +#endif +#ifdef HAVE_SYS_ERRNO_H +#include +#endif +#ifdef HAVE_TIME_H #include +#endif +#ifdef HAVE_SYS_TIME_H #include - -void _err(int, bool, char *, int, char *, ...); -#define libspamc_log(flags, level, ...) _err(-1, false, __FILE__, __LINE__, __VA_ARGS__) - -enum { LOG_ERR, LOG_DEBUG, LOG_NOTICE }; +#endif /* FIXME: Make this configurable */ #define MAX_CONNECT_RETRIES 3 @@ -63,6 +74,10 @@ enum { LOG_ERR, LOG_DEBUG, LOG_NOTICE }; # define SHUT_RDWR 2 /* no more receptions or transmissions */ #endif +#ifndef HAVE_H_ERRNO +#define h_errno errno +#endif + #ifndef HAVE_OPTARG extern char *optarg; #endif @@ -74,6 +89,11 @@ extern char *optarg; /* jm: turned off for now, it should not be necessary. */ #undef USE_TCP_NODELAY +#ifndef HAVE_EX__MAX +/* jm: very conservative figure, should be well out of range on almost all NIXes */ +#define EX__MAX 200 +#endif + #undef DO_CONNECT_DEBUG_SYSLOGS /* or #define DO_CONNECT_DEBUG_SYSLOGS 1 */ diff --git a/libspamc.h b/libspamc.h index 4dfc2e5..be3d0fd 100644 --- a/libspamc.h +++ b/libspamc.h @@ -254,6 +254,8 @@ int process_message(struct transport *tp, char *username, int max_size, int in_fd, int out_fd, const int check_only, const int safe_fallback); +#ifndef libspamc_log void libspamc_log(int flags, int level, char *msg, ...); +#endif #endif -- 2.56.0