ftpget/put: make 3rd parameter optional
authorVladimir Dronnikov <dronnikov@gmail.com>
Fri, 23 Oct 2009 21:34:43 +0000 (23:34 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 23 Oct 2009 21:34:43 +0000 (23:34 +0200)
function                                             old     new   delta
packed_usage                                       26728   26738     +10
ftpgetput_main                                       343     351      +8

Signed-off-by: Vladimir Dronnikov <dronnikov@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
include/usage.h
networking/ftpgetput.c

index 8db1946cd6e8fe517921a86db145fe161e98bebb..d03ec2295d82539d76758f9c294e00a0d91ba25d 100644 (file)
      "\n       DIR     Change root to this directory" \
 
 #define ftpget_trivial_usage \
-       "[OPTIONS] HOST LOCAL_FILE REMOTE_FILE"
+       "[OPTIONS] HOST [LOCAL_FILE] REMOTE_FILE"
 #define ftpget_full_usage "\n\n" \
        "Retrieve a remote file via FTP\n" \
      "\nOptions:" \
        )
 
 #define ftpput_trivial_usage \
-       "[OPTIONS] HOST REMOTE_FILE LOCAL_FILE"
+       "[OPTIONS] HOST [REMOTE_FILE] LOCAL_FILE"
 #define ftpput_full_usage "\n\n" \
        "Store a local file on a remote machine via FTP\n" \
      "\nOptions:" \
index d39b73ebb56a8642698a094c99ce16c47b01fd2b..c0ecddac1cab4e208999d2eb12a37e7ab87296aa 100644 (file)
@@ -306,7 +306,7 @@ int ftpgetput_main(int argc UNUSED_PARAM, char **argv)
 #if ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS
        applet_long_options = ftpgetput_longopts;
 #endif
-       opt_complementary = "=3:vv:cc"; /* must have 3 params; -v and -c count */
+       opt_complementary = "-2:vv:cc"; /* must have 2 to 3 params; -v and -c count */
        opt = getopt32(argv, "cvu:p:P:", &user, &password, &port,
                                        &verbose_flag, &do_continue);
        argv += optind;
@@ -321,5 +321,5 @@ int ftpgetput_main(int argc UNUSED_PARAM, char **argv)
        }
 
        ftp_login();
-       return ftp_action(argv[1], argv[2]);
+       return ftp_action(argv[1], argv[2] ? argv[2] : argv[1]);
 }