diff options
| author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-06-21 19:45:06 +0000 |
|---|---|---|
| committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-06-21 19:45:06 +0000 |
| commit | c3f76c9711dc97ecd481c10794b595fe0fef368e (patch) | |
| tree | 8c4977f9b0a6a58e97813de86bcaf2196eb833f2 | |
| parent | 5f0f7d3428d4c8cc51fef8fcb4e7bf0ac616dab2 (diff) | |
| download | busybox-w32-c3f76c9711dc97ecd481c10794b595fe0fef368e.tar.gz busybox-w32-c3f76c9711dc97ecd481c10794b595fe0fef368e.tar.bz2 busybox-w32-c3f76c9711dc97ecd481c10794b595fe0fef368e.zip | |
Add wget -P support, finishing off bug #1176
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@2874 69ca8d6d-28ef-0310-b511-8ec308f3f277
| -rw-r--r-- | applets/usage.h | 3 | ||||
| -rw-r--r-- | include/usage.h | 3 | ||||
| -rw-r--r-- | networking/wget.c | 10 | ||||
| -rw-r--r-- | usage.h | 3 | ||||
| -rw-r--r-- | wget.c | 10 |
5 files changed, 20 insertions, 9 deletions
diff --git a/applets/usage.h b/applets/usage.h index acba3677c..9fd3a2e1c 100644 --- a/applets/usage.h +++ b/applets/usage.h | |||
| @@ -1729,12 +1729,13 @@ | |||
| 1729 | " 31 46 1365 /etc/passwd\n" | 1729 | " 31 46 1365 /etc/passwd\n" |
| 1730 | 1730 | ||
| 1731 | #define wget_trivial_usage \ | 1731 | #define wget_trivial_usage \ |
| 1732 | "[-c|--continue] [-q|--quiet] [-O|--output-document file] [--header 'header: value'] url" | 1732 | "[-c|--continue] [-q|--quiet] [-O|--output-document file]\n\t[--header 'header: value'] [-P DIR] url" |
| 1733 | #define wget_full_usage \ | 1733 | #define wget_full_usage \ |
| 1734 | "wget retrieves files via HTTP or FTP\n\n" \ | 1734 | "wget retrieves files via HTTP or FTP\n\n" \ |
| 1735 | "Options:\n" \ | 1735 | "Options:\n" \ |
| 1736 | "\t-c\tcontinue retrieval of aborted transfers\n" \ | 1736 | "\t-c\tcontinue retrieval of aborted transfers\n" \ |
| 1737 | "\t-q\tquiet mode - do not print\n" \ | 1737 | "\t-q\tquiet mode - do not print\n" \ |
| 1738 | "\t-P\tSet directory prefix to DIR\n" \ | ||
| 1738 | "\t-O\tsave to filename ('-' for stdout)" | 1739 | "\t-O\tsave to filename ('-' for stdout)" |
| 1739 | 1740 | ||
| 1740 | #define which_trivial_usage \ | 1741 | #define which_trivial_usage \ |
diff --git a/include/usage.h b/include/usage.h index acba3677c..9fd3a2e1c 100644 --- a/include/usage.h +++ b/include/usage.h | |||
| @@ -1729,12 +1729,13 @@ | |||
| 1729 | " 31 46 1365 /etc/passwd\n" | 1729 | " 31 46 1365 /etc/passwd\n" |
| 1730 | 1730 | ||
| 1731 | #define wget_trivial_usage \ | 1731 | #define wget_trivial_usage \ |
| 1732 | "[-c|--continue] [-q|--quiet] [-O|--output-document file] [--header 'header: value'] url" | 1732 | "[-c|--continue] [-q|--quiet] [-O|--output-document file]\n\t[--header 'header: value'] [-P DIR] url" |
| 1733 | #define wget_full_usage \ | 1733 | #define wget_full_usage \ |
| 1734 | "wget retrieves files via HTTP or FTP\n\n" \ | 1734 | "wget retrieves files via HTTP or FTP\n\n" \ |
| 1735 | "Options:\n" \ | 1735 | "Options:\n" \ |
| 1736 | "\t-c\tcontinue retrieval of aborted transfers\n" \ | 1736 | "\t-c\tcontinue retrieval of aborted transfers\n" \ |
| 1737 | "\t-q\tquiet mode - do not print\n" \ | 1737 | "\t-q\tquiet mode - do not print\n" \ |
| 1738 | "\t-P\tSet directory prefix to DIR\n" \ | ||
| 1738 | "\t-O\tsave to filename ('-' for stdout)" | 1739 | "\t-O\tsave to filename ('-' for stdout)" |
| 1739 | 1740 | ||
| 1740 | #define which_trivial_usage \ | 1741 | #define which_trivial_usage \ |
diff --git a/networking/wget.c b/networking/wget.c index 6fd170d4d..61945b7d1 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
| @@ -160,6 +160,7 @@ int wget_main(int argc, char **argv) | |||
| 160 | int n, try=5, status; | 160 | int n, try=5, status; |
| 161 | int port; | 161 | int port; |
| 162 | char *proxy; | 162 | char *proxy; |
| 163 | char *dir_prefix=NULL; | ||
| 163 | char *s, buf[512]; | 164 | char *s, buf[512]; |
| 164 | struct stat sbuf; | 165 | struct stat sbuf; |
| 165 | char extra_headers[1024]; | 166 | char extra_headers[1024]; |
| @@ -188,11 +189,14 @@ int wget_main(int argc, char **argv) | |||
| 188 | /* | 189 | /* |
| 189 | * Crack command line. | 190 | * Crack command line. |
| 190 | */ | 191 | */ |
| 191 | while ((n = getopt_long(argc, argv, "cqO:", long_options, &option_index)) != EOF) { | 192 | while ((n = getopt_long(argc, argv, "cqO:P:", long_options, &option_index)) != EOF) { |
| 192 | switch (n) { | 193 | switch (n) { |
| 193 | case 'c': | 194 | case 'c': |
| 194 | ++do_continue; | 195 | ++do_continue; |
| 195 | break; | 196 | break; |
| 197 | case 'P': | ||
| 198 | dir_prefix = optarg; | ||
| 199 | break; | ||
| 196 | case 'q': | 200 | case 'q': |
| 197 | quiet_flag = TRUE; | 201 | quiet_flag = TRUE; |
| 198 | break; | 202 | break; |
| @@ -224,7 +228,6 @@ int wget_main(int argc, char **argv) | |||
| 224 | } | 228 | } |
| 225 | } | 229 | } |
| 226 | 230 | ||
| 227 | fprintf(stderr, "extra_headers='%s'\n", extra_headers); | ||
| 228 | if (argc - optind != 1) | 231 | if (argc - optind != 1) |
| 229 | show_usage(); | 232 | show_usage(); |
| 230 | 233 | ||
| @@ -269,6 +272,7 @@ int wget_main(int argc, char **argv) | |||
| 269 | output = stdout; | 272 | output = stdout; |
| 270 | quiet_flag = TRUE; | 273 | quiet_flag = TRUE; |
| 271 | } else { | 274 | } else { |
| 275 | fname_out = concat_path_file(dir_prefix, fname_out); | ||
| 272 | output = xfopen(fname_out, (do_continue ? "a" : "w")); | 276 | output = xfopen(fname_out, (do_continue ? "a" : "w")); |
| 273 | } | 277 | } |
| 274 | 278 | ||
| @@ -812,7 +816,7 @@ progressmeter(int flag) | |||
| 812 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 816 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 813 | * SUCH DAMAGE. | 817 | * SUCH DAMAGE. |
| 814 | * | 818 | * |
| 815 | * $Id: wget.c,v 1.41 2001/05/16 15:40:48 kraai Exp $ | 819 | * $Id: wget.c,v 1.42 2001/06/21 19:45:06 andersen Exp $ |
| 816 | */ | 820 | */ |
| 817 | 821 | ||
| 818 | 822 | ||
| @@ -1729,12 +1729,13 @@ | |||
| 1729 | " 31 46 1365 /etc/passwd\n" | 1729 | " 31 46 1365 /etc/passwd\n" |
| 1730 | 1730 | ||
| 1731 | #define wget_trivial_usage \ | 1731 | #define wget_trivial_usage \ |
| 1732 | "[-c|--continue] [-q|--quiet] [-O|--output-document file] [--header 'header: value'] url" | 1732 | "[-c|--continue] [-q|--quiet] [-O|--output-document file]\n\t[--header 'header: value'] [-P DIR] url" |
| 1733 | #define wget_full_usage \ | 1733 | #define wget_full_usage \ |
| 1734 | "wget retrieves files via HTTP or FTP\n\n" \ | 1734 | "wget retrieves files via HTTP or FTP\n\n" \ |
| 1735 | "Options:\n" \ | 1735 | "Options:\n" \ |
| 1736 | "\t-c\tcontinue retrieval of aborted transfers\n" \ | 1736 | "\t-c\tcontinue retrieval of aborted transfers\n" \ |
| 1737 | "\t-q\tquiet mode - do not print\n" \ | 1737 | "\t-q\tquiet mode - do not print\n" \ |
| 1738 | "\t-P\tSet directory prefix to DIR\n" \ | ||
| 1738 | "\t-O\tsave to filename ('-' for stdout)" | 1739 | "\t-O\tsave to filename ('-' for stdout)" |
| 1739 | 1740 | ||
| 1740 | #define which_trivial_usage \ | 1741 | #define which_trivial_usage \ |
| @@ -160,6 +160,7 @@ int wget_main(int argc, char **argv) | |||
| 160 | int n, try=5, status; | 160 | int n, try=5, status; |
| 161 | int port; | 161 | int port; |
| 162 | char *proxy; | 162 | char *proxy; |
| 163 | char *dir_prefix=NULL; | ||
| 163 | char *s, buf[512]; | 164 | char *s, buf[512]; |
| 164 | struct stat sbuf; | 165 | struct stat sbuf; |
| 165 | char extra_headers[1024]; | 166 | char extra_headers[1024]; |
| @@ -188,11 +189,14 @@ int wget_main(int argc, char **argv) | |||
| 188 | /* | 189 | /* |
| 189 | * Crack command line. | 190 | * Crack command line. |
| 190 | */ | 191 | */ |
| 191 | while ((n = getopt_long(argc, argv, "cqO:", long_options, &option_index)) != EOF) { | 192 | while ((n = getopt_long(argc, argv, "cqO:P:", long_options, &option_index)) != EOF) { |
| 192 | switch (n) { | 193 | switch (n) { |
| 193 | case 'c': | 194 | case 'c': |
| 194 | ++do_continue; | 195 | ++do_continue; |
| 195 | break; | 196 | break; |
| 197 | case 'P': | ||
| 198 | dir_prefix = optarg; | ||
| 199 | break; | ||
| 196 | case 'q': | 200 | case 'q': |
| 197 | quiet_flag = TRUE; | 201 | quiet_flag = TRUE; |
| 198 | break; | 202 | break; |
| @@ -224,7 +228,6 @@ int wget_main(int argc, char **argv) | |||
| 224 | } | 228 | } |
| 225 | } | 229 | } |
| 226 | 230 | ||
| 227 | fprintf(stderr, "extra_headers='%s'\n", extra_headers); | ||
| 228 | if (argc - optind != 1) | 231 | if (argc - optind != 1) |
| 229 | show_usage(); | 232 | show_usage(); |
| 230 | 233 | ||
| @@ -269,6 +272,7 @@ int wget_main(int argc, char **argv) | |||
| 269 | output = stdout; | 272 | output = stdout; |
| 270 | quiet_flag = TRUE; | 273 | quiet_flag = TRUE; |
| 271 | } else { | 274 | } else { |
| 275 | fname_out = concat_path_file(dir_prefix, fname_out); | ||
| 272 | output = xfopen(fname_out, (do_continue ? "a" : "w")); | 276 | output = xfopen(fname_out, (do_continue ? "a" : "w")); |
| 273 | } | 277 | } |
| 274 | 278 | ||
| @@ -812,7 +816,7 @@ progressmeter(int flag) | |||
| 812 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 816 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 813 | * SUCH DAMAGE. | 817 | * SUCH DAMAGE. |
| 814 | * | 818 | * |
| 815 | * $Id: wget.c,v 1.41 2001/05/16 15:40:48 kraai Exp $ | 819 | * $Id: wget.c,v 1.42 2001/06/21 19:45:06 andersen Exp $ |
| 816 | */ | 820 | */ |
| 817 | 821 | ||
| 818 | 822 | ||
