aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-09-24 18:27:04 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-09-24 18:27:04 +0000
commit818322b9b19a452d66a07ca69256e2c092f5db5f (patch)
tree0b34390ac0cd61951bb9dc5b9fd3a226dae4f1ef /networking
parenta7ce207bd82882d6436d256a73c42ca4c8500ff3 (diff)
downloadbusybox-w32-818322b9b19a452d66a07ca69256e2c092f5db5f.tar.gz
busybox-w32-818322b9b19a452d66a07ca69256e2c092f5db5f.tar.bz2
busybox-w32-818322b9b19a452d66a07ca69256e2c092f5db5f.zip
*: kill bb_get_last_path_component, replace with two functions
(one which strips trailing slash and one which does not) wget: straighten out as a result of above change text data bss dec hex filename 5056 1 0 5057 13c1 busybox.t4/networking/wget.o 5022 0 0 5022 139e busybox.t5/networking/wget.o
Diffstat (limited to 'networking')
-rw-r--r--networking/wget.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/networking/wget.c b/networking/wget.c
index 5feb539d5..86d6f00ec 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -12,11 +12,11 @@
12struct host_info { 12struct host_info {
13 // May be used if we ever will want to free() all xstrdup()s... 13 // May be used if we ever will want to free() all xstrdup()s...
14 /* char *allocated; */ 14 /* char *allocated; */
15 char *path; 15 const char *path;
16 char *user; 16 const char *user;
17 char *host; 17 char *host;
18 int port; 18 int port;
19 smallint is_ftp; 19 smallint is_ftp;
20}; 20};
21 21
22 22
@@ -318,9 +318,7 @@ static void parse_url(char *src_url, struct host_info *h)
318 p = strchr(h->host, '?'); if (!sp || (p && sp > p)) sp = p; 318 p = strchr(h->host, '?'); if (!sp || (p && sp > p)) sp = p;
319 p = strchr(h->host, '#'); if (!sp || (p && sp > p)) sp = p; 319 p = strchr(h->host, '#'); if (!sp || (p && sp > p)) sp = p;
320 if (!sp) { 320 if (!sp) {
321 /* must be writable because of bb_get_last_path_component() */ 321 h->path = "";
322 static char nullstr[] ALIGN1 = "";
323 h->path = nullstr;
324 } else if (*sp == '/') { 322 } else if (*sp == '/') {
325 *sp = '\0'; 323 *sp = '\0';
326 h->path = sp + 1; 324 h->path = sp + 1;
@@ -328,7 +326,7 @@ static void parse_url(char *src_url, struct host_info *h)
328 // http://busybox.net?login=john@doe is a valid URL 326 // http://busybox.net?login=john@doe is a valid URL
329 // memmove converts to: 327 // memmove converts to:
330 // http:/busybox.nett?login=john@doe... 328 // http:/busybox.nett?login=john@doe...
331 memmove(h->host-1, h->host, sp - h->host); 329 memmove(h->host - 1, h->host, sp - h->host);
332 h->host--; 330 h->host--;
333 sp[-1] = '\0'; 331 sp[-1] = '\0';
334 h->path = sp; 332 h->path = sp;
@@ -497,31 +495,20 @@ int wget_main(int argc, char **argv)
497 } 495 }
498 } 496 }
499 497
500 /* Guess an output filename */ 498 /* Guess an output filename, if there was no -O FILE */
501 if (!fname_out) { 499 if (!fname_out) {
502 // Dirty hack. Needed because bb_get_last_path_component 500 fname_out = bb_get_last_path_component_nostrip(target.path);
503 // will destroy trailing / by storing '\0' in last byte! 501 /* handle "wget http://kernel.org//" */
504 if (!last_char_is(target.path, '/')) { 502 if (fname_out[0] == '/' || !fname_out[0])
505 fname_out = bb_get_last_path_component(target.path);
506#if ENABLE_FEATURE_WGET_STATUSBAR
507 curfile = fname_out;
508#endif
509 }
510 if (!fname_out || !fname_out[0]) {
511 /* bb_get_last_path_component writes
512 * to last '/' only. We don't have one here... */
513 fname_out = (char*)"index.html"; 503 fname_out = (char*)"index.html";
514#if ENABLE_FEATURE_WGET_STATUSBAR 504 /* -P DIR is considered only if there was no -O FILE */
515 curfile = fname_out; 505 if (dir_prefix)
516#endif
517 }
518 if (dir_prefix != NULL)
519 fname_out = concat_path_file(dir_prefix, fname_out); 506 fname_out = concat_path_file(dir_prefix, fname_out);
507 }
520#if ENABLE_FEATURE_WGET_STATUSBAR 508#if ENABLE_FEATURE_WGET_STATUSBAR
521 } else { 509 curfile = bb_get_last_path_component_nostrip(fname_out);
522 curfile = bb_get_last_path_component(fname_out);
523#endif 510#endif
524 } 511
525 /* Impossible? 512 /* Impossible?
526 if ((opt & WGET_OPT_CONTINUE) && !fname_out) 513 if ((opt & WGET_OPT_CONTINUE) && !fname_out)
527 bb_error_msg_and_die("cannot specify continue (-c) without a filename (-O)"); */ 514 bb_error_msg_and_die("cannot specify continue (-c) without a filename (-O)"); */