diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-01-30 22:40:05 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-01-30 22:40:05 +0000 |
commit | 39cdf4e2ab484fd3173ea43a2a882f569c7f01e8 (patch) | |
tree | c293559cc7a35a2975860facf9d711ebcee78f36 /networking | |
parent | ad84a516bb825f987d7d5c2e05270449fb408c04 (diff) | |
download | busybox-w32-39cdf4e2ab484fd3173ea43a2a882f569c7f01e8.tar.gz busybox-w32-39cdf4e2ab484fd3173ea43a2a882f569c7f01e8.tar.bz2 busybox-w32-39cdf4e2ab484fd3173ea43a2a882f569c7f01e8.zip |
Use proper C99 types
Diffstat (limited to 'networking')
-rw-r--r-- | networking/nslookup.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/networking/nslookup.c b/networking/nslookup.c index 0f3102e30..329510630 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Copyright (C) 1999,2000 by Lineo, inc. and John Beppu | 5 | * Copyright (C) 1999,2000 by Lineo, inc. and John Beppu |
6 | * Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org> | 6 | * Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org> |
7 | * | 7 | * |
8 | * Correct default name server display and explicit name server option | 8 | * Correct default name server display and explicit name server option |
9 | * added by Ben Zeckel <bzeckel@hmc.edu> June 2001 | 9 | * added by Ben Zeckel <bzeckel@hmc.edu> June 2001 |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
@@ -30,6 +30,7 @@ | |||
30 | #include <string.h> | 30 | #include <string.h> |
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <stdint.h> | ||
33 | #include <netdb.h> | 34 | #include <netdb.h> |
34 | #include <sys/socket.h> | 35 | #include <sys/socket.h> |
35 | #include <sys/types.h> | 36 | #include <sys/types.h> |
@@ -46,9 +47,9 @@ | |||
46 | /* only works for IPv4 */ | 47 | /* only works for IPv4 */ |
47 | static int addr_fprint(char *addr) | 48 | static int addr_fprint(char *addr) |
48 | { | 49 | { |
49 | u_int8_t split[4]; | 50 | uint8_t split[4]; |
50 | u_int32_t ip; | 51 | uint32_t ip; |
51 | u_int32_t *x = (u_int32_t *) addr; | 52 | uint32_t *x = (uint32_t *) addr; |
52 | 53 | ||
53 | ip = ntohl(*x); | 54 | ip = ntohl(*x); |
54 | split[0] = (ip & 0xff000000) >> 24; | 55 | split[0] = (ip & 0xff000000) >> 24; |
@@ -102,12 +103,12 @@ static struct hostent *hostent_fprint(struct hostent *host, const char *server_h | |||
102 | } | 103 | } |
103 | 104 | ||
104 | /* changes a c-string matching the perl regex \d+\.\d+\.\d+\.\d+ | 105 | /* changes a c-string matching the perl regex \d+\.\d+\.\d+\.\d+ |
105 | * into a u_int32_t | 106 | * into a uint32_t |
106 | */ | 107 | */ |
107 | static u_int32_t str_to_addr(const char *addr) | 108 | static uint32_t str_to_addr(const char *addr) |
108 | { | 109 | { |
109 | u_int32_t split[4]; | 110 | uint32_t split[4]; |
110 | u_int32_t ip; | 111 | uint32_t ip; |
111 | 112 | ||
112 | sscanf(addr, "%d.%d.%d.%d", | 113 | sscanf(addr, "%d.%d.%d.%d", |
113 | &split[0], &split[1], &split[2], &split[3]); | 114 | &split[0], &split[1], &split[2], &split[3]); |
@@ -144,12 +145,12 @@ static inline void set_default_dns(char *server) | |||
144 | { | 145 | { |
145 | struct in_addr server_in_addr; | 146 | struct in_addr server_in_addr; |
146 | 147 | ||
147 | if(inet_aton(server,&server_in_addr)) | 148 | if(inet_aton(server,&server_in_addr)) |
148 | { | 149 | { |
149 | _res.nscount = 1; | 150 | _res.nscount = 1; |
150 | _res.nsaddr_list[0].sin_addr = server_in_addr; | 151 | _res.nsaddr_list[0].sin_addr = server_in_addr; |
151 | } | 152 | } |
152 | } | 153 | } |
153 | 154 | ||
154 | /* naive function to check whether char *s is an ip address */ | 155 | /* naive function to check whether char *s is an ip address */ |
155 | static int is_ip_address(const char *s) | 156 | static int is_ip_address(const char *s) |
@@ -173,18 +174,18 @@ int nslookup_main(int argc, char **argv) | |||
173 | * initialize DNS structure _res used in printing the default | 174 | * initialize DNS structure _res used in printing the default |
174 | * name server and in the explicit name server option feature. | 175 | * name server and in the explicit name server option feature. |
175 | */ | 176 | */ |
176 | 177 | ||
177 | res_init(); | 178 | res_init(); |
178 | 179 | ||
179 | /* | 180 | /* |
180 | * We allow 1 or 2 arguments. | 181 | * We allow 1 or 2 arguments. |
181 | * The first is the name to be looked up and the second is an | 182 | * The first is the name to be looked up and the second is an |
182 | * optional DNS server with which to do the lookup. | 183 | * optional DNS server with which to do the lookup. |
183 | * More than 3 arguments is an error to follow the pattern of the | 184 | * More than 3 arguments is an error to follow the pattern of the |
184 | * standard nslookup | 185 | * standard nslookup |
185 | */ | 186 | */ |
186 | 187 | ||
187 | if (argc < 2 || *argv[1]=='-' || argc > 3) | 188 | if (argc < 2 || *argv[1]=='-' || argc > 3) |
188 | bb_show_usage(); | 189 | bb_show_usage(); |
189 | else if(argc == 3) | 190 | else if(argc == 3) |
190 | set_default_dns(argv[2]); | 191 | set_default_dns(argv[2]); |
@@ -199,4 +200,4 @@ int nslookup_main(int argc, char **argv) | |||
199 | return EXIT_SUCCESS; | 200 | return EXIT_SUCCESS; |
200 | } | 201 | } |
201 | 202 | ||
202 | /* $Id: nslookup.c,v 1.30 2003/03/19 09:12:38 mjn3 Exp $ */ | 203 | /* $Id: nslookup.c,v 1.31 2004/01/30 22:40:05 andersen Exp $ */ |