aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2014-02-16 11:10:09 +0000
committerSteve Holme <steve_holme@hotmail.com>2014-02-16 11:13:16 +0000
commitf3bae6ed737c59791c5d36932e4d2387309f8fdb (patch)
treeab98cdcbe9ab7fa19d47876733863d4a1eca1b6f
parent013e9a11ffffe954ca56b70b8400fe1986966e96 (diff)
tool_paramhlp: Added URL index to password prompt for multiple operations
-rw-r--r--src/tool_operate.c3
-rw-r--r--src/tool_paramhlp.c23
-rw-r--r--src/tool_paramhlp.h2
3 files changed, 19 insertions, 9 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 6e0715707..efe9bfc64 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -1838,11 +1838,12 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
}
/* Perform the main operations */
else {
+ size_t count = 0;
struct Configurable *operation = config;
/* Get the required aguments for each operation */
while(!result && operation) {
- result = get_args(operation);
+ result = get_args(operation, count++);
operation = operation->next;
}
diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c
index 6dcee8d5f..d4f1368c4 100644
--- a/src/tool_paramhlp.c
+++ b/src/tool_paramhlp.c
@@ -366,7 +366,9 @@ ParameterError str2offset(curl_off_t *val, const char *str)
return PARAM_BAD_NUMERIC;
}
-static CURLcode checkpasswd(const char *kind, /* for what purpose */
+static CURLcode checkpasswd(const char *kind, /* for what purpose */
+ const size_t index, /* operation index */
+ const bool last, /* TRUE if last operation */
char **userpwd) /* pointer to allocated string */
{
char *psep;
@@ -393,9 +395,15 @@ static CURLcode checkpasswd(const char *kind, /* for what purpose */
*osep = '\0';
/* build a nice-looking prompt */
- curlx_msnprintf(prompt, sizeof(prompt),
- "Enter %s password for user '%s':",
- kind, *userpwd);
+ if(!index && last)
+ curlx_msnprintf(prompt, sizeof(prompt),
+ "Enter %s password for user '%s':",
+ kind, *userpwd);
+ else
+ curlx_msnprintf(prompt, sizeof(prompt),
+ "Enter %s password for user '%s' on URL #%"
+ CURL_FORMAT_CURL_OFF_TU ":",
+ kind, *userpwd, index + 1);
/* get password */
getpass_r(prompt, passwd, sizeof(passwd));
@@ -473,20 +481,21 @@ static char *my_useragent(void)
return strdup(CURL_NAME "/" CURL_VERSION);
}
-CURLcode get_args(struct Configurable *config)
+CURLcode get_args(struct Configurable *config, const size_t index)
{
CURLcode result = CURLE_OK;
+ bool last = (config->next ? FALSE : TRUE);
/* Check we have a password for the given host user */
if(config->userpwd && !config->xoauth2_bearer) {
- result = checkpasswd("host", &config->userpwd);
+ result = checkpasswd("host", index, last, &config->userpwd);
if(result)
return result;
}
/* Check we have a password for the given proxy user */
if(config->proxyuserpwd) {
- result = checkpasswd("proxy", &config->proxyuserpwd);
+ result = checkpasswd("proxy", index, last, &config->proxyuserpwd);
if(result)
return result;
}
diff --git a/src/tool_paramhlp.h b/src/tool_paramhlp.h
index 844137445..e56d63691 100644
--- a/src/tool_paramhlp.h
+++ b/src/tool_paramhlp.h
@@ -40,7 +40,7 @@ long proto2num(struct Configurable *config, long *val, const char *str);
ParameterError str2offset(curl_off_t *val, const char *str);
-CURLcode get_args(struct Configurable *config);
+CURLcode get_args(struct Configurable *config, const size_t index);
ParameterError add2list(struct curl_slist **list, const char *ptr);