diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-01-20 16:22:58 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-01-20 16:22:58 +0000 |
commit | 5f825ee6d61df5496ede529d3cbf159531b7838d (patch) | |
tree | 26755386cdc56010b82b1efe14bef5262550e3f4 | |
parent | f914a8af2be457ce735e72a71ebe8c9a19cf4b23 (diff) | |
download | busybox-w32-5f825ee6d61df5496ede529d3cbf159531b7838d.tar.gz busybox-w32-5f825ee6d61df5496ede529d3cbf159531b7838d.tar.bz2 busybox-w32-5f825ee6d61df5496ede529d3cbf159531b7838d.zip |
Apply a patch from Vladimir N. Oleynik <dzo@simtreas.ru>,
and thereby save 64 bytes.
-Erik
-rw-r--r-- | networking/nslookup.c | 37 | ||||
-rw-r--r-- | nslookup.c | 37 |
2 files changed, 36 insertions, 38 deletions
diff --git a/networking/nslookup.c b/networking/nslookup.c index c46a0b8ea..62fea35fa 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c | |||
@@ -45,14 +45,14 @@ | |||
45 | * I could dig through /etc/resolv.conf, but is there a | 45 | * I could dig through /etc/resolv.conf, but is there a |
46 | * better (programatic) way? | 46 | * better (programatic) way? |
47 | */ | 47 | */ |
48 | static void server_fprint(FILE * dst) | 48 | static inline void server_fprint(void) |
49 | { | 49 | { |
50 | fprintf(dst, "Server: %s\n", "default"); | 50 | printf("Server: %s\n", "default"); |
51 | fprintf(dst, "Address: %s\n\n", "default"); | 51 | printf("Address: %s\n\n", "default"); |
52 | } | 52 | } |
53 | 53 | ||
54 | /* only works for IPv4 */ | 54 | /* only works for IPv4 */ |
55 | static int addr_fprint(char *addr, FILE * dst) | 55 | static int addr_fprint(char *addr) |
56 | { | 56 | { |
57 | u_int8_t split[4]; | 57 | u_int8_t split[4]; |
58 | u_int32_t ip; | 58 | u_int32_t ip; |
@@ -63,8 +63,7 @@ static int addr_fprint(char *addr, FILE * dst) | |||
63 | split[1] = (ip & 0x00ff0000) >> 16; | 63 | split[1] = (ip & 0x00ff0000) >> 16; |
64 | split[2] = (ip & 0x0000ff00) >> 8; | 64 | split[2] = (ip & 0x0000ff00) >> 8; |
65 | split[3] = (ip & 0x000000ff); | 65 | split[3] = (ip & 0x000000ff); |
66 | fprintf(dst, "%d.%d.%d.%d", split[0], split[1], split[2], split[3] | 66 | printf("%d.%d.%d.%d", split[0], split[1], split[2], split[3]); |
67 | ); | ||
68 | return 0; | 67 | return 0; |
69 | } | 68 | } |
70 | 69 | ||
@@ -89,30 +88,30 @@ static u_int32_t str_to_addr(const char *addr) | |||
89 | /* takes the NULL-terminated array h_addr_list, and | 88 | /* takes the NULL-terminated array h_addr_list, and |
90 | * prints its contents appropriately | 89 | * prints its contents appropriately |
91 | */ | 90 | */ |
92 | static int addr_list_fprint(char **h_addr_list, FILE * dst) | 91 | static int addr_list_fprint(char **h_addr_list) |
93 | { | 92 | { |
94 | int i, j; | 93 | int i, j; |
95 | char *addr_string = (h_addr_list[1]) | 94 | char *addr_string = (h_addr_list[1]) |
96 | ? "Addresses: " : "Address: "; | 95 | ? "Addresses: " : "Address: "; |
97 | 96 | ||
98 | fprintf(dst, "%s ", addr_string); | 97 | printf("%s ", addr_string); |
99 | for (i = 0, j = 0; h_addr_list[i]; i++, j++) { | 98 | for (i = 0, j = 0; h_addr_list[i]; i++, j++) { |
100 | addr_fprint(h_addr_list[i], dst); | 99 | addr_fprint(h_addr_list[i]); |
101 | 100 | ||
102 | /* real nslookup does this */ | 101 | /* real nslookup does this */ |
103 | if (j == 4) { | 102 | if (j == 4) { |
104 | if (h_addr_list[i + 1]) { | 103 | if (h_addr_list[i + 1]) { |
105 | fprintf(dst, "\n "); | 104 | printf("\n "); |
106 | } | 105 | } |
107 | j = 0; | 106 | j = 0; |
108 | } else { | 107 | } else { |
109 | if (h_addr_list[i + 1]) { | 108 | if (h_addr_list[i + 1]) { |
110 | fprintf(dst, ", "); | 109 | printf(", "); |
111 | } | 110 | } |
112 | } | 111 | } |
113 | 112 | ||
114 | } | 113 | } |
115 | fprintf(dst, "\n"); | 114 | printf("\n"); |
116 | return 0; | 115 | return 0; |
117 | } | 116 | } |
118 | 117 | ||
@@ -126,13 +125,13 @@ static struct hostent *gethostbyaddr_wrapper(const char *address) | |||
126 | } | 125 | } |
127 | 126 | ||
128 | /* print the results as nslookup would */ | 127 | /* print the results as nslookup would */ |
129 | static struct hostent *hostent_fprint(struct hostent *host, FILE * dst) | 128 | static struct hostent *hostent_fprint(struct hostent *host) |
130 | { | 129 | { |
131 | if (host) { | 130 | if (host) { |
132 | fprintf(dst, "Name: %s\n", host->h_name); | 131 | printf("Name: %s\n", host->h_name); |
133 | addr_list_fprint(host->h_addr_list, dst); | 132 | addr_list_fprint(host->h_addr_list); |
134 | } else { | 133 | } else { |
135 | fprintf(dst, "*** Unknown host\n"); | 134 | printf("*** Unknown host\n"); |
136 | } | 135 | } |
137 | return host; | 136 | return host; |
138 | } | 137 | } |
@@ -160,14 +159,14 @@ int nslookup_main(int argc, char **argv) | |||
160 | usage(nslookup_usage); | 159 | usage(nslookup_usage); |
161 | } | 160 | } |
162 | 161 | ||
163 | server_fprint(stdout); | 162 | server_fprint(); |
164 | if (is_ip_address(argv[1])) { | 163 | if (is_ip_address(argv[1])) { |
165 | host = gethostbyaddr_wrapper(argv[1]); | 164 | host = gethostbyaddr_wrapper(argv[1]); |
166 | } else { | 165 | } else { |
167 | host = gethostbyname(argv[1]); | 166 | host = gethostbyname(argv[1]); |
168 | } | 167 | } |
169 | hostent_fprint(host, stdout); | 168 | hostent_fprint(host); |
170 | return EXIT_SUCCESS; | 169 | return EXIT_SUCCESS; |
171 | } | 170 | } |
172 | 171 | ||
173 | /* $Id: nslookup.c,v 1.13 2000/12/01 02:55:13 kraai Exp $ */ | 172 | /* $Id: nslookup.c,v 1.14 2001/01/20 16:22:58 andersen Exp $ */ |
diff --git a/nslookup.c b/nslookup.c index c46a0b8ea..62fea35fa 100644 --- a/nslookup.c +++ b/nslookup.c | |||
@@ -45,14 +45,14 @@ | |||
45 | * I could dig through /etc/resolv.conf, but is there a | 45 | * I could dig through /etc/resolv.conf, but is there a |
46 | * better (programatic) way? | 46 | * better (programatic) way? |
47 | */ | 47 | */ |
48 | static void server_fprint(FILE * dst) | 48 | static inline void server_fprint(void) |
49 | { | 49 | { |
50 | fprintf(dst, "Server: %s\n", "default"); | 50 | printf("Server: %s\n", "default"); |
51 | fprintf(dst, "Address: %s\n\n", "default"); | 51 | printf("Address: %s\n\n", "default"); |
52 | } | 52 | } |
53 | 53 | ||
54 | /* only works for IPv4 */ | 54 | /* only works for IPv4 */ |
55 | static int addr_fprint(char *addr, FILE * dst) | 55 | static int addr_fprint(char *addr) |
56 | { | 56 | { |
57 | u_int8_t split[4]; | 57 | u_int8_t split[4]; |
58 | u_int32_t ip; | 58 | u_int32_t ip; |
@@ -63,8 +63,7 @@ static int addr_fprint(char *addr, FILE * dst) | |||
63 | split[1] = (ip & 0x00ff0000) >> 16; | 63 | split[1] = (ip & 0x00ff0000) >> 16; |
64 | split[2] = (ip & 0x0000ff00) >> 8; | 64 | split[2] = (ip & 0x0000ff00) >> 8; |
65 | split[3] = (ip & 0x000000ff); | 65 | split[3] = (ip & 0x000000ff); |
66 | fprintf(dst, "%d.%d.%d.%d", split[0], split[1], split[2], split[3] | 66 | printf("%d.%d.%d.%d", split[0], split[1], split[2], split[3]); |
67 | ); | ||
68 | return 0; | 67 | return 0; |
69 | } | 68 | } |
70 | 69 | ||
@@ -89,30 +88,30 @@ static u_int32_t str_to_addr(const char *addr) | |||
89 | /* takes the NULL-terminated array h_addr_list, and | 88 | /* takes the NULL-terminated array h_addr_list, and |
90 | * prints its contents appropriately | 89 | * prints its contents appropriately |
91 | */ | 90 | */ |
92 | static int addr_list_fprint(char **h_addr_list, FILE * dst) | 91 | static int addr_list_fprint(char **h_addr_list) |
93 | { | 92 | { |
94 | int i, j; | 93 | int i, j; |
95 | char *addr_string = (h_addr_list[1]) | 94 | char *addr_string = (h_addr_list[1]) |
96 | ? "Addresses: " : "Address: "; | 95 | ? "Addresses: " : "Address: "; |
97 | 96 | ||
98 | fprintf(dst, "%s ", addr_string); | 97 | printf("%s ", addr_string); |
99 | for (i = 0, j = 0; h_addr_list[i]; i++, j++) { | 98 | for (i = 0, j = 0; h_addr_list[i]; i++, j++) { |
100 | addr_fprint(h_addr_list[i], dst); | 99 | addr_fprint(h_addr_list[i]); |
101 | 100 | ||
102 | /* real nslookup does this */ | 101 | /* real nslookup does this */ |
103 | if (j == 4) { | 102 | if (j == 4) { |
104 | if (h_addr_list[i + 1]) { | 103 | if (h_addr_list[i + 1]) { |
105 | fprintf(dst, "\n "); | 104 | printf("\n "); |
106 | } | 105 | } |
107 | j = 0; | 106 | j = 0; |
108 | } else { | 107 | } else { |
109 | if (h_addr_list[i + 1]) { | 108 | if (h_addr_list[i + 1]) { |
110 | fprintf(dst, ", "); | 109 | printf(", "); |
111 | } | 110 | } |
112 | } | 111 | } |
113 | 112 | ||
114 | } | 113 | } |
115 | fprintf(dst, "\n"); | 114 | printf("\n"); |
116 | return 0; | 115 | return 0; |
117 | } | 116 | } |
118 | 117 | ||
@@ -126,13 +125,13 @@ static struct hostent *gethostbyaddr_wrapper(const char *address) | |||
126 | } | 125 | } |
127 | 126 | ||
128 | /* print the results as nslookup would */ | 127 | /* print the results as nslookup would */ |
129 | static struct hostent *hostent_fprint(struct hostent *host, FILE * dst) | 128 | static struct hostent *hostent_fprint(struct hostent *host) |
130 | { | 129 | { |
131 | if (host) { | 130 | if (host) { |
132 | fprintf(dst, "Name: %s\n", host->h_name); | 131 | printf("Name: %s\n", host->h_name); |
133 | addr_list_fprint(host->h_addr_list, dst); | 132 | addr_list_fprint(host->h_addr_list); |
134 | } else { | 133 | } else { |
135 | fprintf(dst, "*** Unknown host\n"); | 134 | printf("*** Unknown host\n"); |
136 | } | 135 | } |
137 | return host; | 136 | return host; |
138 | } | 137 | } |
@@ -160,14 +159,14 @@ int nslookup_main(int argc, char **argv) | |||
160 | usage(nslookup_usage); | 159 | usage(nslookup_usage); |
161 | } | 160 | } |
162 | 161 | ||
163 | server_fprint(stdout); | 162 | server_fprint(); |
164 | if (is_ip_address(argv[1])) { | 163 | if (is_ip_address(argv[1])) { |
165 | host = gethostbyaddr_wrapper(argv[1]); | 164 | host = gethostbyaddr_wrapper(argv[1]); |
166 | } else { | 165 | } else { |
167 | host = gethostbyname(argv[1]); | 166 | host = gethostbyname(argv[1]); |
168 | } | 167 | } |
169 | hostent_fprint(host, stdout); | 168 | hostent_fprint(host); |
170 | return EXIT_SUCCESS; | 169 | return EXIT_SUCCESS; |
171 | } | 170 | } |
172 | 171 | ||
173 | /* $Id: nslookup.c,v 1.13 2000/12/01 02:55:13 kraai Exp $ */ | 172 | /* $Id: nslookup.c,v 1.14 2001/01/20 16:22:58 andersen Exp $ */ |