Use #ifdef instead of #if

This commit is contained in:
Glenn L McGrath 2002-11-26 02:40:56 +00:00
parent 2801eb925d
commit d7fb1b372c
4 changed files with 22 additions and 22 deletions

View File

@ -14,7 +14,7 @@
#include <unistd.h> #include <unistd.h>
#include "libbb.h" #include "libbb.h"
#if CONFIG_FEATURE_IPV6 #ifdef CONFIG_FEATURE_IPV6
int create_icmp6_socket(void) int create_icmp6_socket(void)
{ {
struct protoent *proto; struct protoent *proto;

View File

@ -4,7 +4,7 @@
* *
* Heavily modified by Manuel Novoa III Mar 12, 2001 * Heavily modified by Manuel Novoa III Mar 12, 2001
* *
* Version: $Id: inet_common.c,v 1.3 2002/07/03 11:46:36 andersen Exp $ * Version: $Id: inet_common.c,v 1.4 2002/11/26 02:35:15 bug1 Exp $
* *
*/ */
@ -17,7 +17,7 @@
#include "libbb.h" #include "libbb.h"
#ifdef DEBUG #ifdef DEBUG
#include <resolv.h> # include <resolv.h>
#endif #endif
@ -178,7 +178,7 @@ int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in,
return (0); return (0);
} }
#if CONFIG_FEATURE_IPV6 #ifdef CONFIG_FEATURE_IPV6
int INET6_resolve(char *name, struct sockaddr_in6 *sin6) int INET6_resolve(char *name, struct sockaddr_in6 *sin6)
{ {
@ -199,7 +199,7 @@ int INET6_resolve(char *name, struct sockaddr_in6 *sin6)
} }
#ifndef IN6_IS_ADDR_UNSPECIFIED #ifndef IN6_IS_ADDR_UNSPECIFIED
#define IN6_IS_ADDR_UNSPECIFIED(a) \ # define IN6_IS_ADDR_UNSPECIFIED(a) \
(((__u32 *) (a))[0] == 0 && ((__u32 *) (a))[1] == 0 && \ (((__u32 *) (a))[0] == 0 && ((__u32 *) (a))[1] == 0 && \
((__u32 *) (a))[2] == 0 && ((__u32 *) (a))[3] == 0) ((__u32 *) (a))[2] == 0 && ((__u32 *) (a))[3] == 0)
#endif #endif

View File

@ -24,7 +24,7 @@
#include "libbb.h" #include "libbb.h"
#if CONFIG_FEATURE_IPV6 #ifdef CONFIG_FEATURE_IPV6
struct hostent *xgethostbyname2(const char *name, int af) struct hostent *xgethostbyname2(const char *name, int af)
{ {
struct hostent *retval; struct hostent *retval;

View File

@ -131,7 +131,7 @@ static void snprint_ip_port(char *ip_port, int size, struct sockaddr *addr, int
{ {
char *port_name; char *port_name;
#if CONFIG_FEATURE_IPV6 #ifdef CONFIG_FEATURE_IPV6
if (addr->sa_family == AF_INET6) { if (addr->sa_family == AF_INET6) {
INET6_rresolve(ip_port, size, (struct sockaddr_in6 *)addr, INET6_rresolve(ip_port, size, (struct sockaddr_in6 *)addr,
(numeric&NETSTAT_NUMERIC) ? 0x0fff : 0); (numeric&NETSTAT_NUMERIC) ? 0x0fff : 0);
@ -156,7 +156,7 @@ static void tcp_do_one(int lnr, const char *line)
const char *state_str; const char *state_str;
char more[512]; char more[512];
int num, local_port, rem_port, d, state, timer_run, uid, timeout; int num, local_port, rem_port, d, state, timer_run, uid, timeout;
#if CONFIG_FEATURE_IPV6 #ifdef CONFIG_FEATURE_IPV6
struct sockaddr_in6 localaddr, remaddr; struct sockaddr_in6 localaddr, remaddr;
char addr6[INET6_ADDRSTRLEN]; char addr6[INET6_ADDRSTRLEN];
struct in6_addr in6; struct in6_addr in6;
@ -176,7 +176,7 @@ static void tcp_do_one(int lnr, const char *line)
&txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more); &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);
if (strlen(local_addr) > 8) { if (strlen(local_addr) > 8) {
#if CONFIG_FEATURE_IPV6 #ifdef CONFIG_FEATURE_IPV6
sscanf(local_addr, "%08X%08X%08X%08X", sscanf(local_addr, "%08X%08X%08X%08X",
&in6.s6_addr32[0], &in6.s6_addr32[1], &in6.s6_addr32[0], &in6.s6_addr32[1],
&in6.s6_addr32[2], &in6.s6_addr32[3]); &in6.s6_addr32[2], &in6.s6_addr32[3]);
@ -226,7 +226,7 @@ static void udp_do_one(int lnr, const char *line)
char local_addr[64], rem_addr[64]; char local_addr[64], rem_addr[64];
char *state_str, more[512]; char *state_str, more[512];
int num, local_port, rem_port, d, state, timer_run, uid, timeout; int num, local_port, rem_port, d, state, timer_run, uid, timeout;
#if CONFIG_FEATURE_IPV6 #ifdef CONFIG_FEATURE_IPV6
struct sockaddr_in6 localaddr, remaddr; struct sockaddr_in6 localaddr, remaddr;
char addr6[INET6_ADDRSTRLEN]; char addr6[INET6_ADDRSTRLEN];
struct in6_addr in6; struct in6_addr in6;
@ -246,7 +246,7 @@ static void udp_do_one(int lnr, const char *line)
&txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more); &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);
if (strlen(local_addr) > 8) { if (strlen(local_addr) > 8) {
#if CONFIG_FEATURE_IPV6 #ifdef CONFIG_FEATURE_IPV6
/* Demangle what the kernel gives us */ /* Demangle what the kernel gives us */
sscanf(local_addr, "%08X%08X%08X%08X", sscanf(local_addr, "%08X%08X%08X%08X",
&in6.s6_addr32[0], &in6.s6_addr32[1], &in6.s6_addr32[0], &in6.s6_addr32[1],
@ -288,8 +288,8 @@ static void udp_do_one(int lnr, const char *line)
break; break;
} }
#if CONFIG_FEATURE_IPV6 #ifdef CONFIG_FEATURE_IPV6
#define notnull(A) (((A.sin6_family == AF_INET6) && \ # define notnull(A) (((A.sin6_family == AF_INET6) && \
((A.sin6_addr.s6_addr32[0]) || \ ((A.sin6_addr.s6_addr32[0]) || \
(A.sin6_addr.s6_addr32[1]) || \ (A.sin6_addr.s6_addr32[1]) || \
(A.sin6_addr.s6_addr32[2]) || \ (A.sin6_addr.s6_addr32[2]) || \
@ -297,7 +297,7 @@ static void udp_do_one(int lnr, const char *line)
((A.sin6_family == AF_INET) && \ ((A.sin6_family == AF_INET) && \
((struct sockaddr_in *) &A)->sin_addr.s_addr)) ((struct sockaddr_in *) &A)->sin_addr.s_addr))
#else #else
#define notnull(A) (A.sin_addr.s_addr) # define notnull(A) (A.sin_addr.s_addr)
#endif #endif
if ((notnull(remaddr) && (flags&NETSTAT_CONNECTED)) || if ((notnull(remaddr) && (flags&NETSTAT_CONNECTED)) ||
(!notnull(remaddr) && (flags&NETSTAT_LISTENING))) (!notnull(remaddr) && (flags&NETSTAT_LISTENING)))
@ -321,7 +321,7 @@ static void raw_do_one(int lnr, const char *line)
char local_addr[64], rem_addr[64]; char local_addr[64], rem_addr[64];
char *state_str, more[512]; char *state_str, more[512];
int num, local_port, rem_port, d, state, timer_run, uid, timeout; int num, local_port, rem_port, d, state, timer_run, uid, timeout;
#if CONFIG_FEATURE_IPV6 #ifdef CONFIG_FEATURE_IPV6
struct sockaddr_in6 localaddr, remaddr; struct sockaddr_in6 localaddr, remaddr;
char addr6[INET6_ADDRSTRLEN]; char addr6[INET6_ADDRSTRLEN];
struct in6_addr in6; struct in6_addr in6;
@ -341,7 +341,7 @@ static void raw_do_one(int lnr, const char *line)
&txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more); &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);
if (strlen(local_addr) > 8) { if (strlen(local_addr) > 8) {
#if CONFIG_FEATURE_IPV6 #ifdef CONFIG_FEATURE_IPV6
sscanf(local_addr, "%08X%08X%08X%08X", sscanf(local_addr, "%08X%08X%08X%08X",
&in6.s6_addr32[0], &in6.s6_addr32[1], &in6.s6_addr32[0], &in6.s6_addr32[1],
&in6.s6_addr32[2], &in6.s6_addr32[3]); &in6.s6_addr32[2], &in6.s6_addr32[3]);
@ -370,8 +370,8 @@ static void raw_do_one(int lnr, const char *line)
} }
state_str=itoa(state); state_str=itoa(state);
#if CONFIG_FEATURE_IPV6 #ifdef CONFIG_FEATURE_IPV6
#define notnull(A) (((A.sin6_family == AF_INET6) && \ # define notnull(A) (((A.sin6_family == AF_INET6) && \
((A.sin6_addr.s6_addr32[0]) || \ ((A.sin6_addr.s6_addr32[0]) || \
(A.sin6_addr.s6_addr32[1]) || \ (A.sin6_addr.s6_addr32[1]) || \
(A.sin6_addr.s6_addr32[2]) || \ (A.sin6_addr.s6_addr32[2]) || \
@ -379,7 +379,7 @@ static void raw_do_one(int lnr, const char *line)
((A.sin6_family == AF_INET) && \ ((A.sin6_family == AF_INET) && \
((struct sockaddr_in *) &A)->sin_addr.s_addr)) ((struct sockaddr_in *) &A)->sin_addr.s_addr))
#else #else
#define notnull(A) (A.sin_addr.s_addr) # define notnull(A) (A.sin_addr.s_addr)
#endif #endif
if ((notnull(remaddr) && (flags&NETSTAT_CONNECTED)) || if ((notnull(remaddr) && (flags&NETSTAT_CONNECTED)) ||
(!notnull(remaddr) && (flags&NETSTAT_LISTENING))) (!notnull(remaddr) && (flags&NETSTAT_LISTENING)))
@ -559,12 +559,12 @@ int netstat_main(int argc, char **argv)
int opt; int opt;
int new_flags=0; int new_flags=0;
int showroute = 0, extended = 0; int showroute = 0, extended = 0;
#if CONFIG_FEATURE_IPV6 #ifdef CONFIG_FEATURE_IPV6
int inet=1; int inet=1;
int inet6=1; int inet6=1;
#else #else
#define inet 1 # define inet 1
#define inet6 0 # define inet6 0
#endif #endif
while ((opt = getopt(argc, argv, "laenrtuwx")) != -1) while ((opt = getopt(argc, argv, "laenrtuwx")) != -1)
switch (opt) { switch (opt) {