}
/* 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;
}
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;
*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));
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;
}