cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: extract max keepalive requests configuration using a discovery loop

From: Roberto Nibali <ratz_at_drugphish.ch>
Date: Wed, 28 Sep 2005 01:34:26 +0200

> Why is there no libcurl_easy_getopt()? Just curious.

Something along the lines of (completely unfinished and untested, should
depict the idea):

diff -ur curl-7.14.1/include/curl/curl.h
curl-7.14.1-ratz/include/curl/curl.h
--- curl-7.14.1/include/curl/curl.h 2005-08-27 07:34:46.000000000 +0200
+++ curl-7.14.1-ratz/include/curl/curl.h 2005-09-28
01:17:00.246727502 +0200
@@ -896,6 +896,9 @@
    /* ignore Content-Length */
    CINIT(IGNORE_CONTENT_LENGTH, LONG, 136),

+ CINIT(TEST_LONG, LONG, 137),
+ CINIT(TEST_CHAR, OBJECTPOINT, 138),
+
    CURLOPT_LASTENTRY /* the last unused */
  } CURLoption;

@@ -1336,6 +1339,7 @@
  } CURLSHoption;

  CURL_EXTERN CURLSH *curl_share_init(void);
+CURL_EXTERN CURLSHcode curl_share_getopt(CURLSH *, CURLSHoption option,
CURLSH *);
  CURL_EXTERN CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption
option, ...);
  CURL_EXTERN CURLSHcode curl_share_cleanup(CURLSH *);

diff -ur curl-7.14.1/include/curl/easy.h
curl-7.14.1-ratz/include/curl/easy.h
--- curl-7.14.1/include/curl/easy.h 2004-11-09 15:02:58.000000000 +0100
+++ curl-7.14.1-ratz/include/curl/easy.h 2005-09-28
01:11:07.817240084 +0200
@@ -28,6 +28,7 @@

  CURL_EXTERN CURL *curl_easy_init(void);
  CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
+CURL_EXTERN CURLcode curl_easy_getopt(CURL *curl, CURLoption option,
void *);
  CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
  CURL_EXTERN void curl_easy_cleanup(CURL *curl);

diff -ur curl-7.14.1/lib/ca-bundle.h curl-7.14.1-ratz/lib/ca-bundle.h
--- curl-7.14.1/lib/ca-bundle.h 2005-09-01 22:54:42.000000000 +0200
+++ curl-7.14.1-ratz/lib/ca-bundle.h 2005-09-28 01:29:41.737693033 +0200
@@ -1 +1,2 @@
-/* ca bundle path set in here*/
+/* This file is generated automatically */
+#define CURL_CA_BUNDLE "/usr/local/share/curl/curl-ca-bundle.crt"
diff -ur curl-7.14.1/lib/easy.c curl-7.14.1-ratz/lib/easy.c
--- curl-7.14.1/lib/easy.c 2005-07-17 14:46:02.000000000 +0200
+++ curl-7.14.1-ratz/lib/easy.c 2005-09-28 00:34:02.847775975 +0200
@@ -305,6 +305,22 @@
  }

  /*
+ * curl_easy_getopt() is the external interface for getting options from an
+ * easy handle.
+ */
+
+CURLcode curl_easy_getopt(CURL *curl, CURLoption tag, void* arg)
+{
+ struct SessionHandle *data = curl;
+ CURLcode ret;
+
+ if(!curl)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ ret = Curl_getopt(data, tag, arg);
+ return ret;
+}
+
+/*
   * curl_easy_setopt() is the external interface for setting options on an
   * easy handle.
   */
diff -ur curl-7.14.1/lib/libcurl.imp curl-7.14.1-ratz/lib/libcurl.imp
--- curl-7.14.1/lib/libcurl.imp 2005-08-18 10:06:43.000000000 +0200
+++ curl-7.14.1-ratz/lib/libcurl.imp 2005-09-28 01:29:08.813093602 +0200
@@ -6,6 +6,7 @@
         curl_easy_getinfo,
         curl_easy_init,
         curl_easy_perform,
+ curl_easy_getopt,
         curl_easy_setopt,
         curl_escape,
         curl_unescape,
diff -ur curl-7.14.1/lib/url.c curl-7.14.1-ratz/lib/url.c
--- curl-7.14.1/lib/url.c 2005-09-28 00:45:47.798732930 +0200
+++ curl-7.14.1-ratz/lib/url.c 2005-09-28 00:58:28.417867946 +0200
@@ -380,6 +380,35 @@
    return CURLE_OK;
  }

+CURLcode Curl_getopt(struct SessionHandle *data, CURLoption option,
+ void* param)
+{
+ CURLcode result = CURLE_OK;
+ switch(option) {
+ case CURLOPT_TEST_LONG:
+ param = (void *) 42; /* long */
+ break;
+ case CURLOPT_TEST_CHAR:
+ param = (void *) "test"; /* char */
+ break;
+ case CURLOPT_MAXREDIRS:
+ /*
+ * The maximum amount of hops you allow curl to follow Location:
+ * headers. This should mostly be used to detect never-ending loops.
+ */
+ param = (void *) data->set.maxredirs; /* long */
+ break;
+ case CURLOPT_DNS_CACHE_TIMEOUT:
+ param = (void *) data->set.dns_cache_timeout; /* int */
+ break;
+ default:
+ /* unknown tag and its companion, just ignore: */
+ result = CURLE_FAILED_INIT; /* correct this */
+ break;
+ }
+
+ return result;
+}
  CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
                       va_list param)
  {
diff -ur curl-7.14.1/lib/url.h curl-7.14.1-ratz/lib/url.h
--- curl-7.14.1/lib/url.h 2005-07-17 14:46:33.000000000 +0200
+++ curl-7.14.1-ratz/lib/url.h 2005-09-28 00:46:54.018859683 +0200
@@ -30,6 +30,8 @@
   */

  CURLcode Curl_open(struct SessionHandle **curl);
+CURLcode Curl_getopt(struct SessionHandle *data, CURLoption option,
+ void *);
  CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
                       va_list arg);
  CURLcode Curl_close(struct SessionHandle *data); /* opposite of
curl_open() */

Regards,
Roberto Nibali, ratz

-- 
echo 
'[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq' | dc
Received on 2005-09-28