summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2011-01-17 05:20:22 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2011-01-17 05:20:22 (GMT)
commitbe986af65aad4dc28fd5c1ff33700ee54a09c79c (patch)
treef8e4e9a54ebd5fdbea4c126584cfe5a83a4b74d2
parent45f0910929a803f3031f0707a29ab1099d70a01c (diff)
downloadipxrelay-be986af65aad4dc28fd5c1ff33700ee54a09c79c.zip
ipxrelay-be986af65aad4dc28fd5c1ff33700ee54a09c79c.tar.gz
ipxrelay-be986af65aad4dc28fd5c1ff33700ee54a09c79c.tar.bz2
ipxrelay-be986af65aad4dc28fd5c1ff33700ee54a09c79c.tar.xz
Move headers to a common config.h
-rw-r--r--config.h248
-rw-r--r--configure.in2
-rw-r--r--ipxrelay.c23
3 files changed, 249 insertions, 24 deletions
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..c0127df
--- /dev/null
+++ b/config.h
@@ -0,0 +1,248 @@
+/* -*- c -*- ------------------------------------------------------------- *
+ *
+ * Copyright 2001-2006 H. Peter Anvin - All Rights Reserved
+ *
+ * This program is free software available under the same license
+ * as the "OpenBSD" operating system, distributed at
+ * http://www.openbsd.org/.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * config.h
+ *
+ * Sets up a common baseline environment, based on "autoconf" findings...
+ */
+
+#ifndef CONFIG_H
+#define CONFIG_H 1
+
+/* Must be included before we include any system headers! */
+#include "aconfig.h" /* autogenerated configuration header */
+
+/* Standard includes */
+
+#include <stdio.h>
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#else
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#endif
+
+#ifdef HAVE_MEMORY_H
+#ifndef STDC_HEADERS
+#include <memory.h>
+#endif
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#ifdef HAVE_INTTYPES_H
+#ifdef INTTYPES_H_IS_SANE
+#include <inttypes.h>
+#endif
+#else
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_SETJMP_H
+#include <setjmp.h>
+#endif
+
+#ifdef TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h>
+#else
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#endif
+
+#ifdef HAVE_GRP_H
+#include <grp.h>
+#endif
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#include <errno.h>
+#include <signal.h>
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#else
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+#ifdef HAVE_GETOPT_LONG
+#include <getopt.h>
+#else
+#include "lib/getopt.h"
+#endif
+
+#ifdef HAVE_SYS_CAPABILITY_H
+#include <sys/capability.h>
+#endif
+
+/* A lot of this is old BSD code. Some newer systems don't approve. */
+
+/* The type used by htons(), ntohs() */
+#ifndef HAVE_U_SHORT
+#ifdef HAVE_UINT16_T
+typedef uint16_t u_short;
+#else
+typedef unsigned short u_short;
+#endif
+#endif
+
+/* The type used to htonl(), ntohl() */
+#ifndef HAVE_U_LONG
+#ifdef HAVE_UINT32_T
+typedef uint32_t u_long;
+#else
+typedef unsigned long u_long;
+#endif
+#endif
+
+/* socklen_t */
+#ifndef HAVE_SOCKLEN_T
+typedef int socklen_t;
+#endif
+
+/* sysexits.h */
+
+#ifdef HAVE_SYSEXITS_H
+#include <sysexits.h>
+#else
+#define EX_USAGE 64 /* command line usage error */
+#define EX_DATAERR 65 /* data format error */
+#define EX_NOINPUT 66 /* cannot open input */
+#define EX_NOUSER 67 /* addressee unknown */
+#define EX_NOHOST 68 /* host name unknown */
+#define EX_UNAVAILABLE 69 /* service unavailable */
+#define EX_SOFTWARE 70 /* internal software error */
+#define EX_OSERR 71 /* system error (e.g., can't fork) */
+#define EX_OSFILE 72 /* critical OS file missing */
+#define EX_CANTCREAT 73 /* can't create (user) output file */
+#define EX_IOERR 74 /* input/output error */
+#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
+#define EX_PROTOCOL 76 /* remote error in protocol */
+#define EX_NOPERM 77 /* permission denied */
+#define EX_CONFIG 78 /* configuration error */
+#endif
+
+/* If we don't have sigsetjmp() et all, setjmp() will have to do */
+
+#ifndef HAVE_SIGSETJMP
+#define sigsetjmp(x,y) setjmp(x)
+#define siglongjmp(x,y) longjmp(x,y)
+#define sigjmp_buf jmp_buf
+#endif
+
+/* How do we annotate unused data items? */
+
+#ifndef UNUSED
+#ifdef __GNUC__
+#define UNUSED __attribute__((unused))
+#else
+#define UNUSED
+#endif
+#endif
+
+/* arpa/inet.h, and possible missing pieces */
+
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
+/* Prototypes for libxtra functions */
+
+#ifndef HAVE_DUP2
+int dup2(int, int);
+#endif
+#ifndef HAVE_DAEMON
+int daemon(int, int);
+#endif
+
+#ifndef HAVE_GETADDRINFO
+#ifndef HAVE_STRUCT_ADDRINFO
+struct addrinfo {
+ int ai_flags;
+ int ai_family;
+ int ai_socktype;
+ int ai_protocol;
+ size_t ai_addrlen;
+ struct sockaddr *ai_addr;
+ char *ai_canonname;
+ struct addrinfo *ai_next;
+};
+#endif
+int getaddrinfo(const char *, const char *, const struct addrinfo *,
+ struct addrinfo **);
+void freeaddrinfo(struct addrinfo *);
+const char *gai_strerror(int);
+
+
+#ifndef EAI_NONAME
+#define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
+#endif
+#ifndef EAI_ADDRFAMILY
+#define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
+#endif
+#ifndef EAI_MEMORY
+#define EAI_MEMORY -10 /* Memory allocation failure. */
+#endif
+#ifndef EAI_SYSTEM
+#define EAI_SYSTEM -11 /* System error returned in `errno'. */
+#endif
+#endif
+
+#ifndef AI_CANONNAME
+#define AI_CANONNAME 0
+#endif
+
+#ifndef AI_ADDRCONFIG
+#define AI_ADDRCONFIG 0
+#endif
+
+#ifndef INET6_ADDRSTRLEN
+#define INET6_ADDRSTRLEN 46
+#endif
+
+#endif
diff --git a/configure.in b/configure.in
index 0931b5a..23045a2 100644
--- a/configure.in
+++ b/configure.in
@@ -127,8 +127,6 @@ dnl
SRCROOT=`cd $srcdir && pwd`
OBJROOT=`pwd`
-XTRA=false
-AC_CHECK_LIB(cygwin, getopt_long)
PA_SEARCH_LIBS_AND_ADD(getopt_long, [getopt cygwin iberty], getopt_long)
PA_SEARCH_LIBS_AND_ADD(getaddrinfo, [nsl resolv])
if $pa_add_getaddrinfo
diff --git a/ipxrelay.c b/ipxrelay.c
index adb4007..81947d4 100644
--- a/ipxrelay.c
+++ b/ipxrelay.c
@@ -1,25 +1,4 @@
-#include <errno.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <string.h>
-#include <signal.h>
-#include <inttypes.h>
-#include <time.h>
-#ifdef __WIN32__
-#include "sysexits.h"
-#include <winsock2.h>
-#else
-#include <sysexits.h>
-#include <unistd.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#endif
+#include "config.h"
#define VERSION_STRING "0.2"