wget: make Bartosz's "wget --passive-ftp -nd -t 3" work
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 20 Oct 2015 19:51:52 +0000 (21:51 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 20 Oct 2015 19:51:52 +0000 (21:51 +0200)
function                                             old     new   delta
static.wget_longopts                                 166     234     +68
wget_main                                           2608    2610      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/wget.c

index af9c53c223d0a707360aa55dc0585b5fad105142..7f27e4e7b8aa0e8bc56ebbd5e30cbc5caf07c64a 100644 (file)
 //usage:       "[-c|--continue] [-s|--spider] [-q|--quiet] [-O|--output-document FILE]\n"
 //usage:       "       [--header 'header: value'] [-Y|--proxy on/off] [-P DIR]\n"
 /* Since we ignore these opts, we don't show them in --help */
-/* //usage:    "       [--no-check-certificate] [--no-cache]" */
+/* //usage:    "       [--no-check-certificate] [--no-cache] [--passive-ftp] [-t TRIES]" */
+/* //usage:    "       [-nv] [-nc] [-nH] [-np]" */
 //usage:       "       [-U|--user-agent AGENT]" IF_FEATURE_WGET_TIMEOUT(" [-T SEC]") " URL..."
 //usage:       )
 //usage:       IF_NOT_FEATURE_WGET_LONG_OPTIONS(
@@ -1219,19 +1220,22 @@ int wget_main(int argc UNUSED_PARAM, char **argv)
                "directory-prefix\0" Required_argument "P"
                "proxy\0"            Required_argument "Y"
                "user-agent\0"       Required_argument "U"
-#if ENABLE_FEATURE_WGET_TIMEOUT
-               "timeout\0"          Required_argument "T"
-#endif
+IF_FEATURE_WGET_TIMEOUT(
+               "timeout\0"          Required_argument "T")
                /* Ignored: */
-               // "tries\0"            Required_argument "t"
+IF_DESKTOP(    "tries\0"            Required_argument "t")
+               "header\0"           Required_argument "\xff"
+               "post-data\0"        Required_argument "\xfe"
                /* Ignored (we always use PASV): */
-               "passive-ftp\0"      No_argument       "\xff"
-               "header\0"           Required_argument "\xfe"
-               "post-data\0"        Required_argument "\xfd"
+IF_DESKTOP(    "passive-ftp\0"      No_argument       "\xf0")
                /* Ignored (we don't do ssl) */
-               "no-check-certificate\0" No_argument   "\xfc"
+IF_DESKTOP(    "no-check-certificate\0" No_argument   "\xf0")
                /* Ignored (we don't support caching) */
-               "no-cache\0"         No_argument       "\xfb"
+IF_DESKTOP(    "no-cache\0"         No_argument       "\xf0")
+IF_DESKTOP(    "no-verbose\0"       No_argument       "\xf0")
+IF_DESKTOP(    "no-clobber\0"       No_argument       "\xf0")
+IF_DESKTOP(    "no-host-directories\0" No_argument    "\xf0")
+IF_DESKTOP(    "no-parent\0"        No_argument       "\xf0")
                ;
 #endif
 
@@ -1251,14 +1255,25 @@ int wget_main(int argc UNUSED_PARAM, char **argv)
 #if ENABLE_FEATURE_WGET_LONG_OPTIONS
        applet_long_options = wget_longopts;
 #endif
-       opt_complementary = "-1"
-                       IF_FEATURE_WGET_TIMEOUT(":T+")
-                       IF_FEATURE_WGET_LONG_OPTIONS(":\xfe::");
-       getopt32(argv, "csqO:P:Y:U:T:" /*ignored:*/ "t:",
-               &G.fname_out, &G.dir_prefix,
+       opt_complementary = "-1" /* at least one URL */
+               IF_FEATURE_WGET_TIMEOUT(":T+") /* -T NUM */
+               IF_FEATURE_WGET_LONG_OPTIONS(":\xff::"); /* --header is a list */
+       getopt32(argv, "csqO:P:Y:U:T:"
+               /*ignored:*/ "t:"
+               /*ignored:*/ "n::"
+               /* wget has exactly four -n<letter> opts, all of which we can ignore:
+                * -nv --no-verbose: be moderately quiet (-q is full quiet)
+                * -nc --no-clobber: abort if exists, neither download to FILE.n nor overwrite FILE
+                * -nH --no-host-directories: wget -r http://host/ won't create host/
+                * -np --no-parent
+                * "n::" above says that we accept -n[ARG].
+                * Specifying "n:" would be a bug: "-n ARG" would eat ARG!
+                */
+               , &G.fname_out, &G.dir_prefix,
                &G.proxy_flag, &G.user_agent,
                IF_FEATURE_WGET_TIMEOUT(&G.timeout_seconds) IF_NOT_FEATURE_WGET_TIMEOUT(NULL),
-               NULL /* -t RETRIES */
+               NULL, /* -t RETRIES */
+               NULL  /* -n[ARG] */
                IF_FEATURE_WGET_LONG_OPTIONS(, &headers_llist)
                IF_FEATURE_WGET_LONG_OPTIONS(, &G.post_data)
        );