curl / Mailing Lists / curl-library / Single Mail

curl-library

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

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

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

---
 docs/libcurl/curl_share_setopt.3 |  6 +++++-
 include/curl/curl.h              |  1 +
 lib/share.c                      | 18 +++++++++++++-----
 3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/docs/libcurl/curl_share_setopt.3 b/docs/libcurl/curl_share_setopt.3
index 55e06f129..893a19997 100644
--- a/docs/libcurl/curl_share_setopt.3
+++ b/docs/libcurl/curl_share_setopt.3
@@ -21,14 +21,18 @@
 .\" **************************************************************************
 .TH curl_share_setopt 3 "8 Aug 2003" "libcurl 7.10.7" "libcurl Manual"
 .SH NAME
-curl_share_setopt - Set options for a shared object
+curl_share_setopt, curl_share_setopt_va - Set options for a shared object
 .SH SYNOPSIS
 .B #include <curl/curl.h>
 .sp
 CURLSHcode curl_share_setopt(CURLSH *share, CURLSHoption option, parameter);
+
+CURLSHcode curl_share_setopt_va(CURLSH *share, CURLSHoption option, va_list params);
 .ad
 .SH DESCRIPTION
 Set the \fIoption\fP to \fIparameter\fP for the given \fIshare\fP.
+
+For curl_share_setopt_va the first element of the va_list should contain \fIparameter\fP.
 .SH OPTIONS
 .IP CURLSHOPT_LOCKFUNC
 The \fIparameter\fP must be a pointer to a function matching the following
diff --git a/include/curl/curl.h b/include/curl/curl.h
index 36ecf53cd..f1cb35c93 100644
--- a/include/curl/curl.h
+++ b/include/curl/curl.h
@@ -2382,6 +2382,7 @@ typedef enum {
 
 CURL_EXTERN CURLSH *curl_share_init(void);
 CURL_EXTERN CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption option, ...);
+CURL_EXTERN CURLSHcode curl_share_setopt_va(CURLSH *, CURLSHoption option, va_list params);
 CURL_EXTERN CURLSHcode curl_share_cleanup(CURLSH *);
 
 /****************************************************************************
diff --git a/lib/share.c b/lib/share.c
index 5b3957fcf..da8331536 100644
--- a/lib/share.c
+++ b/lib/share.c
@@ -47,11 +47,9 @@ curl_share_init(void)
   return share;
 }
 
-#undef curl_share_setopt
 CURLSHcode
-curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)
+curl_share_setopt_va(struct Curl_share *share, CURLSHoption option, va_list param)
 {
-  va_list param;
   int type;
   curl_lock_function lockfunc;
   curl_unlock_function unlockfunc;
@@ -63,8 +61,6 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)
        using this share */
     return CURLSHE_IN_USE;
 
-  va_start(param, option);
-
   switch(option) {
   case CURLSHOPT_SHARE:
     /* this is a type this share will share */
@@ -165,6 +161,18 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)
     break;
   }
 
+  return res;
+}
+
+#undef curl_share_setopt
+CURLSHcode
+curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)
+{
+  va_list param;
+  CURLSHcode res;
+
+  va_start(param, option);
+  res = curl_share_setopt_va(share, option, param);
   va_end(param);
 
   return res;
-- 
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