summaryrefslogtreecommitdiffabout
path: root/lib/consumer.cc
authorMichael Krelin <hacker@klever.net>2007-11-21 14:01:36 (UTC)
committer Michael Krelin <hacker@klever.net>2007-11-21 14:01:36 (UTC)
commit8e397698d6a224e36f2b4a188380ec04400aac66 (patch) (unidiff)
treeda7aa7d75f6dd74b8d7260b7ab9c39241726ca88 /lib/consumer.cc
parent10916ef2b15b91badb17af5404acd9981b8a2087 (diff)
downloadlibopkele-8e397698d6a224e36f2b4a188380ec04400aac66.zip
libopkele-8e397698d6a224e36f2b4a188380ec04400aac66.tar.gz
libopkele-8e397698d6a224e36f2b4a188380ec04400aac66.tar.bz2
added some missing includes for gcc 4.3
According to Marcus Rueckert gcc 4.3 wants these. Thanks, Marcus! Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'lib/consumer.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/consumer.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/consumer.cc b/lib/consumer.cc
index f9212ea..d578546 100644
--- a/lib/consumer.cc
+++ b/lib/consumer.cc
@@ -1,98 +1,99 @@
1#include <algorithm> 1#include <algorithm>
2#include <cassert> 2#include <cassert>
3#include <cstring>
3#include <opkele/util.h> 4#include <opkele/util.h>
4#include <opkele/exception.h> 5#include <opkele/exception.h>
5#include <opkele/data.h> 6#include <opkele/data.h>
6#include <opkele/consumer.h> 7#include <opkele/consumer.h>
7#include <openssl/sha.h> 8#include <openssl/sha.h>
8#include <openssl/hmac.h> 9#include <openssl/hmac.h>
9#include <curl/curl.h> 10#include <curl/curl.h>
10 11
11#include <iostream> 12#include <iostream>
12 13
13#include "config.h" 14#include "config.h"
14 15
15#include <pcre.h> 16#include <pcre.h>
16 17
17namespace opkele { 18namespace opkele {
18 using namespace std; 19 using namespace std;
19 20
20 class pcre_matches_t { 21 class pcre_matches_t {
21 public: 22 public:
22 int *_ov; 23 int *_ov;
23 int _s; 24 int _s;
24 25
25 pcre_matches_t() : _ov(0), _s(0) { } 26 pcre_matches_t() : _ov(0), _s(0) { }
26 pcre_matches_t(int s) : _ov(0), _s(s) { 27 pcre_matches_t(int s) : _ov(0), _s(s) {
27 if(_s&1) ++_s; 28 if(_s&1) ++_s;
28 _s += _s>>1; 29 _s += _s>>1;
29 _ov = new int[_s]; 30 _ov = new int[_s];
30 } 31 }
31 ~pcre_matches_t() throw() { if(_ov) delete[] _ov; } 32 ~pcre_matches_t() throw() { if(_ov) delete[] _ov; }
32 33
33 int begin(int i) const { return _ov[i<<1]; } 34 int begin(int i) const { return _ov[i<<1]; }
34 int end(int i) const { return _ov[(i<<1)+1]; } 35 int end(int i) const { return _ov[(i<<1)+1]; }
35 int length(int i) const { int t=i<<1; return _ov[t+1]-_ov[t]; } 36 int length(int i) const { int t=i<<1; return _ov[t+1]-_ov[t]; }
36 }; 37 };
37 38
38 class pcre_t { 39 class pcre_t {
39 public: 40 public:
40 pcre *_p; 41 pcre *_p;
41 42
42 pcre_t() : _p(0) { } 43 pcre_t() : _p(0) { }
43 pcre_t(pcre *p) : _p(p) { } 44 pcre_t(pcre *p) : _p(p) { }
44 pcre_t(const char *re,int opts) : _p(0) { 45 pcre_t(const char *re,int opts) : _p(0) {
45 static const char *errptr; static int erroffset; 46 static const char *errptr; static int erroffset;
46 _p = pcre_compile(re,opts,&errptr,&erroffset,NULL); 47 _p = pcre_compile(re,opts,&errptr,&erroffset,NULL);
47 if(!_p) 48 if(!_p)
48 throw internal_error(OPKELE_CP_ string("Failed to compile regexp: ")+errptr); 49 throw internal_error(OPKELE_CP_ string("Failed to compile regexp: ")+errptr);
49 } 50 }
50 ~pcre_t() throw() { if(_p) (*pcre_free)(_p); } 51 ~pcre_t() throw() { if(_p) (*pcre_free)(_p); }
51 52
52 pcre_t& operator=(pcre *p) { if(_p) (*pcre_free)(_p); _p=p; return *this; } 53 pcre_t& operator=(pcre *p) { if(_p) (*pcre_free)(_p); _p=p; return *this; }
53 54
54 operator const pcre*(void) const { return _p; } 55 operator const pcre*(void) const { return _p; }
55 operator pcre*(void) { return _p; } 56 operator pcre*(void) { return _p; }
56 57
57 int exec(const string& s,pcre_matches_t& m) { 58 int exec(const string& s,pcre_matches_t& m) {
58 if(!_p) 59 if(!_p)
59 throw internal_error(OPKELE_CP_ "Trying to execute absent regexp"); 60 throw internal_error(OPKELE_CP_ "Trying to execute absent regexp");
60 return pcre_exec(_p,NULL,s.c_str(),s.length(),0,0,m._ov,m._s); 61 return pcre_exec(_p,NULL,s.c_str(),s.length(),0,0,m._ov,m._s);
61 } 62 }
62 }; 63 };
63 64
64 class curl_t { 65 class curl_t {
65 public: 66 public:
66 CURL *_c; 67 CURL *_c;
67 68
68 curl_t() : _c(0) { } 69 curl_t() : _c(0) { }
69 curl_t(CURL *c) : _c(c) { } 70 curl_t(CURL *c) : _c(c) { }
70 ~curl_t() throw() { if(_c) curl_easy_cleanup(_c); } 71 ~curl_t() throw() { if(_c) curl_easy_cleanup(_c); }
71 72
72 curl_t& operator=(CURL *c) { if(_c) curl_easy_cleanup(_c); _c=c; return *this; } 73 curl_t& operator=(CURL *c) { if(_c) curl_easy_cleanup(_c); _c=c; return *this; }
73 74
74 operator const CURL*(void) const { return _c; } 75 operator const CURL*(void) const { return _c; }
75 operator CURL*(void) { return _c; } 76 operator CURL*(void) { return _c; }
76 }; 77 };
77 78
78 static CURLcode curl_misc_sets(CURL* c) { 79 static CURLcode curl_misc_sets(CURL* c) {
79 CURLcode r; 80 CURLcode r;
80 (r=curl_easy_setopt(c,CURLOPT_FOLLOWLOCATION,1)) 81 (r=curl_easy_setopt(c,CURLOPT_FOLLOWLOCATION,1))
81 || (r=curl_easy_setopt(c,CURLOPT_MAXREDIRS,5)) 82 || (r=curl_easy_setopt(c,CURLOPT_MAXREDIRS,5))
82 || (r=curl_easy_setopt(c,CURLOPT_DNS_CACHE_TIMEOUT,120)) 83 || (r=curl_easy_setopt(c,CURLOPT_DNS_CACHE_TIMEOUT,120))
83 || (r=curl_easy_setopt(c,CURLOPT_DNS_USE_GLOBAL_CACHE,1)) 84 || (r=curl_easy_setopt(c,CURLOPT_DNS_USE_GLOBAL_CACHE,1))
84 || (r=curl_easy_setopt(c,CURLOPT_USERAGENT,PACKAGE_NAME"/"PACKAGE_SRC_VERSION)) 85 || (r=curl_easy_setopt(c,CURLOPT_USERAGENT,PACKAGE_NAME"/"PACKAGE_SRC_VERSION))
85 || (r=curl_easy_setopt(c,CURLOPT_TIMEOUT,20)) 86 || (r=curl_easy_setopt(c,CURLOPT_TIMEOUT,20))
86 #ifdefDISABLE_CURL_SSL_VERIFYHOST 87 #ifdefDISABLE_CURL_SSL_VERIFYHOST
87 || (r=curl_easy_setopt(c,CURLOPT_SSL_VERIFYHOST,0)) 88 || (r=curl_easy_setopt(c,CURLOPT_SSL_VERIFYHOST,0))
88#endif 89#endif
89 #ifdefDISABLE_CURL_SSL_VERIFYPEER 90 #ifdefDISABLE_CURL_SSL_VERIFYPEER
90 || (r=curl_easy_setopt(c,CURLOPT_SSL_VERIFYPEER,0)) 91 || (r=curl_easy_setopt(c,CURLOPT_SSL_VERIFYPEER,0))
91#endif 92#endif
92 ; 93 ;
93 return r; 94 return r;
94 } 95 }
95 96
96 static size_t _curl_tostring(void *ptr,size_t size,size_t nmemb,void *stream) { 97 static size_t _curl_tostring(void *ptr,size_t size,size_t nmemb,void *stream) {
97 string *str = (string*)stream; 98 string *str = (string*)stream;
98 size_t bytes = size*nmemb; 99 size_t bytes = size*nmemb;