]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
if2ip.c related preprocessor cleanup
authorYang Tse <yangsita@gmail.com>
Mon, 17 Nov 2008 14:24:15 +0000 (14:24 +0000)
committerYang Tse <yangsita@gmail.com>
Mon, 17 Nov 2008 14:24:15 +0000 (14:24 +0000)
lib/config-os400.h
lib/config-riscos.h
lib/if2ip.c
lib/setup.h
packages/vms/config-vms.h
src/config-riscos.h

index e562b3c0be42291daeb43cf8cdfbc9c9320279b7..0814773b524d60134cb3f851099804117976984e 100644 (file)
 /* Define if you have the `strlcpy' function. */
 #undef HAVE_STRLCPY
 
+/* Define if you have the <stropts.h> header file. */
+#define HAVE_STROPTS_H
+
 /* Define if you have the `strstr' function. */
 #define HAVE_STRSTR
 
 /* Define to `unsigned' if <sys/types.h> 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
 
index fb1bb521e9b3255b7b71fae29953751563e8580b..938a8fc3ee5399a433fbe8e261f0141fbf2ec6ae 100644 (file)
 /* 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
 
index c591a957af313d7fd0660ae33b0c28eacd2c6723..bf400df4863540a1ec3ccab23849987373b768a4 100644 (file)
 
 #include "setup.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #ifdef HAVE_UNISTD_H
-#include <unistd.h>
+#  include <unistd.h>
 #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 <ifaddrs.h>
-
 #ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
+#  include <sys/socket.h>
 #endif
 #ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
+#  include <netinet/in.h>
 #endif
 #ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
+#  include <arpa/inet.h>
+#endif
+#ifdef HAVE_NET_IF_H
+#  include <net/if.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+#  include <sys/ioctl.h>
+#endif
+#ifdef HAVE_NETDB_H
+#  include <netdb.h>
+#endif
+#ifdef HAVE_SYS_SOCKIO_H
+#  include <sys/sockio.h>
+#endif
+#ifdef HAVE_IFADDRS_H
+#  include <ifaddrs.h>
+#endif
+#ifdef HAVE_STROPTS_H
+#  include <stropts.h>
+#endif
+#ifdef VMS
+#  include <inet.h>
 #endif
 
 #include "inet_ntop.h"
 #include "strequal.h"
+#include "if2ip.h"
 
 #define _MPRINTF_REPLACE /* use our functions only */
 #include <curl/mprintf.h>
 /* 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 <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-
-#ifdef HAVE_SYS_TIME_H
-/* This must be before net/if.h for AIX 3.2 to enjoy life */
-#include <sys/time.h>
-#endif
-#ifdef HAVE_NET_IF_H
-#include <net/if.h>
-#endif
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-
-#ifdef HAVE_SYS_SOCKIO_H
-#include <sys/sockio.h>
-#endif
-
-#ifdef VMS
-#include <inet.h>
-#endif
-
-#include "inet_ntop.h"
-
-#define _MPRINTF_REPLACE /* use our functions only */
-#include <curl/mprintf.h>
-
-#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
index 66ddd38cbe30e8b89a92b350f31fd9991202943b..5b675edda58b4cad512f29a244b0dde4e718fd5f 100644 (file)
 #    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 <tcp.h>
 #    ifdef word
 #      undef word
 #endif
 #endif
 
-#ifdef mpeix
-#define IOCTL_3_ARGS
-#endif
-
 #ifdef NETWARE
 int netware_init(void);
 #ifndef __NOVELL_LIBC__
index fe51c9a72679e4722ff35f71d0c501862be248db..ad92543c149b97f19b29cdf387e4d0adc4e6ef3f 100644 (file)
@@ -1,6 +1,6 @@
 /* MSK, 02/05/04, Hand edited for trail build on Alpha V7.3, DEC C 6.5-003 */
 /* MSK, 03/09/04, Seems to work for all platforms I've built on so far.    */
-/*      Added HAVE_SYS_IOCTL_H and IOCTL_3_ARGS defines                    */
+/*      Added HAVE_SYS_IOCTL_H define                                      */
 /* TES, 10/06/04, Added MAX_INITIAL_POST_SIZE, HAVE_BASENAME               */
 /* MSK, 02/02/05, Changed HAVE_TERMIOS_H to an undef since the change in   */
 /*                getpass.c no longer undef'd it during compile.           */
@@ -67,6 +67,9 @@
 /* Define if you have a working ioctl FIONBIO function. */
 #define HAVE_IOCTL_FIONBIO 1
 
+/* Define if you have a working ioctl SIOCGIFADDR function. */
+#define HAVE_IOCTL_SIOCGIFADDR 1
+
 /* Define if you have the perror function.  */
 #define HAVE_PERROR 1
 
 /* Define to 1 if you have the <sys/ioctl.h> header file. */
 #define HAVE_SYS_IOCTL_H 1
 
-/* IOCTL_3_ARGS defined to match the ioctl function in stropts.h */
-#define IOCTL_3_ARGS 1
+/* Define to 1 if you have the <stropts.h> header file. */
+#define HAVE_STROPTS_H 1
 
 /* to disable LDAP */
 #define CURL_DISABLE_LDAP 1
index dc5a4c7d6bde1a21629c49420e832e74a330c962..840b94f6b870d5a765aed58800631e817913ab03 100644 (file)
 /* 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