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 .
--- /dev/null
+/* 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 <sys/mman.h>
+#include <sys/stat.h>
+#include <stdbool.h>
+
+/* Swap in my logging replacement. */
+void _err(int, bool, char *, int, char *, ...);
+#define libspamc_log(flags, level, ...) _err(-1, false, __FILE__, __LINE__, __VA_ARGS__)
#include "libspamc.h"
#include "utils.h"
#include "libspamc.h"
#include "utils.h"
-#include <sys/mman.h>
-#include <sys/stat.h>
-
-#include <stdbool.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
+#ifdef _WIN32
+#define snprintf _snprintf
+#define vsnprintf _vsnprintf
+#define strcasecmp stricmp
+#define sleep Sleep
+#include <io.h>
+#else
+#include <syslog.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#define closesocket(x) close(x)
#include <netinet/tcp.h>
#include <arpa/inet.h>
#define closesocket(x) close(x)
+#endif
+#ifdef HAVE_ERRNO_H
+#endif
+#ifdef HAVE_SYS_ERRNO_H
+#include <sys/errno.h>
+#endif
+#ifdef HAVE_TIME_H
+#endif
+#ifdef HAVE_SYS_TIME_H
-
-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 };
/* FIXME: Make this configurable */
#define MAX_CONNECT_RETRIES 3
/* FIXME: Make this configurable */
#define MAX_CONNECT_RETRIES 3
# define SHUT_RDWR 2 /* no more receptions or transmissions */
#endif
# 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
#ifndef HAVE_OPTARG
extern char *optarg;
#endif
/* jm: turned off for now, it should not be necessary. */
#undef USE_TCP_NODELAY
/* 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 */
#undef DO_CONNECT_DEBUG_SYSLOGS
/* or #define DO_CONNECT_DEBUG_SYSLOGS 1 */
int max_size, int in_fd, int out_fd,
const int check_only, const int safe_fallback);
int max_size, int in_fd, int out_fd,
const int check_only, const int safe_fallback);
void libspamc_log(int flags, int level, char *msg, ...);
void libspamc_log(int flags, int level, char *msg, ...);