summaryrefslogtreecommitdiff
path: root/networking/wget.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-01-14 13:28:49 +0000
committerRon Yorston <rmy@pobox.com>2021-01-14 13:28:49 +0000
commit89963b524d211e1aec12b72b3725be05ee95c8cf (patch)
tree48590aef62b7ee7686b7898256f29def8d9c50b9 /networking/wget.c
parent9aa5a829070392c2ac6494d0c4e674c0c2bc7dab (diff)
parent2b7c1aa92c68524559a2067609d09309d5c09adc (diff)
downloadbusybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.tar.gz
busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.tar.bz2
busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'networking/wget.c')
-rw-r--r--networking/wget.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/networking/wget.c b/networking/wget.c
index 8a967fe20..270eab141 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -128,19 +128,14 @@
128 128
129//usage:#define wget_trivial_usage 129//usage:#define wget_trivial_usage
130//usage: IF_FEATURE_WGET_LONG_OPTIONS( 130//usage: IF_FEATURE_WGET_LONG_OPTIONS(
131//usage: "[-c|--continue] [--spider] [-q|--quiet] [-O|--output-document FILE]\n" 131//usage: "[-cqS] [--spider] [-O FILE] [-o LOGFILE] [--header 'HEADER: VALUE'] [-Y on/off]\n"
132//usage: " [-o|--output-file FILE] [--header 'header: value'] [-Y|--proxy on/off]\n"
133//usage: IF_FEATURE_WGET_OPENSSL(
134//usage: " [--no-check-certificate]\n"
135//usage: )
136/* Since we ignore these opts, we don't show them in --help */ 132/* Since we ignore these opts, we don't show them in --help */
137/* //usage: " [--no-cache] [--passive-ftp] [-t TRIES]" */ 133/* //usage: " [--no-cache] [--passive-ftp] [-t TRIES]" */
138/* //usage: " [-nv] [-nc] [-nH] [-np]" */ 134/* //usage: " [-nv] [-nc] [-nH] [-np]" */
139//usage: " [-P DIR] [-S|--server-response] [-U|--user-agent AGENT]" IF_FEATURE_WGET_TIMEOUT(" [-T SEC]") " URL..." 135//usage: " "IF_FEATURE_WGET_OPENSSL("[--no-check-certificate] ")"[-P DIR] [-U AGENT]"IF_FEATURE_WGET_TIMEOUT(" [-T SEC]")" URL..."
140//usage: ) 136//usage: )
141//usage: IF_NOT_FEATURE_WGET_LONG_OPTIONS( 137//usage: IF_NOT_FEATURE_WGET_LONG_OPTIONS(
142//usage: "[-cq] [-O FILE] [-o FILE] [-Y on/off] [-P DIR] [-S] [-U AGENT]" 138//usage: "[-cqS] [-O FILE] [-o LOGFILE] [-Y on/off] [-P DIR] [-U AGENT]"IF_FEATURE_WGET_TIMEOUT(" [-T SEC]")" URL..."
143//usage: IF_FEATURE_WGET_TIMEOUT(" [-T SEC]") " URL..."
144//usage: ) 139//usage: )
145//usage:#define wget_full_usage "\n\n" 140//usage:#define wget_full_usage "\n\n"
146//usage: "Retrieve files via HTTP or FTP\n" 141//usage: "Retrieve files via HTTP or FTP\n"
@@ -158,7 +153,7 @@
158//usage: "\n -T SEC Network read timeout is SEC seconds" 153//usage: "\n -T SEC Network read timeout is SEC seconds"
159//usage: ) 154//usage: )
160//usage: "\n -O FILE Save to FILE ('-' for stdout)" 155//usage: "\n -O FILE Save to FILE ('-' for stdout)"
161//usage: "\n -o FILE Log messages to FILE" 156//usage: "\n -o LOGFILE Log messages to FILE"
162//usage: "\n -U STR Use STR for User-Agent header" 157//usage: "\n -U STR Use STR for User-Agent header"
163//usage: "\n -Y on/off Use proxy" 158//usage: "\n -Y on/off Use proxy"
164 159
@@ -287,6 +282,8 @@ enum {
287 WGET_OPT_POST_DATA = (1 << 12) * ENABLE_FEATURE_WGET_LONG_OPTIONS, 282 WGET_OPT_POST_DATA = (1 << 12) * ENABLE_FEATURE_WGET_LONG_OPTIONS,
288 WGET_OPT_SPIDER = (1 << 13) * ENABLE_FEATURE_WGET_LONG_OPTIONS, 283 WGET_OPT_SPIDER = (1 << 13) * ENABLE_FEATURE_WGET_LONG_OPTIONS,
289 WGET_OPT_NO_CHECK_CERT = (1 << 14) * ENABLE_FEATURE_WGET_LONG_OPTIONS, 284 WGET_OPT_NO_CHECK_CERT = (1 << 14) * ENABLE_FEATURE_WGET_LONG_OPTIONS,
285 /* hijack this bit for other than opts purposes: */
286 WGET_NO_FTRUNCATE = (1 << 31)
290}; 287};
291 288
292enum { 289enum {
@@ -1085,8 +1082,13 @@ static void NOINLINE retrieve_file_data(FILE *dfp)
1085 */ 1082 */
1086 { 1083 {
1087 off_t pos = lseek(G.output_fd, 0, SEEK_CUR); 1084 off_t pos = lseek(G.output_fd, 0, SEEK_CUR);
1088 if (pos != (off_t)-1) 1085 if (pos != (off_t)-1) {
1089 ftruncate(G.output_fd, pos); 1086 /* do not truncate if -O- is in use, a user complained about
1087 * "wget -qO- 'http://example.com/empty' >>FILE" truncating FILE.
1088 */
1089 if (!(option_mask32 & WGET_NO_FTRUNCATE))
1090 ftruncate(G.output_fd, pos);
1091 }
1090 } 1092 }
1091 1093
1092 if (!(option_mask32 & WGET_OPT_QUIET)) { 1094 if (!(option_mask32 & WGET_OPT_QUIET)) {
@@ -1599,7 +1601,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0")
1599 if (G.fname_out) { /* -O FILE ? */ 1601 if (G.fname_out) { /* -O FILE ? */
1600 if (LONE_DASH(G.fname_out)) { /* -O - ? */ 1602 if (LONE_DASH(G.fname_out)) { /* -O - ? */
1601 G.output_fd = 1; 1603 G.output_fd = 1;
1602 option_mask32 &= ~WGET_OPT_CONTINUE; 1604 option_mask32 = (option_mask32 & (~WGET_OPT_CONTINUE)) | WGET_NO_FTRUNCATE;
1603 } 1605 }
1604 /* compat with wget: -O FILE can overwrite */ 1606 /* compat with wget: -O FILE can overwrite */
1605 G.o_flags = O_WRONLY | O_CREAT | O_TRUNC; 1607 G.o_flags = O_WRONLY | O_CREAT | O_TRUNC;