Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 3 | * wget - retrieve a file using HTTP or FTP |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 4 | * |
Eric Andersen | 4e573f4 | 2000-11-14 23:29:24 +0000 | [diff] [blame] | 5 | * Chip Rosenthal Covad Communications <chip@laserlink.net> |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 6 | * |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
Rob Landley | af12cb3 | 2006-06-27 18:41:03 +0000 | [diff] [blame] | 9 | #include "busybox.h" |
Eric Andersen | 50ae310 | 2001-05-15 17:51:37 +0000 | [diff] [blame] | 10 | #include <getopt.h> |
| 11 | |
Eric Andersen | cbe31da | 2001-02-20 06:14:08 +0000 | [diff] [blame] | 12 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 13 | struct host_info { |
| 14 | char *host; |
| 15 | int port; |
| 16 | char *path; |
| 17 | int is_ftp; |
| 18 | char *user; |
| 19 | }; |
| 20 | |
| 21 | static void parse_url(char *url, struct host_info *h); |
Glenn L McGrath | ffccf6e | 2003-12-20 01:47:18 +0000 | [diff] [blame] | 22 | static FILE *open_socket(struct sockaddr_in *s_in); |
Eric Andersen | 3e6ff90 | 2001-03-09 21:24:12 +0000 | [diff] [blame] | 23 | static char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 24 | static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf); |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 25 | |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 26 | /* Globals (can be accessed from signal handlers */ |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 27 | static off_t filesize; /* content-length of the file */ |
| 28 | static int chunked; /* chunked transfer encoding */ |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 29 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
Eric Andersen | 20aab26 | 2001-07-19 22:28:02 +0000 | [diff] [blame] | 30 | static void progressmeter(int flag); |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 31 | static char *curfile; /* Name of current file being transferred. */ |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 32 | static struct timeval start; /* Time a transfer started. */ |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 33 | static off_t transferred; /* Number of bytes transferred so far. */ |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 34 | /* For progressmeter() -- number of seconds before xfer considered "stalled" */ |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 35 | enum { |
| 36 | STALLTIME = 5 |
| 37 | }; |
| 38 | #else |
Rob Landley | f5fc138 | 2006-09-15 04:08:25 +0000 | [diff] [blame^] | 39 | static void progressmeter(int flag) {} |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 40 | #endif |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 41 | |
Eric Andersen | 3e6ff90 | 2001-03-09 21:24:12 +0000 | [diff] [blame] | 42 | static void close_and_delete_outfile(FILE* output, char *fname_out, int do_continue) |
Eric Andersen | 7d69701 | 2001-01-24 20:28:35 +0000 | [diff] [blame] | 43 | { |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 44 | if (output != stdout && do_continue == 0) { |
Eric Andersen | 7d69701 | 2001-01-24 20:28:35 +0000 | [diff] [blame] | 45 | fclose(output); |
| 46 | unlink(fname_out); |
| 47 | } |
| 48 | } |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 49 | |
Matt Kraai | 854125f | 2001-05-09 19:15:46 +0000 | [diff] [blame] | 50 | /* Read NMEMB elements of SIZE bytes into PTR from STREAM. Returns the |
| 51 | * number of elements read, and a short count if an eof or non-interrupt |
| 52 | * error is encountered. */ |
| 53 | static size_t safe_fread(void *ptr, size_t size, size_t nmemb, FILE *stream) |
| 54 | { |
| 55 | size_t ret = 0; |
| 56 | |
| 57 | do { |
| 58 | clearerr(stream); |
| 59 | ret += fread((char *)ptr + (ret * size), size, nmemb - ret, stream); |
| 60 | } while (ret < nmemb && ferror(stream) && errno == EINTR); |
| 61 | |
| 62 | return ret; |
| 63 | } |
| 64 | |
| 65 | /* Write NMEMB elements of SIZE bytes from PTR to STREAM. Returns the |
| 66 | * number of elements written, and a short count if an eof or non-interrupt |
| 67 | * error is encountered. */ |
| 68 | static size_t safe_fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream) |
| 69 | { |
| 70 | size_t ret = 0; |
| 71 | |
| 72 | do { |
| 73 | clearerr(stream); |
| 74 | ret += fwrite((char *)ptr + (ret * size), size, nmemb - ret, stream); |
| 75 | } while (ret < nmemb && ferror(stream) && errno == EINTR); |
| 76 | |
| 77 | return ret; |
| 78 | } |
| 79 | |
| 80 | /* Read a line or SIZE - 1 bytes into S, whichever is less, from STREAM. |
| 81 | * Returns S, or NULL if an eof or non-interrupt error is encountered. */ |
| 82 | static char *safe_fgets(char *s, int size, FILE *stream) |
| 83 | { |
| 84 | char *ret; |
| 85 | |
| 86 | do { |
| 87 | clearerr(stream); |
| 88 | ret = fgets(s, size, stream); |
| 89 | } while (ret == NULL && ferror(stream) && errno == EINTR); |
| 90 | |
| 91 | return ret; |
| 92 | } |
| 93 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 94 | #define close_delete_and_die(s...) { \ |
| 95 | close_and_delete_outfile(output, fname_out, do_continue); \ |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 96 | bb_error_msg_and_die(s); } |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 97 | |
| 98 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 99 | #ifdef CONFIG_FEATURE_WGET_AUTHENTICATION |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 100 | /* |
Denis Vlasenko | 21afc7d | 2006-09-03 15:49:40 +0000 | [diff] [blame] | 101 | * Base64-encode character string and return the string. |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 102 | */ |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 103 | static char *base64enc(unsigned char *p, char *buf, int len) |
| 104 | { |
Denis Vlasenko | 21afc7d | 2006-09-03 15:49:40 +0000 | [diff] [blame] | 105 | bb_uuencode(p, buf, len, bb_uuenc_tbl_base64); |
Rob Landley | 76ef08c | 2006-06-13 16:44:26 +0000 | [diff] [blame] | 106 | return buf; |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 107 | } |
| 108 | #endif |
| 109 | |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 110 | #define WGET_OPT_CONTINUE 1 |
| 111 | #define WGET_OPT_QUIET 2 |
| 112 | #define WGET_OPT_PASSIVE 4 |
| 113 | #define WGET_OPT_OUTNAME 8 |
| 114 | #define WGET_OPT_HEADER 16 |
| 115 | #define WGET_OPT_PREFIX 32 |
| 116 | #define WGET_OPT_PROXY 64 |
Bernhard Reutner-Fischer | bfbc4eb | 2006-09-02 15:30:26 +0000 | [diff] [blame] | 117 | #define WGET_OPT_USER_AGENT 128 |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 118 | |
Bernhard Reutner-Fischer | 289e86a | 2006-08-20 20:01:24 +0000 | [diff] [blame] | 119 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 120 | static const struct option wget_long_options[] = { |
| 121 | { "continue", 0, NULL, 'c' }, |
| 122 | { "quiet", 0, NULL, 'q' }, |
| 123 | { "passive-ftp", 0, NULL, 139 }, |
| 124 | { "output-document", 1, NULL, 'O' }, |
Rob Landley | 76ef08c | 2006-06-13 16:44:26 +0000 | [diff] [blame] | 125 | { "header", 1, NULL, 131 }, |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 126 | { "directory-prefix",1, NULL, 'P' }, |
| 127 | { "proxy", 1, NULL, 'Y' }, |
Bernhard Reutner-Fischer | bfbc4eb | 2006-09-02 15:30:26 +0000 | [diff] [blame] | 128 | { "user-agent", 1, NULL, 'U' }, |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 129 | { 0, 0, 0, 0 } |
| 130 | }; |
Bernhard Reutner-Fischer | 8d3a6f7 | 2006-05-31 14:11:38 +0000 | [diff] [blame] | 131 | #endif |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 132 | |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 133 | int wget_main(int argc, char **argv) |
| 134 | { |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 135 | int n, try=5, status; |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 136 | unsigned long opt; |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 137 | int port; |
Robert Griebl | d776011 | 2002-05-14 23:36:45 +0000 | [diff] [blame] | 138 | char *proxy = 0; |
Eric Andersen | 8071c02 | 2001-06-21 19:45:06 +0000 | [diff] [blame] | 139 | char *dir_prefix=NULL; |
Eric Andersen | 29edd00 | 2000-12-09 16:55:35 +0000 | [diff] [blame] | 140 | char *s, buf[512]; |
| 141 | struct stat sbuf; |
Eric Andersen | 50ae310 | 2001-05-15 17:51:37 +0000 | [diff] [blame] | 142 | char extra_headers[1024]; |
| 143 | char *extra_headers_ptr = extra_headers; |
| 144 | int extra_headers_left = sizeof(extra_headers); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 145 | struct host_info server, target; |
Eric Andersen | e6dc439 | 2003-10-31 09:31:46 +0000 | [diff] [blame] | 146 | struct sockaddr_in s_in; |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 147 | llist_t *headers_llist = NULL; |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 148 | |
"Vladimir N. Oleynik" | f704b27 | 2005-10-14 09:56:52 +0000 | [diff] [blame] | 149 | FILE *sfp = NULL; /* socket to web/ftp server */ |
| 150 | FILE *dfp = NULL; /* socket to ftp server (data) */ |
| 151 | char *fname_out = NULL; /* where to direct output (-O) */ |
| 152 | int do_continue = 0; /* continue a prev transfer (-c) */ |
| 153 | long beg_range = 0L; /* range at which continue begins */ |
| 154 | int got_clen = 0; /* got content-length: from server */ |
| 155 | FILE *output; /* socket to web server */ |
| 156 | int quiet_flag = FALSE; /* Be verry, verry quiet... */ |
| 157 | int use_proxy = 1; /* Use proxies if env vars are set */ |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 158 | char *proxy_flag = "on"; /* Use proxies if env vars are set */ |
Bernhard Reutner-Fischer | bfbc4eb | 2006-09-02 15:30:26 +0000 | [diff] [blame] | 159 | char *user_agent = "Wget"; /* Content of the "User-Agent" header field */ |
Eric Andersen | 29edd00 | 2000-12-09 16:55:35 +0000 | [diff] [blame] | 160 | |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 161 | /* |
| 162 | * Crack command line. |
| 163 | */ |
"Vladimir N. Oleynik" | f704b27 | 2005-10-14 09:56:52 +0000 | [diff] [blame] | 164 | bb_opt_complementally = "-1:\203::"; |
Bernhard Reutner-Fischer | 289e86a | 2006-08-20 20:01:24 +0000 | [diff] [blame] | 165 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 166 | bb_applet_long_options = wget_long_options; |
Bernhard Reutner-Fischer | 8d3a6f7 | 2006-05-31 14:11:38 +0000 | [diff] [blame] | 167 | #endif |
Bernhard Reutner-Fischer | bfbc4eb | 2006-09-02 15:30:26 +0000 | [diff] [blame] | 168 | opt = bb_getopt_ulflags(argc, argv, "cq\213O:\203:P:Y:U:", |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 169 | &fname_out, &headers_llist, |
Bernhard Reutner-Fischer | bfbc4eb | 2006-09-02 15:30:26 +0000 | [diff] [blame] | 170 | &dir_prefix, &proxy_flag, &user_agent); |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 171 | if (opt & WGET_OPT_CONTINUE) { |
| 172 | ++do_continue; |
| 173 | } |
| 174 | if (opt & WGET_OPT_QUIET) { |
| 175 | quiet_flag = TRUE; |
| 176 | } |
Glenn L McGrath | f1c4b11 | 2004-02-22 00:27:34 +0000 | [diff] [blame] | 177 | if (strcmp(proxy_flag, "off") == 0) { |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 178 | /* Use the proxy if necessary. */ |
Glenn L McGrath | f1c4b11 | 2004-02-22 00:27:34 +0000 | [diff] [blame] | 179 | use_proxy = 0; |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 180 | } |
| 181 | if (opt & WGET_OPT_HEADER) { |
| 182 | while (headers_llist) { |
| 183 | int arglen = strlen(headers_llist->data); |
| 184 | if (extra_headers_left - arglen - 2 <= 0) |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 185 | bb_error_msg_and_die("extra_headers buffer too small " |
| 186 | "(need %i)", extra_headers_left - arglen); |
Glenn L McGrath | 514aeab | 2003-12-19 12:08:56 +0000 | [diff] [blame] | 187 | strcpy(extra_headers_ptr, headers_llist->data); |
| 188 | extra_headers_ptr += arglen; |
| 189 | extra_headers_left -= ( arglen + 2 ); |
| 190 | *extra_headers_ptr++ = '\r'; |
| 191 | *extra_headers_ptr++ = '\n'; |
| 192 | *(extra_headers_ptr + 1) = 0; |
| 193 | headers_llist = headers_llist->link; |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 194 | } |
| 195 | } |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 196 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 197 | parse_url(argv[optind], &target); |
| 198 | server.host = target.host; |
| 199 | server.port = target.port; |
| 200 | |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 201 | /* |
Eric Andersen | f3b2b52 | 2000-12-07 22:42:11 +0000 | [diff] [blame] | 202 | * Use the proxy if necessary. |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 203 | */ |
Glenn L McGrath | f1c4b11 | 2004-02-22 00:27:34 +0000 | [diff] [blame] | 204 | if (use_proxy) { |
Robert Griebl | d776011 | 2002-05-14 23:36:45 +0000 | [diff] [blame] | 205 | proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy"); |
Glenn L McGrath | f1c4b11 | 2004-02-22 00:27:34 +0000 | [diff] [blame] | 206 | if (proxy && *proxy) { |
Rob Landley | d921b2e | 2006-08-03 15:41:12 +0000 | [diff] [blame] | 207 | parse_url(xstrdup(proxy), &server); |
Glenn L McGrath | f1c4b11 | 2004-02-22 00:27:34 +0000 | [diff] [blame] | 208 | } else { |
| 209 | use_proxy = 0; |
| 210 | } |
Robert Griebl | d776011 | 2002-05-14 23:36:45 +0000 | [diff] [blame] | 211 | } |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 212 | |
Eric Andersen | 29edd00 | 2000-12-09 16:55:35 +0000 | [diff] [blame] | 213 | /* Guess an output filename */ |
| 214 | if (!fname_out) { |
Eric Andersen | 751750e | 2004-10-08 08:27:40 +0000 | [diff] [blame] | 215 | // Dirty hack. Needed because bb_get_last_path_component |
| 216 | // will destroy trailing / by storing '\0' in last byte! |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 217 | if (*target.path && target.path[strlen(target.path)-1] != '/') { |
Eric Andersen | 751750e | 2004-10-08 08:27:40 +0000 | [diff] [blame] | 218 | fname_out = |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 219 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
Eric Andersen | 751750e | 2004-10-08 08:27:40 +0000 | [diff] [blame] | 220 | curfile = |
Eric Andersen | 29edd00 | 2000-12-09 16:55:35 +0000 | [diff] [blame] | 221 | #endif |
Eric Andersen | 751750e | 2004-10-08 08:27:40 +0000 | [diff] [blame] | 222 | bb_get_last_path_component(target.path); |
| 223 | } |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 224 | if (fname_out == NULL || strlen(fname_out) < 1) { |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 225 | fname_out = |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 226 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 227 | curfile = |
Eric Andersen | 29edd00 | 2000-12-09 16:55:35 +0000 | [diff] [blame] | 228 | #endif |
| 229 | "index.html"; |
| 230 | } |
Matt Kraai | 0382eb8 | 2001-07-19 19:13:55 +0000 | [diff] [blame] | 231 | if (dir_prefix != NULL) |
| 232 | fname_out = concat_path_file(dir_prefix, fname_out); |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 233 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
Eric Andersen | 29edd00 | 2000-12-09 16:55:35 +0000 | [diff] [blame] | 234 | } else { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 235 | curfile = bb_get_last_path_component(fname_out); |
Eric Andersen | 29edd00 | 2000-12-09 16:55:35 +0000 | [diff] [blame] | 236 | #endif |
| 237 | } |
Eric Andersen | 7d69701 | 2001-01-24 20:28:35 +0000 | [diff] [blame] | 238 | if (do_continue && !fname_out) |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 239 | bb_error_msg_and_die("cannot specify continue (-c) without a filename (-O)"); |
Eric Andersen | 29edd00 | 2000-12-09 16:55:35 +0000 | [diff] [blame] | 240 | |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 241 | |
| 242 | /* |
Eric Andersen | 29edd00 | 2000-12-09 16:55:35 +0000 | [diff] [blame] | 243 | * Open the output file stream. |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 244 | */ |
Matt Kraai | 65317ea | 2001-04-11 20:03:01 +0000 | [diff] [blame] | 245 | if (strcmp(fname_out, "-") == 0) { |
Randolph Chung | 02553a2 | 2000-12-07 03:53:47 +0000 | [diff] [blame] | 246 | output = stdout; |
Eric Andersen | 95a349f | 2001-05-13 00:55:54 +0000 | [diff] [blame] | 247 | quiet_flag = TRUE; |
Matt Kraai | 65317ea | 2001-04-11 20:03:01 +0000 | [diff] [blame] | 248 | } else { |
Rob Landley | d921b2e | 2006-08-03 15:41:12 +0000 | [diff] [blame] | 249 | output = xfopen(fname_out, (do_continue ? "a" : "w")); |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | /* |
| 253 | * Determine where to start transfer. |
| 254 | */ |
| 255 | if (do_continue) { |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 256 | if (fstat(fileno(output), &sbuf) < 0) |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 257 | bb_perror_msg_and_die("fstat"); |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 258 | if (sbuf.st_size > 0) |
| 259 | beg_range = sbuf.st_size; |
| 260 | else |
| 261 | do_continue = 0; |
| 262 | } |
| 263 | |
Eric Andersen | e6dc439 | 2003-10-31 09:31:46 +0000 | [diff] [blame] | 264 | /* We want to do exactly _one_ DNS lookup, since some |
| 265 | * sites (i.e. ftp.us.debian.org) use round-robin DNS |
| 266 | * and we want to connect to only one IP... */ |
Glenn L McGrath | ffccf6e | 2003-12-20 01:47:18 +0000 | [diff] [blame] | 267 | bb_lookup_host(&s_in, server.host); |
| 268 | s_in.sin_port = server.port; |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 269 | if (quiet_flag == FALSE) { |
| 270 | printf("Connecting to %s[%s]:%d\n", |
Glenn L McGrath | ffccf6e | 2003-12-20 01:47:18 +0000 | [diff] [blame] | 271 | server.host, inet_ntoa(s_in.sin_addr), ntohs(server.port)); |
Eric Andersen | e6dc439 | 2003-10-31 09:31:46 +0000 | [diff] [blame] | 272 | } |
| 273 | |
Glenn L McGrath | f1c4b11 | 2004-02-22 00:27:34 +0000 | [diff] [blame] | 274 | if (use_proxy || !target.is_ftp) { |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 275 | /* |
| 276 | * HTTP session |
| 277 | */ |
| 278 | do { |
Glenn L McGrath | e7bdfcc | 2003-08-28 22:03:19 +0000 | [diff] [blame] | 279 | got_clen = chunked = 0; |
| 280 | |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 281 | if (!--try) |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 282 | close_delete_and_die("too many redirections"); |
Eric Andersen | 7d69701 | 2001-01-24 20:28:35 +0000 | [diff] [blame] | 283 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 284 | /* |
| 285 | * Open socket to http server |
| 286 | */ |
| 287 | if (sfp) fclose(sfp); |
Glenn L McGrath | ffccf6e | 2003-12-20 01:47:18 +0000 | [diff] [blame] | 288 | sfp = open_socket(&s_in); |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 289 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 290 | /* |
| 291 | * Send HTTP request. |
| 292 | */ |
Glenn L McGrath | f1c4b11 | 2004-02-22 00:27:34 +0000 | [diff] [blame] | 293 | if (use_proxy) { |
Glenn L McGrath | cc20ebc | 2003-09-10 23:52:15 +0000 | [diff] [blame] | 294 | const char *format = "GET %stp://%s:%d/%s HTTP/1.1\r\n"; |
| 295 | #ifdef CONFIG_FEATURE_WGET_IP6_LITERAL |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 296 | if (strchr(target.host, ':')) |
Glenn L McGrath | cc20ebc | 2003-09-10 23:52:15 +0000 | [diff] [blame] | 297 | format = "GET %stp://[%s]:%d/%s HTTP/1.1\r\n"; |
| 298 | #endif |
| 299 | fprintf(sfp, format, |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 300 | target.is_ftp ? "f" : "ht", target.host, |
Glenn L McGrath | 24cb17f | 2004-01-31 08:08:57 +0000 | [diff] [blame] | 301 | ntohs(target.port), target.path); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 302 | } else { |
Eric Andersen | 6d7fa43 | 2001-04-10 18:17:05 +0000 | [diff] [blame] | 303 | fprintf(sfp, "GET /%s HTTP/1.1\r\n", target.path); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 304 | } |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 305 | |
Bernhard Reutner-Fischer | bfbc4eb | 2006-09-02 15:30:26 +0000 | [diff] [blame] | 306 | fprintf(sfp, "Host: %s\r\nUser-Agent: %s\r\n", target.host, |
| 307 | user_agent); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 308 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 309 | #ifdef CONFIG_FEATURE_WGET_AUTHENTICATION |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 310 | if (target.user) { |
| 311 | fprintf(sfp, "Authorization: Basic %s\r\n", |
Eric Andersen | 0cb6f35 | 2006-01-30 22:30:41 +0000 | [diff] [blame] | 312 | base64enc((unsigned char*)target.user, buf, sizeof(buf))); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 313 | } |
Glenn L McGrath | f1c4b11 | 2004-02-22 00:27:34 +0000 | [diff] [blame] | 314 | if (use_proxy && server.user) { |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 315 | fprintf(sfp, "Proxy-Authorization: Basic %s\r\n", |
Eric Andersen | 0cb6f35 | 2006-01-30 22:30:41 +0000 | [diff] [blame] | 316 | base64enc((unsigned char*)server.user, buf, sizeof(buf))); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 317 | } |
| 318 | #endif |
| 319 | |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 320 | if (do_continue) |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 321 | fprintf(sfp, "Range: bytes=%ld-\r\n", beg_range); |
Eric Andersen | 50ae310 | 2001-05-15 17:51:37 +0000 | [diff] [blame] | 322 | if(extra_headers_left < sizeof(extra_headers)) |
Eric Andersen | 9abfe85 | 2001-05-15 20:11:49 +0000 | [diff] [blame] | 323 | fputs(extra_headers,sfp); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 324 | fprintf(sfp,"Connection: close\r\n\r\n"); |
| 325 | |
| 326 | /* |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 327 | * Retrieve HTTP response line and check for "200" status code. |
| 328 | */ |
Glenn L McGrath | e7bdfcc | 2003-08-28 22:03:19 +0000 | [diff] [blame] | 329 | read_response: |
| 330 | if (fgets(buf, sizeof(buf), sfp) == NULL) |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 331 | close_delete_and_die("no response from server"); |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 332 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 333 | for (s = buf ; *s != '\0' && !isspace(*s) ; ++s) |
Rob Landley | 76ef08c | 2006-06-13 16:44:26 +0000 | [diff] [blame] | 334 | ; |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 335 | for ( ; isspace(*s) ; ++s) |
Rob Landley | 76ef08c | 2006-06-13 16:44:26 +0000 | [diff] [blame] | 336 | ; |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 337 | switch (status = atoi(s)) { |
| 338 | case 0: |
Eric Andersen | 6d7fa43 | 2001-04-10 18:17:05 +0000 | [diff] [blame] | 339 | case 100: |
| 340 | while (gethdr(buf, sizeof(buf), sfp, &n) != NULL); |
| 341 | goto read_response; |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 342 | case 200: |
| 343 | if (do_continue && output != stdout) |
| 344 | output = freopen(fname_out, "w", output); |
| 345 | do_continue = 0; |
| 346 | break; |
| 347 | case 300: /* redirection */ |
| 348 | case 301: |
| 349 | case 302: |
| 350 | case 303: |
| 351 | break; |
| 352 | case 206: |
| 353 | if (do_continue) |
| 354 | break; |
| 355 | /*FALLTHRU*/ |
| 356 | default: |
| 357 | chomp(buf); |
| 358 | close_delete_and_die("server returned error %d: %s", atoi(s), buf); |
| 359 | } |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 360 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 361 | /* |
| 362 | * Retrieve HTTP headers. |
| 363 | */ |
| 364 | while ((s = gethdr(buf, sizeof(buf), sfp, &n)) != NULL) { |
| 365 | if (strcasecmp(buf, "content-length") == 0) { |
Eric Andersen | 2479445 | 2004-03-06 22:11:45 +0000 | [diff] [blame] | 366 | unsigned long value; |
| 367 | if (safe_strtoul(s, &value)) { |
| 368 | close_delete_and_die("content-length %s is garbage", s); |
| 369 | } |
| 370 | filesize = value; |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 371 | got_clen = 1; |
| 372 | continue; |
| 373 | } |
Eric Andersen | 6d7fa43 | 2001-04-10 18:17:05 +0000 | [diff] [blame] | 374 | if (strcasecmp(buf, "transfer-encoding") == 0) { |
| 375 | if (strcasecmp(s, "chunked") == 0) { |
| 376 | chunked = got_clen = 1; |
| 377 | } else { |
Rob Landley | 76ef08c | 2006-06-13 16:44:26 +0000 | [diff] [blame] | 378 | close_delete_and_die("server wants to do %s transfer encoding", s); |
Eric Andersen | 6d7fa43 | 2001-04-10 18:17:05 +0000 | [diff] [blame] | 379 | } |
| 380 | } |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 381 | if (strcasecmp(buf, "location") == 0) { |
| 382 | if (s[0] == '/') |
Rob Landley | d921b2e | 2006-08-03 15:41:12 +0000 | [diff] [blame] | 383 | target.path = xstrdup(s+1); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 384 | else { |
Rob Landley | d921b2e | 2006-08-03 15:41:12 +0000 | [diff] [blame] | 385 | parse_url(xstrdup(s), &target); |
Glenn L McGrath | f1c4b11 | 2004-02-22 00:27:34 +0000 | [diff] [blame] | 386 | if (use_proxy == 0) { |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 387 | server.host = target.host; |
| 388 | server.port = target.port; |
| 389 | } |
Glenn L McGrath | 58a2e0e | 2004-01-17 23:07:14 +0000 | [diff] [blame] | 390 | bb_lookup_host(&s_in, server.host); |
| 391 | s_in.sin_port = server.port; |
| 392 | break; |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 393 | } |
| 394 | } |
| 395 | } |
| 396 | } while(status >= 300); |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 397 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 398 | dfp = sfp; |
| 399 | } |
| 400 | else |
| 401 | { |
| 402 | /* |
| 403 | * FTP session |
| 404 | */ |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 405 | if (!target.user) |
Rob Landley | d921b2e | 2006-08-03 15:41:12 +0000 | [diff] [blame] | 406 | target.user = xstrdup("anonymous:busybox@"); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 407 | |
Glenn L McGrath | ffccf6e | 2003-12-20 01:47:18 +0000 | [diff] [blame] | 408 | sfp = open_socket(&s_in); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 409 | if (ftpcmd(NULL, NULL, sfp, buf) != 220) |
| 410 | close_delete_and_die("%s", buf+4); |
| 411 | |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 412 | /* |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 413 | * Splitting username:password pair, |
| 414 | * trying to log in |
| 415 | */ |
| 416 | s = strchr(target.user, ':'); |
| 417 | if (s) |
| 418 | *(s++) = '\0'; |
| 419 | switch(ftpcmd("USER ", target.user, sfp, buf)) { |
| 420 | case 230: |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 421 | break; |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 422 | case 331: |
| 423 | if (ftpcmd("PASS ", s, sfp, buf) == 230) |
| 424 | break; |
| 425 | /* FALLTHRU (failed login) */ |
| 426 | default: |
| 427 | close_delete_and_die("ftp login: %s", buf+4); |
| 428 | } |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 429 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 430 | ftpcmd("TYPE I", NULL, sfp, buf); |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 431 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 432 | /* |
| 433 | * Querying file size |
| 434 | */ |
Rob Landley | af12cb3 | 2006-06-27 18:41:03 +0000 | [diff] [blame] | 435 | if (ftpcmd("SIZE ", target.path, sfp, buf) == 213) { |
Eric Andersen | 2479445 | 2004-03-06 22:11:45 +0000 | [diff] [blame] | 436 | unsigned long value; |
| 437 | if (safe_strtoul(buf+4, &value)) { |
| 438 | close_delete_and_die("SIZE value is garbage"); |
| 439 | } |
| 440 | filesize = value; |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 441 | got_clen = 1; |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 442 | } |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 443 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 444 | /* |
| 445 | * Entering passive mode |
| 446 | */ |
| 447 | if (ftpcmd("PASV", NULL, sfp, buf) != 227) |
| 448 | close_delete_and_die("PASV: %s", buf+4); |
| 449 | s = strrchr(buf, ','); |
| 450 | *s = 0; |
| 451 | port = atoi(s+1); |
| 452 | s = strrchr(buf, ','); |
| 453 | port += atoi(s+1) * 256; |
Glenn L McGrath | ffccf6e | 2003-12-20 01:47:18 +0000 | [diff] [blame] | 454 | s_in.sin_port = htons(port); |
| 455 | dfp = open_socket(&s_in); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 456 | |
| 457 | if (do_continue) { |
| 458 | sprintf(buf, "REST %ld", beg_range); |
| 459 | if (ftpcmd(buf, NULL, sfp, buf) != 350) { |
| 460 | if (output != stdout) |
| 461 | output = freopen(fname_out, "w", output); |
| 462 | do_continue = 0; |
| 463 | } else |
| 464 | filesize -= beg_range; |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 465 | } |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 466 | |
Rob Landley | af12cb3 | 2006-06-27 18:41:03 +0000 | [diff] [blame] | 467 | if (ftpcmd("RETR ", target.path, sfp, buf) > 150) |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 468 | close_delete_and_die("RETR: %s", buf+4); |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 469 | } |
| 470 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 471 | |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 472 | /* |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 473 | * Retrieve file |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 474 | */ |
Eric Andersen | 6d7fa43 | 2001-04-10 18:17:05 +0000 | [diff] [blame] | 475 | if (chunked) { |
| 476 | fgets(buf, sizeof(buf), dfp); |
| 477 | filesize = strtol(buf, (char **) NULL, 16); |
| 478 | } |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 479 | |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 480 | if (quiet_flag == FALSE) |
Glenn L McGrath | 1bca5ed | 2000-12-09 08:12:06 +0000 | [diff] [blame] | 481 | progressmeter(-1); |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 482 | |
Mark Whitley | 30ac01c | 2001-04-17 18:13:16 +0000 | [diff] [blame] | 483 | do { |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 484 | while (filesize > 0 || !got_clen) { |
| 485 | unsigned rdsz = sizeof(buf); |
| 486 | if (filesize < sizeof(buf) && (chunked || got_clen)) |
| 487 | rdsz = filesize; |
| 488 | n = safe_fread(buf, 1, rdsz, dfp); |
| 489 | if (n <= 0) |
| 490 | break; |
Glenn L McGrath | 83e4a5b | 2003-08-28 21:55:22 +0000 | [diff] [blame] | 491 | if (safe_fwrite(buf, 1, n, output) != n) { |
Bernhard Reutner-Fischer | 1b9d7c9 | 2006-06-03 22:45:37 +0000 | [diff] [blame] | 492 | bb_perror_msg_and_die(bb_msg_write_error); |
Glenn L McGrath | 83e4a5b | 2003-08-28 21:55:22 +0000 | [diff] [blame] | 493 | } |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 494 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 495 | transferred += n; |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 496 | #endif |
Glenn L McGrath | 83e4a5b | 2003-08-28 21:55:22 +0000 | [diff] [blame] | 497 | if (got_clen) { |
| 498 | filesize -= n; |
| 499 | } |
| 500 | } |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 501 | |
Eric Andersen | 6d7fa43 | 2001-04-10 18:17:05 +0000 | [diff] [blame] | 502 | if (chunked) { |
Matt Kraai | 854125f | 2001-05-09 19:15:46 +0000 | [diff] [blame] | 503 | safe_fgets(buf, sizeof(buf), dfp); /* This is a newline */ |
| 504 | safe_fgets(buf, sizeof(buf), dfp); |
Eric Andersen | 6d7fa43 | 2001-04-10 18:17:05 +0000 | [diff] [blame] | 505 | filesize = strtol(buf, (char **) NULL, 16); |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 506 | if (filesize == 0) { |
Glenn L McGrath | 83e4a5b | 2003-08-28 21:55:22 +0000 | [diff] [blame] | 507 | chunked = 0; /* all done! */ |
| 508 | } |
Eric Andersen | 6d7fa43 | 2001-04-10 18:17:05 +0000 | [diff] [blame] | 509 | } |
| 510 | |
Glenn L McGrath | 83e4a5b | 2003-08-28 21:55:22 +0000 | [diff] [blame] | 511 | if (n == 0 && ferror(dfp)) { |
Bernhard Reutner-Fischer | 1b9d7c9 | 2006-06-03 22:45:37 +0000 | [diff] [blame] | 512 | bb_perror_msg_and_die(bb_msg_read_error); |
Glenn L McGrath | 83e4a5b | 2003-08-28 21:55:22 +0000 | [diff] [blame] | 513 | } |
Eric Andersen | 6d7fa43 | 2001-04-10 18:17:05 +0000 | [diff] [blame] | 514 | } while (chunked); |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 515 | |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 516 | if (quiet_flag == FALSE) |
Mark Whitley | 30ac01c | 2001-04-17 18:13:16 +0000 | [diff] [blame] | 517 | progressmeter(1); |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 518 | |
Glenn L McGrath | f1c4b11 | 2004-02-22 00:27:34 +0000 | [diff] [blame] | 519 | if ((use_proxy == 0) && target.is_ftp) { |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 520 | fclose(dfp); |
| 521 | if (ftpcmd(NULL, NULL, sfp, buf) != 226) |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 522 | bb_error_msg_and_die("ftp error: %s", buf+4); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 523 | ftpcmd("QUIT", NULL, sfp, buf); |
| 524 | } |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 525 | exit(EXIT_SUCCESS); |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 529 | void parse_url(char *url, struct host_info *h) |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 530 | { |
Glenn L McGrath | cc20ebc | 2003-09-10 23:52:15 +0000 | [diff] [blame] | 531 | char *cp, *sp, *up, *pp; |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 532 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 533 | if (strncmp(url, "http://", 7) == 0) { |
Glenn L McGrath | 036dbaa | 2004-01-17 05:03:31 +0000 | [diff] [blame] | 534 | h->port = bb_lookup_port("http", "tcp", 80); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 535 | h->host = url + 7; |
| 536 | h->is_ftp = 0; |
| 537 | } else if (strncmp(url, "ftp://", 6) == 0) { |
Glenn L McGrath | 036dbaa | 2004-01-17 05:03:31 +0000 | [diff] [blame] | 538 | h->port = bb_lookup_port("ftp", "tfp", 21); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 539 | h->host = url + 6; |
| 540 | h->is_ftp = 1; |
| 541 | } else |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 542 | bb_error_msg_and_die("not an http or ftp url: %s", url); |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 543 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 544 | sp = strchr(h->host, '/'); |
Glenn L McGrath | f1c4b11 | 2004-02-22 00:27:34 +0000 | [diff] [blame] | 545 | if (sp) { |
Matt Kraai | a9711a5 | 2001-01-03 16:15:15 +0000 | [diff] [blame] | 546 | *sp++ = '\0'; |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 547 | h->path = sp; |
Matt Kraai | a9711a5 | 2001-01-03 16:15:15 +0000 | [diff] [blame] | 548 | } else |
Rob Landley | d921b2e | 2006-08-03 15:41:12 +0000 | [diff] [blame] | 549 | h->path = xstrdup(""); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 550 | |
| 551 | up = strrchr(h->host, '@'); |
| 552 | if (up != NULL) { |
| 553 | h->user = h->host; |
| 554 | *up++ = '\0'; |
| 555 | h->host = up; |
| 556 | } else |
| 557 | h->user = NULL; |
| 558 | |
Glenn L McGrath | cc20ebc | 2003-09-10 23:52:15 +0000 | [diff] [blame] | 559 | pp = h->host; |
| 560 | |
| 561 | #ifdef CONFIG_FEATURE_WGET_IP6_LITERAL |
| 562 | if (h->host[0] == '[') { |
| 563 | char *ep; |
| 564 | |
| 565 | ep = h->host + 1; |
Eric Andersen | 6231f09 | 2003-09-11 08:25:11 +0000 | [diff] [blame] | 566 | while (*ep == ':' || isxdigit (*ep)) |
Glenn L McGrath | cc20ebc | 2003-09-10 23:52:15 +0000 | [diff] [blame] | 567 | ep++; |
| 568 | if (*ep == ']') { |
| 569 | h->host++; |
| 570 | *ep = '\0'; |
| 571 | pp = ep + 1; |
| 572 | } |
| 573 | } |
| 574 | #endif |
| 575 | |
| 576 | cp = strchr(pp, ':'); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 577 | if (cp != NULL) { |
| 578 | *cp++ = '\0'; |
Glenn L McGrath | f980bd5 | 2003-12-27 00:21:47 +0000 | [diff] [blame] | 579 | h->port = htons(atoi(cp)); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 580 | } |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | |
Glenn L McGrath | ffccf6e | 2003-12-20 01:47:18 +0000 | [diff] [blame] | 584 | FILE *open_socket(struct sockaddr_in *s_in) |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 585 | { |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 586 | FILE *fp; |
| 587 | |
Glenn L McGrath | ffccf6e | 2003-12-20 01:47:18 +0000 | [diff] [blame] | 588 | fp = fdopen(xconnect(s_in), "r+"); |
| 589 | if (fp == NULL) |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 590 | bb_perror_msg_and_die("fdopen"); |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 591 | |
| 592 | return fp; |
| 593 | } |
| 594 | |
| 595 | |
| 596 | char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc) |
| 597 | { |
| 598 | char *s, *hdrval; |
| 599 | int c; |
| 600 | |
| 601 | *istrunc = 0; |
| 602 | |
| 603 | /* retrieve header line */ |
| 604 | if (fgets(buf, bufsiz, fp) == NULL) |
| 605 | return NULL; |
| 606 | |
| 607 | /* see if we are at the end of the headers */ |
| 608 | for (s = buf ; *s == '\r' ; ++s) |
| 609 | ; |
| 610 | if (s[0] == '\n') |
| 611 | return NULL; |
| 612 | |
| 613 | /* convert the header name to lower case */ |
| 614 | for (s = buf ; isalnum(*s) || *s == '-' ; ++s) |
| 615 | *s = tolower(*s); |
| 616 | |
| 617 | /* verify we are at the end of the header name */ |
| 618 | if (*s != ':') |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 619 | bb_error_msg_and_die("bad header line: %s", buf); |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 620 | |
| 621 | /* locate the start of the header value */ |
| 622 | for (*s++ = '\0' ; *s == ' ' || *s == '\t' ; ++s) |
| 623 | ; |
| 624 | hdrval = s; |
| 625 | |
| 626 | /* locate the end of header */ |
| 627 | while (*s != '\0' && *s != '\r' && *s != '\n') |
| 628 | ++s; |
| 629 | |
| 630 | /* end of header found */ |
| 631 | if (*s != '\0') { |
| 632 | *s = '\0'; |
| 633 | return hdrval; |
| 634 | } |
| 635 | |
Eric Andersen | 5d63884 | 2000-09-14 21:46:30 +0000 | [diff] [blame] | 636 | /* Rats! The buffer isn't big enough to hold the entire header value. */ |
Eric Andersen | 9670083 | 2000-09-04 15:15:55 +0000 | [diff] [blame] | 637 | while (c = getc(fp), c != EOF && c != '\n') |
| 638 | ; |
| 639 | *istrunc = 1; |
| 640 | return hdrval; |
| 641 | } |
| 642 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 643 | static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf) |
| 644 | { |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 645 | if (s1) { |
| 646 | if (!s2) s2=""; |
Eric Andersen | 3f1cf45 | 2003-03-11 18:03:39 +0000 | [diff] [blame] | 647 | fprintf(fp, "%s%s\r\n", s1, s2); |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 648 | fflush(fp); |
| 649 | } |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 650 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 651 | do { |
Glenn L McGrath | 32da885 | 2004-04-08 10:27:11 +0000 | [diff] [blame] | 652 | char *buf_ptr; |
| 653 | |
| 654 | if (fgets(buf, 510, fp) == NULL) { |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 655 | bb_perror_msg_and_die("fgets"); |
Glenn L McGrath | 32da885 | 2004-04-08 10:27:11 +0000 | [diff] [blame] | 656 | } |
| 657 | buf_ptr = strstr(buf, "\r\n"); |
| 658 | if (buf_ptr) { |
| 659 | *buf_ptr = '\0'; |
| 660 | } |
Denis Vlasenko | 3526a13 | 2006-09-09 12:20:57 +0000 | [diff] [blame] | 661 | } while (!isdigit(buf[0]) || buf[3] != ' '); |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 662 | |
Eric Andersen | 79757c9 | 2001-04-05 21:45:54 +0000 | [diff] [blame] | 663 | return atoi(buf); |
| 664 | } |
| 665 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 666 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 667 | /* Stuff below is from BSD rcp util.c, as added to openshh. |
Eric Andersen | 4e573f4 | 2000-11-14 23:29:24 +0000 | [diff] [blame] | 668 | * Original copyright notice is retained at the end of this file. |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 669 | * |
| 670 | */ |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 671 | |
| 672 | |
Eric Andersen | 3e6ff90 | 2001-03-09 21:24:12 +0000 | [diff] [blame] | 673 | static int |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 674 | getttywidth(void) |
| 675 | { |
Eric Andersen | 8efe967 | 2003-09-15 08:33:45 +0000 | [diff] [blame] | 676 | int width=0; |
| 677 | get_terminal_width_height(0, &width, NULL); |
| 678 | return (width); |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 679 | } |
| 680 | |
Eric Andersen | 3e6ff90 | 2001-03-09 21:24:12 +0000 | [diff] [blame] | 681 | static void |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 682 | updateprogressmeter(int ignore) |
| 683 | { |
| 684 | int save_errno = errno; |
| 685 | |
| 686 | progressmeter(0); |
| 687 | errno = save_errno; |
| 688 | } |
| 689 | |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 690 | static void alarmtimer(int iwait) |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 691 | { |
| 692 | struct itimerval itv; |
| 693 | |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 694 | itv.it_value.tv_sec = iwait; |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 695 | itv.it_value.tv_usec = 0; |
| 696 | itv.it_interval = itv.it_value; |
| 697 | setitimer(ITIMER_REAL, &itv, NULL); |
| 698 | } |
| 699 | |
| 700 | |
Eric Andersen | 3e6ff90 | 2001-03-09 21:24:12 +0000 | [diff] [blame] | 701 | static void |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 702 | progressmeter(int flag) |
| 703 | { |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 704 | static struct timeval lastupdate; |
Mark Whitley | 30ac01c | 2001-04-17 18:13:16 +0000 | [diff] [blame] | 705 | static off_t lastsize, totalsize; |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 706 | |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 707 | struct timeval now, td, tvwait; |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 708 | off_t abbrevsize; |
| 709 | int elapsed, ratio, barlength, i; |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 710 | char buf[256]; |
| 711 | |
| 712 | if (flag == -1) { |
| 713 | (void) gettimeofday(&start, (struct timezone *) 0); |
| 714 | lastupdate = start; |
| 715 | lastsize = 0; |
Mark Whitley | 30ac01c | 2001-04-17 18:13:16 +0000 | [diff] [blame] | 716 | totalsize = filesize; /* as filesize changes.. */ |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | (void) gettimeofday(&now, (struct timezone *) 0); |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 720 | ratio = 100; |
Mark Whitley | 30ac01c | 2001-04-17 18:13:16 +0000 | [diff] [blame] | 721 | if (totalsize != 0 && !chunked) { |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 722 | ratio = (int) (100 * transferred / totalsize); |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 723 | ratio = MIN(ratio, 100); |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 724 | } |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 725 | |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 726 | fprintf(stderr, "\r%-20.20s%4d%% ", curfile, ratio); |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 727 | |
| 728 | barlength = getttywidth() - 51; |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 729 | if (barlength > 0 && barlength < sizeof(buf)) { |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 730 | i = barlength * ratio / 100; |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 731 | memset(buf, '*', i); |
| 732 | memset(buf + i, ' ', barlength - i); |
| 733 | buf[barlength] = '\0'; |
| 734 | fprintf(stderr, "|%s|", buf); |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 735 | } |
| 736 | i = 0; |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 737 | abbrevsize = transferred; |
| 738 | while (abbrevsize >= 100000) { |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 739 | i++; |
| 740 | abbrevsize >>= 10; |
| 741 | } |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 742 | /* See http://en.wikipedia.org/wiki/Tera */ |
| 743 | fprintf(stderr, "%6d %c%c ", (int)abbrevsize, " KMGTPEZY"[i], i?'B':' '); |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 744 | |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 745 | timersub(&now, &lastupdate, &tvwait); |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 746 | if (transferred > lastsize) { |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 747 | lastupdate = now; |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 748 | lastsize = transferred; |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 749 | if (tvwait.tv_sec >= STALLTIME) |
| 750 | timeradd(&start, &tvwait, &start); |
| 751 | tvwait.tv_sec = 0; |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 752 | } |
| 753 | timersub(&now, &start, &td); |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 754 | elapsed = td.tv_sec; |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 755 | |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 756 | if (tvwait.tv_sec >= STALLTIME) { |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 757 | fprintf(stderr, " - stalled -"); |
| 758 | } else if (transferred <= 0 || elapsed <= 0 || transferred > totalsize || chunked) { |
| 759 | fprintf(stderr, "--:--:-- ETA"); |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 760 | } else { |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 761 | /* totalsize / (transferred/elapsed) - elapsed: */ |
| 762 | int eta = (int) (totalsize*elapsed/transferred - elapsed); |
| 763 | i = eta % 3600; |
| 764 | fprintf(stderr, "%02d:%02d:%02d ETA", eta / 3600, i / 60, i % 60); |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 765 | } |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 766 | |
| 767 | if (flag == -1) { |
| 768 | struct sigaction sa; |
| 769 | sa.sa_handler = updateprogressmeter; |
| 770 | sigemptyset(&sa.sa_mask); |
| 771 | sa.sa_flags = SA_RESTART; |
| 772 | sigaction(SIGALRM, &sa, NULL); |
| 773 | alarmtimer(1); |
| 774 | } else if (flag == 1) { |
| 775 | alarmtimer(0); |
Rob Landley | 19a3940 | 2006-06-13 17:10:26 +0000 | [diff] [blame] | 776 | transferred = 0; |
Mark Whitley | 30ac01c | 2001-04-17 18:13:16 +0000 | [diff] [blame] | 777 | putc('\n', stderr); |
Eric Andersen | b520e08 | 2000-10-03 00:21:45 +0000 | [diff] [blame] | 778 | } |
| 779 | } |
| 780 | #endif |
Eric Andersen | 4e573f4 | 2000-11-14 23:29:24 +0000 | [diff] [blame] | 781 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 782 | /* Original copyright notice which applies to the CONFIG_FEATURE_WGET_STATUSBAR stuff, |
Eric Andersen | aff114c | 2004-04-14 17:51:38 +0000 | [diff] [blame] | 783 | * much of which was blatantly stolen from openssh. */ |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 784 | |
Eric Andersen | 4e573f4 | 2000-11-14 23:29:24 +0000 | [diff] [blame] | 785 | /*- |
| 786 | * Copyright (c) 1992, 1993 |
| 787 | * The Regents of the University of California. All rights reserved. |
| 788 | * |
| 789 | * Redistribution and use in source and binary forms, with or without |
| 790 | * modification, are permitted provided that the following conditions |
| 791 | * are met: |
| 792 | * 1. Redistributions of source code must retain the above copyright |
| 793 | * notice, this list of conditions and the following disclaimer. |
| 794 | * 2. Redistributions in binary form must reproduce the above copyright |
| 795 | * notice, this list of conditions and the following disclaimer in the |
| 796 | * documentation and/or other materials provided with the distribution. |
| 797 | * |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 798 | * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change |
| 799 | * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change> |
Eric Andersen | 4e573f4 | 2000-11-14 23:29:24 +0000 | [diff] [blame] | 800 | * |
| 801 | * 4. Neither the name of the University nor the names of its contributors |
| 802 | * may be used to endorse or promote products derived from this software |
| 803 | * without specific prior written permission. |
| 804 | * |
| 805 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 806 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 807 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 808 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 809 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 810 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 811 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 812 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 813 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 814 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 815 | * SUCH DAMAGE. |
| 816 | * |
Eric Andersen | 751750e | 2004-10-08 08:27:40 +0000 | [diff] [blame] | 817 | * $Id: wget.c,v 1.75 2004/10/08 08:27:40 andersen Exp $ |
Eric Andersen | 4e573f4 | 2000-11-14 23:29:24 +0000 | [diff] [blame] | 818 | */ |