From 608fdce0a0541cbd73eb80e7db1b5e3df70d1bf5 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 17 Nov 2008 14:24:15 +0000 Subject: if2ip.c related preprocessor cleanup --- lib/config-os400.h | 8 +++- lib/config-riscos.h | 2 - lib/if2ip.c | 111 ++++++++++++++++------------------------------------ lib/setup.h | 5 --- 4 files changed, 39 insertions(+), 87 deletions(-) (limited to 'lib') diff --git a/lib/config-os400.h b/lib/config-os400.h index e562b3c0b..0814773b5 100644 --- a/lib/config-os400.h +++ b/lib/config-os400.h @@ -283,6 +283,9 @@ /* Define if you have the `strlcpy' function. */ #undef HAVE_STRLCPY +/* Define if you have the header file. */ +#define HAVE_STROPTS_H + /* Define if you have the `strstr' function. */ #define HAVE_STRSTR @@ -392,14 +395,15 @@ /* Define to `unsigned' if does not define. */ #undef size_t -#define IOCTL_3_ARGS - /* Define if you have the ioctl function. */ #define HAVE_IOCTL /* Define if you have a working ioctl FIONBIO function. */ #define HAVE_IOCTL_FIONBIO +/* Define if you have a working ioctl SIOCGIFADDR function. */ +#define HAVE_IOCTL_SIOCGIFADDR + /* to disable LDAP */ #undef CURL_DISABLE_LDAP diff --git a/lib/config-riscos.h b/lib/config-riscos.h index fb1bb521e..938a8fc3e 100644 --- a/lib/config-riscos.h +++ b/lib/config-riscos.h @@ -381,8 +381,6 @@ /* this is a quick hack. I hope it's correct. */ #define ifr_dstaddr ifr_addr -#define IOCTL_3_ARGS - /* Define if you have the ioctl function. */ #define HAVE_IOCTL diff --git a/lib/if2ip.c b/lib/if2ip.c index c591a957a..bf400df48 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -23,46 +23,43 @@ #include "setup.h" -#include -#include -#include - #ifdef HAVE_UNISTD_H -#include +# include #endif - -#include "if2ip.h" - -/* - * This test can probably be simplified to #if defined(SIOCGIFADDR) and - * moved after the following includes. - */ -#if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN__) && \ - !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) && \ - !defined(__AMIGA__) && !defined(__minix) && !defined(__SYMBIAN32__) && \ - !defined(__WATCOMC__) - -#if defined(HAVE_GETIFADDRS) - -/* - * glibc provides getifaddrs() to provide a list of all interfaces and their - * addresses. - */ - -#include - #ifdef HAVE_SYS_SOCKET_H -#include +# include #endif #ifdef HAVE_NETINET_IN_H -#include +# include #endif #ifdef HAVE_ARPA_INET_H -#include +# include +#endif +#ifdef HAVE_NET_IF_H +# include +#endif +#ifdef HAVE_SYS_IOCTL_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif +#ifdef HAVE_SYS_SOCKIO_H +# include +#endif +#ifdef HAVE_IFADDRS_H +# include +#endif +#ifdef HAVE_STROPTS_H +# include +#endif +#ifdef VMS +# include #endif #include "inet_ntop.h" #include "strequal.h" +#include "if2ip.h" #define _MPRINTF_REPLACE /* use our functions only */ #include @@ -71,6 +68,10 @@ /* The last #include file should be: */ #include "memdebug.h" +------------------------------------------------------------------ + +#if defined(HAVE_GETIFADDRS) + char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) { struct ifaddrs *iface, *head; @@ -103,49 +104,7 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) return ip; } -#else - -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif - -#ifdef HAVE_SYS_TIME_H -/* This must be before net/if.h for AIX 3.2 to enjoy life */ -#include -#endif -#ifdef HAVE_NET_IF_H -#include -#endif -#ifdef HAVE_SYS_IOCTL_H -#include -#endif - -#ifdef HAVE_NETDB_H -#include -#endif - -#ifdef HAVE_SYS_SOCKIO_H -#include -#endif - -#ifdef VMS -#include -#endif - -#include "inet_ntop.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -#include "memory.h" -/* The last #include file should be: */ -#include "memdebug.h" +#elif defined(HAVE_IOCTL_SIOCGIFADDR) #define SYS_ERROR -1 @@ -171,11 +130,7 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) } memcpy(req.ifr_name, interface, len+1); req.ifr_addr.sa_family = AF_INET; -#ifdef IOCTL_3_ARGS if(SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) { -#else - if(SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) { -#endif sclose(dummy); return NULL; } @@ -190,10 +145,9 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) } return ip; } -#endif -/* -- end of if2ip() -- */ #else + char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size) { (void) af; @@ -202,4 +156,5 @@ char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size) (void) buf_size; return NULL; } + #endif diff --git a/lib/setup.h b/lib/setup.h index 66ddd38cb..5b675edda 100644 --- a/lib/setup.h +++ b/lib/setup.h @@ -355,7 +355,6 @@ # define sclose(x) close_s(x) # define select(n,r,w,x,t) select_s(n,r,w,x,t) # define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z)) -# define IOCTL_3_ARGS # include # ifdef word # undef word @@ -430,10 +429,6 @@ #endif #endif -#ifdef mpeix -#define IOCTL_3_ARGS -#endif - #ifdef NETWARE int netware_init(void); #ifndef __NOVELL_LIBC__ -- cgit v1.2.3