X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fmain.c;h=159973a0021a2e36e80d5c389f8c40fa38f3b91e;hp=fdf368a51fc2e897e9fc2e236a8d5e9744bea2f5;hb=d78cd8d8f8e12d1b71ac19795131d6975abe544b;hpb=da51f9b2c41ca5f7de5ef3c6d6b8fd5fb2a8142b diff --git a/src/main.c b/src/main.c index fdf368a5..159973a0 100644 --- a/src/main.c +++ b/src/main.c @@ -56,6 +56,8 @@ as that of the covered work. */ #include "http.h" /* for save_cookies */ #include +#include +#include #ifndef PATH_SEPARATOR # define PATH_SEPARATOR '/' @@ -130,6 +132,7 @@ static struct cmdline_option option_data[] = { { "accept", 'A', OPT_VALUE, "accept", -1 }, { "append-output", 'a', OPT__APPEND_OUTPUT, NULL, required_argument }, + { "ask-password", 0, OPT_BOOLEAN, "askpassword", -1 }, { "auth-no-challenge", 0, OPT_BOOLEAN, "authnochallenge", -1 }, { "background", 'b', OPT_BOOLEAN, "background", -1 }, { "backup-converted", 'K', OPT_BOOLEAN, "backupconverted", -1 }, @@ -472,6 +475,8 @@ Download:\n"), --user=USER set both ftp and http user to USER.\n"), N_("\ --password=PASS set both ftp and http password to PASS.\n"), + N_("\ + --ask-password prompt for passwords.\n"), "\n", N_("\ @@ -673,6 +678,16 @@ secs_to_human_time (double interval) return buf; } +static char * +prompt_for_password (void) +{ + if (opt.user) + printf (_("Password for user %s: "), quote (opt.user)); + else + printf (_("Password: ")); + return getpass(""); +} + static void print_version (void) { @@ -913,6 +928,13 @@ for details.\n\n")); } } + if (opt.ask_passwd && opt.passwd) + { + printf (_("Cannot specify both --ask-password and --password.\n")); + print_usage (); + exit (1); + } + if (!nurl && !opt.input_filename) { /* No URL specified. */ @@ -1008,6 +1030,9 @@ for details.\n\n")); char *filename = NULL, *redirected_URL = NULL; int dt; + if (opt.ask_passwd) + opt.passwd = prompt_for_password (); + if ((opt.recursive || opt.page_requisites) && (url_scheme (*t) != SCHEME_FTP || url_uses_proxy (*t))) {