curl / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH 2/5] curl_easy_setopt: Add va() API function

From: Ioan-Adrian Ratiu <adrian.ratiu_at_ni.com>
Date: Fri, 20 Jan 2017 17:42:41 +0200

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu_at_ni.com>

---
 docs/libcurl/curl_easy_setopt.3 |  6 +++++-
 include/curl/easy.h             |  1 +
 lib/easy.c                      | 22 +++++++++++++++-------
 3 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/docs/libcurl/curl_easy_setopt.3 b/docs/libcurl/curl_easy_setopt.3
index 422cb8569..b8eb8977b 100644
--- a/docs/libcurl/curl_easy_setopt.3
+++ b/docs/libcurl/curl_easy_setopt.3
@@ -22,11 +22,13 @@
 .\"
 .TH curl_easy_setopt 3 "25 Jun 2014" "libcurl 7.38.0" "libcurl Manual"
 .SH NAME
-curl_easy_setopt \- set options for a curl easy handle
+curl_easy_setopt,curl_easy_setopt_va \- set options for a curl easy handle
 .SH SYNOPSIS
 #include <curl/curl.h>
 
 CURLcode curl_easy_setopt(CURL *handle, CURLoption option, parameter);
+
+CURLcode curl_easy_setopt_va(CURL *handle, CURLoption option, va_list params);
 .SH DESCRIPTION
 \fIcurl_easy_setopt(3)\fP is used to tell libcurl how to behave. By setting
 the appropriate options, the application can change libcurl's behavior.  All
@@ -37,6 +39,8 @@ expects. Read this manual carefully as bad input values may cause libcurl to
 behave badly!  You can only set one option in each function call. A typical
 application uses many \fIcurl_easy_setopt(3)\fP calls in the setup phase.
 
+For curl_easy_setopt_va the first element of the va_list should contain \fIparam\fP.
+
 Options set with this function call are valid for all forthcoming transfers
 performed using this \fIhandle\fP.  The options are not in any way reset
 between transfers, so if you want subsequent transfers with different options,
diff --git a/include/curl/easy.h b/include/curl/easy.h
index 2db58d03e..6ec663102 100644
--- a/include/curl/easy.h
+++ b/include/curl/easy.h
@@ -27,6 +27,7 @@ extern "C" {
 
 CURL_EXTERN CURL *curl_easy_init(void);
 CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
+CURL_EXTERN CURLcode curl_easy_setopt_va(CURL *curl, CURLoption option, va_list params);
 CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
 CURL_EXTERN void curl_easy_cleanup(CURL *curl);
 
diff --git a/lib/easy.c b/lib/easy.c
index 0fbc9cb41..59a4ab1eb 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -366,24 +366,32 @@ struct Curl_easy *curl_easy_init(void)
 }
 
 /*
- * curl_easy_setopt() is the external interface for setting options on an
- * easy handle.
+ * curl_easy_setopt()/curl_easy_setopt_va() are external interfaces for
+ * setting options on an easy handle.
  */
 
-#undef curl_easy_setopt
-CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...)
+CURLcode curl_easy_setopt_va(struct Curl_easy *data, CURLoption tag, va_list arg)
 {
-  va_list arg;
   CURLcode result;
 
   if(!data)
     return CURLE_BAD_FUNCTION_ARGUMENT;
 
-  va_start(arg, tag);
-
   result = Curl_setopt(data, tag, arg);
 
+  return result;
+}
+
+#undef curl_easy_setopt
+CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...)
+{
+  va_list arg;
+  CURLcode result;
+
+  va_start(arg, tag);
+  result = curl_easy_setopt_va(data, tag, arg);
   va_end(arg);
+
   return result;
 }
 
-- 
2.11.0
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2017-01-20