This moves the internal Curl_vsetopt function into the public API so
that users can set options with a va_list.

Signed-off-by: Drew DeVault <s...@cmpwn.com>
---
Sending RFC to see if people are generally cool with this. If so, will
follow up with a man page as well.

 include/curl/easy.h        |  3 +++
 lib/setopt.c               | 14 +++++---------
 lib/setopt.h               |  1 -
 packages/OS400/ccsidcurl.c |  2 +-
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/include/curl/easy.h b/include/curl/easy.h
index 2dbfb26b5..ce6a77c8f 100644
--- a/include/curl/easy.h
+++ b/include/curl/easy.h
@@ -21,6 +21,8 @@
  * KIND, either express or implied.
  *
  ***************************************************************************/
+#include <stdarg.h>
+
 #ifdef  __cplusplus
 extern "C" {
 #endif
@@ -38,6 +40,7 @@ struct curl_blob {
 
 CURL_EXTERN CURL *curl_easy_init(void);
 CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
+CURL_EXTERN CURLcode curl_easy_vsetopt(CURL *curl, CURLoption option, va_list 
param);
 CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
 CURL_EXTERN void curl_easy_cleanup(CURL *curl);
 
diff --git a/lib/setopt.c b/lib/setopt.c
index 8e1bf1279..247234c63 100644
--- a/lib/setopt.c
+++ b/lib/setopt.c
@@ -146,11 +146,7 @@ static CURLcode setstropt_userpwd(char *option, char 
**userp, char **passwdp)
 #define C_SSLVERSION_VALUE(x) (x & 0xffff)
 #define C_SSLVERSION_MAX_VALUE(x) (x & 0xffff0000)
 
-/*
- * Do not make Curl_vsetopt() static: it is called from
- * packages/OS400/ccsidcurl.c.
- */
-CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
+CURLcode curl_easy_vsetopt(struct Curl_easy *data, CURLoption option, va_list 
param)
 {
   char *argptr;
   CURLcode result = CURLE_OK;
@@ -160,6 +156,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption 
option, va_list param)
 #endif
   curl_off_t bigsize;
 
+  if(!data)
+    return CURLE_BAD_FUNCTION_ARGUMENT;
+
   switch(option) {
   case CURLOPT_DNS_CACHE_TIMEOUT:
     arg = va_arg(param, long);
@@ -3044,12 +3043,9 @@ CURLcode curl_easy_setopt(struct Curl_easy *data, 
CURLoption tag, ...)
   va_list arg;
   CURLcode result;
 
-  if(!data)
-    return CURLE_BAD_FUNCTION_ARGUMENT;
-
   va_start(arg, tag);
 
-  result = Curl_vsetopt(data, tag, arg);
+  result = curl_easy_vsetopt(data, tag, arg);
 
   va_end(arg);
   return result;
diff --git a/lib/setopt.h b/lib/setopt.h
index affbfd996..2d7a37995 100644
--- a/lib/setopt.h
+++ b/lib/setopt.h
@@ -25,6 +25,5 @@
 CURLcode Curl_setstropt(char **charp, const char *s);
 CURLcode Curl_setblobopt(struct curl_blob **blobp,
                          const struct curl_blob *blob);
-CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list arg);
 
 #endif /* HEADER_CURL_SETOPT_H */
diff --git a/packages/OS400/ccsidcurl.c b/packages/OS400/ccsidcurl.c
index 4b30683ea..3f9a3a9ee 100644
--- a/packages/OS400/ccsidcurl.c
+++ b/packages/OS400/ccsidcurl.c
@@ -1264,7 +1264,7 @@ curl_easy_setopt_ccsid(CURL *curl, CURLoption tag, ...)
 
   case CURLOPT_ERRORBUFFER:                     /* This is an output buffer. */
   default:
-    result = Curl_vsetopt(curl, tag, arg);
+    result = curl_easy_vsetopt(curl, tag, arg);
     break;
   }
 
-- 
2.35.1

-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Reply via email to