curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

[RFC PATCH] setopt: make curl_easy_vsetopt public

From: Drew DeVault via curl-library <curl-library_at_lists.haxx.se>
Date: Mon, 21 Mar 2022 19:15:18 +0100

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 <sir_at_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
_at__at_ -21,6 +21,8 _at__at_
  * KIND, either express or implied.
  *
  ***************************************************************************/
+#include <stdarg.h>
+
 #ifdef  __cplusplus
 extern "C" {
 #endif
_at__at_ -38,6 +40,7 _at__at_ 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
_at__at_ -146,11 +146,7 _at__at_ 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;
_at__at_ -160,6 +156,9 _at__at_ 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);
_at__at_ -3044,12 +3043,9 _at__at_ 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
_at__at_ -25,6 +25,5 _at__at_
 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
_at__at_ -1264,7 +1264,7 _at__at_ 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
Received on 2022-03-21