aboutsummaryrefslogtreecommitdiff
path: root/src/tool_paramhlp.c
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2014-02-14 21:59:51 +0000
committerSteve Holme <steve_holme@hotmail.com>2014-02-15 16:31:32 +0000
commitf80ca7a05a2affce7b02f618592981aa02e61ce7 (patch)
treed1b2ec919870d044c51391826dfde3caa92ed7fe /src/tool_paramhlp.c
parent89070d0e680402fd92468eb13073434ea5e5380e (diff)
tool_operate: Moved required argument getting into separate function
Diffstat (limited to 'src/tool_paramhlp.c')
-rw-r--r--src/tool_paramhlp.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c
index 46e926952..6dcee8d5f 100644
--- a/src/tool_paramhlp.c
+++ b/src/tool_paramhlp.c
@@ -33,6 +33,7 @@
#include "tool_homedir.h"
#include "tool_msgs.h"
#include "tool_paramhlp.h"
+#include "tool_version.h"
#include "memdebug.h" /* keep this as LAST include */
@@ -365,8 +366,8 @@ ParameterError str2offset(curl_off_t *val, const char *str)
return PARAM_BAD_NUMERIC;
}
-CURLcode checkpasswd(const char *kind, /* for what purpose */
- char **userpwd) /* pointer to allocated string */
+static CURLcode checkpasswd(const char *kind, /* for what purpose */
+ char **userpwd) /* pointer to allocated string */
{
char *psep;
char *osep;
@@ -464,3 +465,40 @@ long delegation(struct Configurable *config, char *str)
return CURLGSSAPI_DELEGATION_NONE;
}
+/*
+ * my_useragent: returns allocated string with default user agent
+ */
+static char *my_useragent(void)
+{
+ return strdup(CURL_NAME "/" CURL_VERSION);
+}
+
+CURLcode get_args(struct Configurable *config)
+{
+ CURLcode result = CURLE_OK;
+
+ /* Check we have a password for the given host user */
+ if(config->userpwd && !config->xoauth2_bearer) {
+ result = checkpasswd("host", &config->userpwd);
+ if(result)
+ return result;
+ }
+
+ /* Check we have a password for the given proxy user */
+ if(config->proxyuserpwd) {
+ result = checkpasswd("proxy", &config->proxyuserpwd);
+ if(result)
+ return result;
+ }
+
+ /* Check we have a user agent */
+ if(!config->useragent) {
+ config->useragent = my_useragent();
+ if(!config->useragent) {
+ helpf(config->errors, "out of memory\n");
+ result = CURLE_OUT_OF_MEMORY;
+ }
+ }
+
+ return result;
+}