diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-22 22:46:04 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-22 22:46:04 +0000 |
commit | 5de9e9ce0bcc5aacb53ec45e36b3fa6b5c7ab5f6 (patch) | |
tree | 5ef5305297b2b964500873bed682f31b12d1479e /networking/nslookup.c | |
parent | 9adc6ced4fcab4d8a068874c55d5f563ce9e62f9 (diff) | |
download | busybox-w32-5de9e9ce0bcc5aacb53ec45e36b3fa6b5c7ab5f6.tar.gz busybox-w32-5de9e9ce0bcc5aacb53ec45e36b3fa6b5c7ab5f6.tar.bz2 busybox-w32-5de9e9ce0bcc5aacb53ec45e36b3fa6b5c7ab5f6.zip |
clean up commented out old code
Diffstat (limited to 'networking/nslookup.c')
-rw-r--r-- | networking/nslookup.c | 55 |
1 files changed, 1 insertions, 54 deletions
diff --git a/networking/nslookup.c b/networking/nslookup.c index af0816215..914f3f5ee 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c | |||
@@ -47,57 +47,8 @@ | |||
47 | * ns3.kernel.org internet address = 204.152.191.36 | 47 | * ns3.kernel.org internet address = 204.152.191.36 |
48 | */ | 48 | */ |
49 | 49 | ||
50 | /*static int sockaddr_to_dotted(struct sockaddr *saddr, char *buf, int buflen) | ||
51 | { | ||
52 | if (buflen <= 0) return -1; | ||
53 | buf[0] = '\0'; | ||
54 | if (saddr->sa_family == AF_INET) { | ||
55 | inet_ntop(AF_INET, &((struct sockaddr_in*)saddr)->sin_addr, buf, buflen); | ||
56 | return 0; | ||
57 | } | ||
58 | if (saddr->sa_family == AF_INET6) { | ||
59 | inet_ntop(AF_INET6, &((struct sockaddr_in6*)saddr)->sin6_addr, buf, buflen); | ||
60 | return 0; | ||
61 | } | ||
62 | return -1; | ||
63 | } | ||
64 | */ | ||
65 | |||
66 | static int print_host(const char *hostname, const char *header) | 50 | static int print_host(const char *hostname, const char *header) |
67 | { | 51 | { |
68 | #if 0 | ||
69 | char str[128]; /* IPv6 address will fit, hostnames hopefully too */ | ||
70 | struct addrinfo *result = NULL; | ||
71 | int rc; | ||
72 | struct addrinfo hint; | ||
73 | |||
74 | memset(&hint, 0 , sizeof(hint)); | ||
75 | /* hint.ai_family = AF_UNSPEC; - zero anyway */ | ||
76 | /* Needed. Or else we will get each address thrice (or more) | ||
77 | * for each possible socket type (tcp,udp,raw...): */ | ||
78 | hint.ai_socktype = SOCK_STREAM; | ||
79 | // hint.ai_flags = AI_CANONNAME; | ||
80 | rc = getaddrinfo(hostname, NULL /*service*/, &hint, &result); | ||
81 | |||
82 | if (!rc) { | ||
83 | struct addrinfo *cur = result; | ||
84 | // printf("%s\n", cur->ai_canonname); ? | ||
85 | while (cur) { | ||
86 | sockaddr_to_dotted(cur->ai_addr, str, sizeof(str)); | ||
87 | printf("%s %s\nAddress: %s", header, hostname, str); | ||
88 | str[0] = ' '; | ||
89 | if (getnameinfo(cur->ai_addr, cur->ai_addrlen, str+1, sizeof(str)-1, NULL, 0, NI_NAMEREQD)) | ||
90 | str[0] = '\0'; | ||
91 | puts(str); | ||
92 | cur = cur->ai_next; | ||
93 | } | ||
94 | } else { | ||
95 | bb_error_msg("getaddrinfo('%s') failed: %s", hostname, gai_strerror(rc)); | ||
96 | } | ||
97 | freeaddrinfo(result); | ||
98 | return (rc != 0); | ||
99 | |||
100 | #else | ||
101 | /* We can't use host2sockaddr() - we want to get ALL addresses, | 52 | /* We can't use host2sockaddr() - we want to get ALL addresses, |
102 | * not just one */ | 53 | * not just one */ |
103 | 54 | ||
@@ -136,7 +87,7 @@ static int print_host(const char *hostname, const char *header) | |||
136 | } | 87 | } |
137 | } else { | 88 | } else { |
138 | #if ENABLE_VERBOSE_RESOLUTION_ERRORS | 89 | #if ENABLE_VERBOSE_RESOLUTION_ERRORS |
139 | bb_error_msg("getaddrinfo('%s') failed: %s", hostname, gai_strerror(rc)); | 90 | bb_error_msg("can't resolve '%s': %s", hostname, gai_strerror(rc)); |
140 | #else | 91 | #else |
141 | bb_error_msg("can't resolve '%s'", hostname); | 92 | bb_error_msg("can't resolve '%s'", hostname); |
142 | #endif | 93 | #endif |
@@ -144,10 +95,8 @@ static int print_host(const char *hostname, const char *header) | |||
144 | if (ENABLE_FEATURE_CLEAN_UP) | 95 | if (ENABLE_FEATURE_CLEAN_UP) |
145 | freeaddrinfo(result); | 96 | freeaddrinfo(result); |
146 | return (rc != 0); | 97 | return (rc != 0); |
147 | #endif | ||
148 | } | 98 | } |
149 | 99 | ||
150 | |||
151 | /* lookup the default nameserver and display it */ | 100 | /* lookup the default nameserver and display it */ |
152 | static void server_print(void) | 101 | static void server_print(void) |
153 | { | 102 | { |
@@ -167,7 +116,6 @@ static void server_print(void) | |||
167 | puts(""); | 116 | puts(""); |
168 | } | 117 | } |
169 | 118 | ||
170 | |||
171 | /* alter the global _res nameserver structure to use | 119 | /* alter the global _res nameserver structure to use |
172 | an explicit dns server instead of what is in /etc/resolv.h */ | 120 | an explicit dns server instead of what is in /etc/resolv.h */ |
173 | static void set_default_dns(char *server) | 121 | static void set_default_dns(char *server) |
@@ -180,7 +128,6 @@ static void set_default_dns(char *server) | |||
180 | } | 128 | } |
181 | } | 129 | } |
182 | 130 | ||
183 | |||
184 | int nslookup_main(int argc, char **argv) | 131 | int nslookup_main(int argc, char **argv) |
185 | { | 132 | { |
186 | /* We allow 1 or 2 arguments. | 133 | /* We allow 1 or 2 arguments. |