diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
commit | cad5364599eb5062d59e0c397ed638ddd61a8d5d (patch) | |
tree | a318d0f03aa076c74b576ea45dc543a5669e8e91 /networking/wget.c | |
parent | e01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff) | |
download | busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.bz2 busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip |
Major coreutils update.
Diffstat (limited to 'networking/wget.c')
-rw-r--r-- | networking/wget.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/networking/wget.c b/networking/wget.c index 7154faa11..d68b16524 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -123,7 +123,7 @@ static char *safe_fgets(char *s, int size, FILE *stream) | |||
123 | 123 | ||
124 | #define close_delete_and_die(s...) { \ | 124 | #define close_delete_and_die(s...) { \ |
125 | close_and_delete_outfile(output, fname_out, do_continue); \ | 125 | close_and_delete_outfile(output, fname_out, do_continue); \ |
126 | error_msg_and_die(s); } | 126 | bb_error_msg_and_die(s); } |
127 | 127 | ||
128 | 128 | ||
129 | #ifdef CONFIG_FEATURE_WGET_AUTHENTICATION | 129 | #ifdef CONFIG_FEATURE_WGET_AUTHENTICATION |
@@ -140,7 +140,7 @@ char *base64enc(char *p, char *buf, int len) { | |||
140 | 140 | ||
141 | while(*p) { | 141 | while(*p) { |
142 | if (s >= buf+len-4) | 142 | if (s >= buf+len-4) |
143 | error_msg_and_die("buffer overflow"); | 143 | bb_error_msg_and_die("buffer overflow"); |
144 | *(s++) = al[(*p >> 2) & 0x3F]; | 144 | *(s++) = al[(*p >> 2) & 0x3F]; |
145 | *(s++) = al[((*p << 4) & 0x30) | ((*(p+1) >> 4) & 0x0F)]; | 145 | *(s++) = al[((*p << 4) & 0x30) | ((*(p+1) >> 4) & 0x0F)]; |
146 | *s = *(s+1) = '='; | 146 | *s = *(s+1) = '='; |
@@ -221,7 +221,7 @@ int wget_main(int argc, char **argv) | |||
221 | case LONG_HEADER: { | 221 | case LONG_HEADER: { |
222 | int arglen = strlen(optarg); | 222 | int arglen = strlen(optarg); |
223 | if(extra_headers_left - arglen - 2 <= 0) | 223 | if(extra_headers_left - arglen - 2 <= 0) |
224 | error_msg_and_die("extra_headers buffer too small(need %i)", extra_headers_left - arglen); | 224 | bb_error_msg_and_die("extra_headers buffer too small(need %i)", extra_headers_left - arglen); |
225 | strcpy(extra_headers_ptr, optarg); | 225 | strcpy(extra_headers_ptr, optarg); |
226 | extra_headers_ptr += arglen; | 226 | extra_headers_ptr += arglen; |
227 | extra_headers_left -= ( arglen + 2 ); | 227 | extra_headers_left -= ( arglen + 2 ); |
@@ -236,12 +236,12 @@ int wget_main(int argc, char **argv) | |||
236 | } | 236 | } |
237 | break; | 237 | break; |
238 | default: | 238 | default: |
239 | show_usage(); | 239 | bb_show_usage(); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | if (argc - optind != 1) | 243 | if (argc - optind != 1) |
244 | show_usage(); | 244 | bb_show_usage(); |
245 | 245 | ||
246 | parse_url(argv[optind], &target); | 246 | parse_url(argv[optind], &target); |
247 | server.host = target.host; | 247 | server.host = target.host; |
@@ -253,7 +253,7 @@ int wget_main(int argc, char **argv) | |||
253 | if (!noproxy) { | 253 | if (!noproxy) { |
254 | proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy"); | 254 | proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy"); |
255 | if (proxy) | 255 | if (proxy) |
256 | parse_url(xstrdup(proxy), &server); | 256 | parse_url(bb_xstrdup(proxy), &server); |
257 | } | 257 | } |
258 | 258 | ||
259 | /* Guess an output filename */ | 259 | /* Guess an output filename */ |
@@ -262,7 +262,7 @@ int wget_main(int argc, char **argv) | |||
262 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR | 262 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
263 | curfile = | 263 | curfile = |
264 | #endif | 264 | #endif |
265 | get_last_path_component(target.path); | 265 | bb_get_last_path_component(target.path); |
266 | if (fname_out==NULL || strlen(fname_out)<1) { | 266 | if (fname_out==NULL || strlen(fname_out)<1) { |
267 | fname_out = | 267 | fname_out = |
268 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR | 268 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
@@ -274,11 +274,11 @@ int wget_main(int argc, char **argv) | |||
274 | fname_out = concat_path_file(dir_prefix, fname_out); | 274 | fname_out = concat_path_file(dir_prefix, fname_out); |
275 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR | 275 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
276 | } else { | 276 | } else { |
277 | curfile = get_last_path_component(fname_out); | 277 | curfile = bb_get_last_path_component(fname_out); |
278 | #endif | 278 | #endif |
279 | } | 279 | } |
280 | if (do_continue && !fname_out) | 280 | if (do_continue && !fname_out) |
281 | error_msg_and_die("cannot specify continue (-c) without a filename (-O)"); | 281 | bb_error_msg_and_die("cannot specify continue (-c) without a filename (-O)"); |
282 | 282 | ||
283 | 283 | ||
284 | /* | 284 | /* |
@@ -288,7 +288,7 @@ int wget_main(int argc, char **argv) | |||
288 | output = stdout; | 288 | output = stdout; |
289 | quiet_flag = TRUE; | 289 | quiet_flag = TRUE; |
290 | } else { | 290 | } else { |
291 | output = xfopen(fname_out, (do_continue ? "a" : "w")); | 291 | output = bb_xfopen(fname_out, (do_continue ? "a" : "w")); |
292 | } | 292 | } |
293 | 293 | ||
294 | /* | 294 | /* |
@@ -296,7 +296,7 @@ int wget_main(int argc, char **argv) | |||
296 | */ | 296 | */ |
297 | if (do_continue) { | 297 | if (do_continue) { |
298 | if (fstat(fileno(output), &sbuf) < 0) | 298 | if (fstat(fileno(output), &sbuf) < 0) |
299 | perror_msg_and_die("fstat()"); | 299 | bb_perror_msg_and_die("fstat()"); |
300 | if (sbuf.st_size > 0) | 300 | if (sbuf.st_size > 0) |
301 | beg_range = sbuf.st_size; | 301 | beg_range = sbuf.st_size; |
302 | else | 302 | else |
@@ -399,9 +399,9 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) | |||
399 | } | 399 | } |
400 | if (strcasecmp(buf, "location") == 0) { | 400 | if (strcasecmp(buf, "location") == 0) { |
401 | if (s[0] == '/') | 401 | if (s[0] == '/') |
402 | target.path = xstrdup(s+1); | 402 | target.path = bb_xstrdup(s+1); |
403 | else { | 403 | else { |
404 | parse_url(xstrdup(s), &target); | 404 | parse_url(bb_xstrdup(s), &target); |
405 | if (!proxy) { | 405 | if (!proxy) { |
406 | server.host = target.host; | 406 | server.host = target.host; |
407 | server.port = target.port; | 407 | server.port = target.port; |
@@ -419,7 +419,7 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) | |||
419 | * FTP session | 419 | * FTP session |
420 | */ | 420 | */ |
421 | if (! target.user) | 421 | if (! target.user) |
422 | target.user = xstrdup("anonymous:busybox@"); | 422 | target.user = bb_xstrdup("anonymous:busybox@"); |
423 | 423 | ||
424 | sfp = open_socket(server.host, server.port); | 424 | sfp = open_socket(server.host, server.port); |
425 | if (ftpcmd(NULL, NULL, sfp, buf) != 220) | 425 | if (ftpcmd(NULL, NULL, sfp, buf) != 220) |
@@ -496,7 +496,7 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) | |||
496 | do { | 496 | do { |
497 | while ((filesize > 0 || !got_clen) && (n = safe_fread(buf, 1, chunked ? (filesize > sizeof(buf) ? sizeof(buf) : filesize) : sizeof(buf), dfp)) > 0) { | 497 | while ((filesize > 0 || !got_clen) && (n = safe_fread(buf, 1, chunked ? (filesize > sizeof(buf) ? sizeof(buf) : filesize) : sizeof(buf), dfp)) > 0) { |
498 | if (safe_fwrite(buf, 1, n, output) != n) | 498 | if (safe_fwrite(buf, 1, n, output) != n) |
499 | perror_msg_and_die("write error"); | 499 | bb_perror_msg_and_die("write error"); |
500 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR | 500 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
501 | statbytes+=n; | 501 | statbytes+=n; |
502 | #endif | 502 | #endif |
@@ -512,7 +512,7 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) | |||
512 | } | 512 | } |
513 | 513 | ||
514 | if (n == 0 && ferror(dfp)) | 514 | if (n == 0 && ferror(dfp)) |
515 | perror_msg_and_die("network read error"); | 515 | bb_perror_msg_and_die("network read error"); |
516 | } while (chunked); | 516 | } while (chunked); |
517 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR | 517 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
518 | if (quiet_flag==FALSE) | 518 | if (quiet_flag==FALSE) |
@@ -521,7 +521,7 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) | |||
521 | if (!proxy && target.is_ftp) { | 521 | if (!proxy && target.is_ftp) { |
522 | fclose(dfp); | 522 | fclose(dfp); |
523 | if (ftpcmd(NULL, NULL, sfp, buf) != 226) | 523 | if (ftpcmd(NULL, NULL, sfp, buf) != 226) |
524 | error_msg_and_die("ftp error: %s", buf+4); | 524 | bb_error_msg_and_die("ftp error: %s", buf+4); |
525 | ftpcmd("QUIT", NULL, sfp, buf); | 525 | ftpcmd("QUIT", NULL, sfp, buf); |
526 | } | 526 | } |
527 | exit(EXIT_SUCCESS); | 527 | exit(EXIT_SUCCESS); |
@@ -541,14 +541,14 @@ void parse_url(char *url, struct host_info *h) | |||
541 | h->host = url + 6; | 541 | h->host = url + 6; |
542 | h->is_ftp = 1; | 542 | h->is_ftp = 1; |
543 | } else | 543 | } else |
544 | error_msg_and_die("not an http or ftp url: %s", url); | 544 | bb_error_msg_and_die("not an http or ftp url: %s", url); |
545 | 545 | ||
546 | sp = strchr(h->host, '/'); | 546 | sp = strchr(h->host, '/'); |
547 | if (sp != NULL) { | 547 | if (sp != NULL) { |
548 | *sp++ = '\0'; | 548 | *sp++ = '\0'; |
549 | h->path = sp; | 549 | h->path = sp; |
550 | } else | 550 | } else |
551 | h->path = xstrdup(""); | 551 | h->path = bb_xstrdup(""); |
552 | 552 | ||
553 | up = strrchr(h->host, '@'); | 553 | up = strrchr(h->host, '@'); |
554 | if (up != NULL) { | 554 | if (up != NULL) { |
@@ -580,7 +580,7 @@ FILE *open_socket(char *host, int port) | |||
580 | * Get the server onto a stdio stream. | 580 | * Get the server onto a stdio stream. |
581 | */ | 581 | */ |
582 | if ((fp = fdopen(fd, "r+")) == NULL) | 582 | if ((fp = fdopen(fd, "r+")) == NULL) |
583 | perror_msg_and_die("fdopen()"); | 583 | bb_perror_msg_and_die("fdopen()"); |
584 | 584 | ||
585 | return fp; | 585 | return fp; |
586 | } | 586 | } |
@@ -609,7 +609,7 @@ char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc) | |||
609 | 609 | ||
610 | /* verify we are at the end of the header name */ | 610 | /* verify we are at the end of the header name */ |
611 | if (*s != ':') | 611 | if (*s != ':') |
612 | error_msg_and_die("bad header line: %s", buf); | 612 | bb_error_msg_and_die("bad header line: %s", buf); |
613 | 613 | ||
614 | /* locate the start of the header value */ | 614 | /* locate the start of the header value */ |
615 | for (*s++ = '\0' ; *s == ' ' || *s == '\t' ; ++s) | 615 | for (*s++ = '\0' ; *s == ' ' || *s == '\t' ; ++s) |
@@ -646,7 +646,7 @@ static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf) | |||
646 | do { | 646 | do { |
647 | p = fgets(buf, 510, fp); | 647 | p = fgets(buf, 510, fp); |
648 | if (!p) | 648 | if (!p) |
649 | perror_msg_and_die("fgets()"); | 649 | bb_perror_msg_and_die("fgets()"); |
650 | } while (! isdigit(buf[0]) || buf[3] != ' '); | 650 | } while (! isdigit(buf[0]) || buf[3] != ' '); |
651 | 651 | ||
652 | return atoi(buf); | 652 | return atoi(buf); |
@@ -824,7 +824,7 @@ progressmeter(int flag) | |||
824 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 824 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
825 | * SUCH DAMAGE. | 825 | * SUCH DAMAGE. |
826 | * | 826 | * |
827 | * $Id: wget.c,v 1.52 2003/03/11 18:03:39 andersen Exp $ | 827 | * $Id: wget.c,v 1.53 2003/03/19 09:12:39 mjn3 Exp $ |
828 | */ | 828 | */ |
829 | 829 | ||
830 | 830 | ||