-rw-r--r-- | include/opkele/curl.h | 20 | ||||
-rw-r--r-- | lib/curl.cc | 20 |
2 files changed, 40 insertions, 0 deletions
diff --git a/include/opkele/curl.h b/include/opkele/curl.h index 5cf8e48..bcaf11d 100644 --- a/include/opkele/curl.h +++ b/include/opkele/curl.h | |||
@@ -14,2 +14,20 @@ namespace opkele { | |||
14 | 14 | ||
15 | class curl_slist_t { | ||
16 | public: | ||
17 | curl_slist *_s; | ||
18 | |||
19 | curl_slist_t() : _s(0) { } | ||
20 | curl_slist_t(curl_slist *s) : _s(s) { } | ||
21 | virtual ~curl_slist_t() throw(); | ||
22 | |||
23 | curl_slist_t& operator=(curl_slist *s); | ||
24 | |||
25 | operator const curl_slist*(void) const { return _s; } | ||
26 | operator curl_slist*(void) { return _s; } | ||
27 | |||
28 | void append(const char *str); | ||
29 | void append(const string& str) { | ||
30 | append(str.c_str()); } | ||
31 | }; | ||
32 | |||
15 | class curl_t { | 33 | class curl_t { |
@@ -31,2 +49,4 @@ namespace opkele { | |||
31 | inline CURLcode easy_setopt(CURLoption o,PT p) { assert(_c); return curl_easy_setopt(_c,o,p); } | 49 | inline CURLcode easy_setopt(CURLoption o,PT p) { assert(_c); return curl_easy_setopt(_c,o,p); } |
50 | inline CURLcode easy_setopt(CURLoption o,const curl_slist_t& p) { | ||
51 | assert(_c); return curl_easy_setopt(_c,o,(const curl_slist*)p); } | ||
32 | CURLcode easy_perform() { assert(_c); return curl_easy_perform(_c); } | 52 | CURLcode easy_perform() { assert(_c); return curl_easy_perform(_c); } |
diff --git a/lib/curl.cc b/lib/curl.cc index 6172828..734e2ca 100644 --- a/lib/curl.cc +++ b/lib/curl.cc | |||
@@ -1 +1,2 @@ | |||
1 | #include <opkele/exception.h> | ||
1 | #include <opkele/curl.h> | 2 | #include <opkele/curl.h> |
@@ -8,2 +9,21 @@ namespace opkele { | |||
8 | 9 | ||
10 | curl_slist_t::~curl_slist_t() throw() { | ||
11 | if(_s) | ||
12 | curl_slist_free_all(_s); | ||
13 | } | ||
14 | |||
15 | curl_slist_t& curl_slist_t::operator=(curl_slist *s) { | ||
16 | if(_s) | ||
17 | curl_slist_free_all(_s); | ||
18 | _s = s; | ||
19 | return *this; | ||
20 | } | ||
21 | |||
22 | void curl_slist_t::append(const char *str) { | ||
23 | curl_slist *s = curl_slist_append(_s,str); | ||
24 | if(!s) | ||
25 | throw opkele::exception(OPKELE_CP_ "failed to curl_slist_append()"); | ||
26 | _s=s; | ||
27 | } | ||
28 | |||
9 | curl_t::~curl_t() throw() { | 29 | curl_t::~curl_t() throw() { |