author | Michael Krelin <hacker@klever.net> | 2007-11-24 12:02:50 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-11-24 12:02:50 (UTC) |
commit | 986274e9f9a8e2ef0f92b08d2d2c9485bd19adec (patch) (unidiff) | |
tree | 72b3d134d9d635b2aadbdebf615e1717dd9d683b | |
parent | ef66d79bf58f099179a932ca80d07ca93a42909c (diff) | |
download | libopkele-986274e9f9a8e2ef0f92b08d2d2c9485bd19adec.zip libopkele-986274e9f9a8e2ef0f92b08d2d2c9485bd19adec.tar.gz libopkele-986274e9f9a8e2ef0f92b08d2d2c9485bd19adec.tar.bz2 |
moved curl_t wrapper to util namespace
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | include/Makefile.am | 3 | ||||
-rw-r--r-- | include/opkele/curl.h | 28 | ||||
-rw-r--r-- | lib/consumer.cc | 25 |
3 files changed, 35 insertions, 21 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index f3551f5..b31786d 100644 --- a/include/Makefile.am +++ b/include/Makefile.am | |||
@@ -15,2 +15,3 @@ EXTRA_DIST = \ | |||
15 | opkele/data.h \ | 15 | opkele/data.h \ |
16 | opkele/util.h | 16 | opkele/util.h \ |
17 | opkele/curl.h | ||
diff --git a/include/opkele/curl.h b/include/opkele/curl.h new file mode 100644 index 0000000..8794ece --- a/dev/null +++ b/include/opkele/curl.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef __OPKELE_CURL_H | ||
2 | #define __OPKELE_CURL_H | ||
3 | |||
4 | #include <curl/curl.h> | ||
5 | |||
6 | namespace opkele { | ||
7 | |||
8 | namespace util { | ||
9 | |||
10 | class curl_t { | ||
11 | public: | ||
12 | CURL *_c; | ||
13 | |||
14 | curl_t() : _c(0) { } | ||
15 | curl_t(CURL *c) : _c(c) { } | ||
16 | ~curl_t() throw() { if(_c) curl_easy_cleanup(_c); } | ||
17 | |||
18 | curl_t& operator=(CURL *c) { if(_c) curl_easy_cleanup(_c); _c=c; return *this; } | ||
19 | |||
20 | operator const CURL*(void) const { return _c; } | ||
21 | operator CURL*(void) { return _c; } | ||
22 | }; | ||
23 | |||
24 | } | ||
25 | |||
26 | } | ||
27 | |||
28 | #endif /* __OPKELE_CURL_H */ | ||
diff --git a/lib/consumer.cc b/lib/consumer.cc index 7881f5f..20f4174 100644 --- a/lib/consumer.cc +++ b/lib/consumer.cc | |||
@@ -4,2 +4,3 @@ | |||
4 | #include <opkele/util.h> | 4 | #include <opkele/util.h> |
5 | #include <opkele/curl.h> | ||
5 | #include <opkele/exception.h> | 6 | #include <opkele/exception.h> |
@@ -9,4 +10,2 @@ | |||
9 | #include <openssl/hmac.h> | 10 | #include <openssl/hmac.h> |
10 | #include <curl/curl.h> | ||
11 | |||
12 | #include <iostream> | 11 | #include <iostream> |
@@ -64,16 +63,2 @@ namespace opkele { | |||
64 | 63 | ||
65 | class curl_t { | ||
66 | public: | ||
67 | CURL *_c; | ||
68 | |||
69 | curl_t() : _c(0) { } | ||
70 | curl_t(CURL *c) : _c(c) { } | ||
71 | ~curl_t() throw() { if(_c) curl_easy_cleanup(_c); } | ||
72 | |||
73 | curl_t& operator=(CURL *c) { if(_c) curl_easy_cleanup(_c); _c=c; return *this; } | ||
74 | |||
75 | operator const CURL*(void) const { return _c; } | ||
76 | operator CURL*(void) { return _c; } | ||
77 | }; | ||
78 | |||
79 | static CURLcode curl_misc_sets(CURL* c) { | 64 | static CURLcode curl_misc_sets(CURL* c) { |
@@ -118,3 +103,3 @@ namespace opkele { | |||
118 | request += util::url_encode(util::bignum_to_base64(dh->pub_key)); | 103 | request += util::url_encode(util::bignum_to_base64(dh->pub_key)); |
119 | curl_t curl = curl_easy_init(); | 104 | util::curl_t curl = curl_easy_init(); |
120 | if(!curl) | 105 | if(!curl) |
@@ -278,3 +263,3 @@ namespace opkele { | |||
278 | } | 263 | } |
279 | curl_t curl = curl_easy_init(); | 264 | util::curl_t curl = curl_easy_init(); |
280 | if(!curl) | 265 | if(!curl) |
@@ -311,3 +296,3 @@ namespace opkele { | |||
311 | delegate.erase(); | 296 | delegate.erase(); |
312 | curl_t curl = curl_easy_init(); | 297 | util::curl_t curl = curl_easy_init(); |
313 | if(!curl) | 298 | if(!curl) |
@@ -417,3 +402,3 @@ namespace opkele { | |||
417 | string rv = normalize(url); | 402 | string rv = normalize(url); |
418 | curl_t curl = curl_easy_init(); | 403 | util::curl_t curl = curl_easy_init(); |
419 | if(!curl) | 404 | if(!curl) |