summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-11-27 14:43:21 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-11-27 14:43:21 +0000
commitd686a045c8134d3a42fa5cc6b2e09118e08d603f (patch)
tree38f509fc9556f68f758c77b06b480cc33b2725eb /networking
parent8a0a83d503a7971895254efa9e79cf15ba1850d4 (diff)
downloadbusybox-w32-d686a045c8134d3a42fa5cc6b2e09118e08d603f.tar.gz
busybox-w32-d686a045c8134d3a42fa5cc6b2e09118e08d603f.tar.bz2
busybox-w32-d686a045c8134d3a42fa5cc6b2e09118e08d603f.zip
safe_strtoXX interface proved to be a bit unconvenient.
Remove it, introduce saner bb_strtoXX. Saved ~350 bytes.
Diffstat (limited to 'networking')
-rw-r--r--networking/ftpgetput.c3
-rw-r--r--networking/udhcp/files.c6
-rw-r--r--networking/wget.c12
3 files changed, 13 insertions, 8 deletions
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index fa1854903..3773f9937 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -124,7 +124,8 @@ int ftp_receive(ftp_host_info_t *server, FILE *control_stream,
124 fd_data = xconnect_ftpdata(server, buf); 124 fd_data = xconnect_ftpdata(server, buf);
125 125
126 if (ftpcmd("SIZE ", server_path, control_stream, buf) == 213) { 126 if (ftpcmd("SIZE ", server_path, control_stream, buf) == 213) {
127 if (SAFE_STRTOOFF(buf + 4, &filesize)) 127 filesize = BB_STRTOOFF(buf + 4, NULL, 10);
128 if (errno || filesize < 0)
128 bb_error_msg_and_die("SIZE error: %s", buf + 4); 129 bb_error_msg_and_die("SIZE error: %s", buf + 4);
129 } else { 130 } else {
130 filesize = -1; 131 filesize = -1;
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index 829d7e960..5e399e1f8 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -64,7 +64,8 @@ static int read_str(const char *line, void *arg)
64 64
65static int read_u32(const char *line, void *arg) 65static int read_u32(const char *line, void *arg)
66{ 66{
67 return safe_strtou32(line, (uint32_t*)arg) == 0; 67 *((uint32_t*)arg) = bb_strtou32(line, NULL, 10);
68 return errno == 0;
68} 69}
69 70
70 71
@@ -101,7 +102,8 @@ static void attach_option(struct option_set **opt_list,
101 struct option_set *existing, *new, **curr; 102 struct option_set *existing, *new, **curr;
102 103
103 /* add it to an existing option */ 104 /* add it to an existing option */
104 if ((existing = find_option(*opt_list, option->code))) { 105 existing = find_option(*opt_list, option->code);
106 if (existing) {
105 DEBUG("Attaching option %s to existing member of list", option->name); 107 DEBUG("Attaching option %s to existing member of list", option->name);
106 if (option->flags & OPTION_LIST) { 108 if (option->flags & OPTION_LIST) {
107 if (existing->data[OPT_LEN] + length <= 255) { 109 if (existing->data[OPT_LEN] + length <= 255) {
diff --git a/networking/wget.c b/networking/wget.c
index 1e51ce96b..49ebda73c 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -335,7 +335,8 @@ int wget_main(int argc, char **argv)
335 */ 335 */
336 while ((s = gethdr(buf, sizeof(buf), sfp, &n)) != NULL) { 336 while ((s = gethdr(buf, sizeof(buf), sfp, &n)) != NULL) {
337 if (strcasecmp(buf, "content-length") == 0) { 337 if (strcasecmp(buf, "content-length") == 0) {
338 if (SAFE_STRTOOFF(s, &content_len) || content_len < 0) { 338 content_len = BB_STRTOOFF(s, NULL, 10);
339 if (errno || content_len < 0) {
339 bb_error_msg_and_die("content-length %s is garbage", s); 340 bb_error_msg_and_die("content-length %s is garbage", s);
340 } 341 }
341 got_clen = 1; 342 got_clen = 1;
@@ -402,7 +403,8 @@ int wget_main(int argc, char **argv)
402 * Querying file size 403 * Querying file size
403 */ 404 */
404 if (ftpcmd("SIZE ", target.path, sfp, buf) == 213) { 405 if (ftpcmd("SIZE ", target.path, sfp, buf) == 213) {
405 if (SAFE_STRTOOFF(buf+4, &content_len) || content_len < 0) { 406 content_len = BB_STRTOOFF(buf+4, NULL, 10);
407 if (errno || content_len < 0) {
406 bb_error_msg_and_die("SIZE value is garbage"); 408 bb_error_msg_and_die("SIZE value is garbage");
407 } 409 }
408 got_clen = 1; 410 got_clen = 1;
@@ -437,7 +439,7 @@ int wget_main(int argc, char **argv)
437 } 439 }
438 440
439 if (ftpcmd("RETR ", target.path, sfp, buf) > 150) 441 if (ftpcmd("RETR ", target.path, sfp, buf) > 150)
440 bb_error_msg_and_die("bad response to %s: %s", "RETR", buf); 442 bb_error_msg_and_die("bad response to RETR: %s", buf);
441 } 443 }
442 444
443 445
@@ -446,7 +448,7 @@ int wget_main(int argc, char **argv)
446 */ 448 */
447 if (chunked) { 449 if (chunked) {
448 fgets(buf, sizeof(buf), dfp); 450 fgets(buf, sizeof(buf), dfp);
449 content_len = STRTOOFF(buf, (char **) NULL, 16); 451 content_len = STRTOOFF(buf, NULL, 16);
450 /* FIXME: error check?? */ 452 /* FIXME: error check?? */
451 } 453 }
452 454
@@ -480,7 +482,7 @@ int wget_main(int argc, char **argv)
480 if (chunked) { 482 if (chunked) {
481 safe_fgets(buf, sizeof(buf), dfp); /* This is a newline */ 483 safe_fgets(buf, sizeof(buf), dfp); /* This is a newline */
482 safe_fgets(buf, sizeof(buf), dfp); 484 safe_fgets(buf, sizeof(buf), dfp);
483 content_len = STRTOOFF(buf, (char **) NULL, 16); 485 content_len = STRTOOFF(buf, NULL, 16);
484 /* FIXME: error check? */ 486 /* FIXME: error check? */
485 if (content_len == 0) { 487 if (content_len == 0) {
486 chunked = 0; /* all done! */ 488 chunked = 0; /* all done! */