author | Michael Krelin <hacker@klever.net> | 2008-01-05 21:43:51 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-01-05 22:03:55 (UTC) |
commit | a0719fb611507d8b9962b87c600855d8837fc266 (patch) (unidiff) | |
tree | c4d2252f876dfdaf71f41affc5a2324762eca84e /include/opkele | |
parent | 7bde7f66284b47a75bbceadc360e7f03550ace21 (diff) | |
download | libopkele-a0719fb611507d8b9962b87c600855d8837fc266.zip libopkele-a0719fb611507d8b9962b87c600855d8837fc266.tar.gz libopkele-a0719fb611507d8b9962b87c600855d8837fc266.tar.bz2 |
added htmltidy dependency
- added libtidy detection to configure
- added tidy flags to libopkele.pc.in
- added primitive wrapper classes
- added tidy exception class
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | include/opkele/exception.h | 11 | ||||
-rw-r--r-- | include/opkele/tidy.h | 73 |
2 files changed, 84 insertions, 0 deletions
diff --git a/include/opkele/exception.h b/include/opkele/exception.h index c200a13..a8c3339 100644 --- a/include/opkele/exception.h +++ b/include/opkele/exception.h | |||
@@ -160,146 +160,157 @@ namespace opkele { | |||
160 | */ | 160 | */ |
161 | class id_res_setup : public id_res_failed { | 161 | class id_res_setup : public id_res_failed { |
162 | public: | 162 | public: |
163 | string setup_url; | 163 | string setup_url; |
164 | id_res_setup(OPKELE_E_PARS,const string& su="") | 164 | id_res_setup(OPKELE_E_PARS,const string& su="") |
165 | : id_res_failed(OPKELE_E_CONS), setup_url(su) { } | 165 | : id_res_failed(OPKELE_E_CONS), setup_url(su) { } |
166 | ~id_res_setup() throw() { } | 166 | ~id_res_setup() throw() { } |
167 | }; | 167 | }; |
168 | /** | 168 | /** |
169 | * thrown in case of signature mismatch | 169 | * thrown in case of signature mismatch |
170 | */ | 170 | */ |
171 | class id_res_mismatch : public id_res_failed { | 171 | class id_res_mismatch : public id_res_failed { |
172 | public: | 172 | public: |
173 | id_res_mismatch(OPKELE_E_PARS) | 173 | id_res_mismatch(OPKELE_E_PARS) |
174 | : id_res_failed(OPKELE_E_CONS) { } | 174 | : id_res_failed(OPKELE_E_CONS) { } |
175 | }; | 175 | }; |
176 | 176 | ||
177 | /** | 177 | /** |
178 | * thrown if the association has expired before it could've been verified. | 178 | * thrown if the association has expired before it could've been verified. |
179 | */ | 179 | */ |
180 | class id_res_expired_on_delivery : public id_res_failed { | 180 | class id_res_expired_on_delivery : public id_res_failed { |
181 | public: | 181 | public: |
182 | id_res_expired_on_delivery(OPKELE_E_PARS) | 182 | id_res_expired_on_delivery(OPKELE_E_PARS) |
183 | : id_res_failed(OPKELE_E_CONS) { } | 183 | : id_res_failed(OPKELE_E_CONS) { } |
184 | }; | 184 | }; |
185 | 185 | ||
186 | /** | 186 | /** |
187 | * thown when the user cancelled authentication process. | 187 | * thown when the user cancelled authentication process. |
188 | */ | 188 | */ |
189 | class id_res_cancel : public id_res_failed { | 189 | class id_res_cancel : public id_res_failed { |
190 | public: | 190 | public: |
191 | id_res_cancel(OPKELE_E_PARS) | 191 | id_res_cancel(OPKELE_E_PARS) |
192 | : id_res_failed(OPKELE_E_CONS) { } | 192 | : id_res_failed(OPKELE_E_CONS) { } |
193 | }; | 193 | }; |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * thrown in case of nonce reuse or otherwise imperfect nonce. | 196 | * thrown in case of nonce reuse or otherwise imperfect nonce. |
197 | */ | 197 | */ |
198 | class id_res_bad_nonce : public id_res_failed { | 198 | class id_res_bad_nonce : public id_res_failed { |
199 | public: | 199 | public: |
200 | id_res_bad_nonce(OPKELE_E_PARS) | 200 | id_res_bad_nonce(OPKELE_E_PARS) |
201 | : id_res_failed(OPKELE_E_CONS) { } | 201 | : id_res_failed(OPKELE_E_CONS) { } |
202 | }; | 202 | }; |
203 | 203 | ||
204 | /** | 204 | /** |
205 | * thrown if return_to didn't pass verification | 205 | * thrown if return_to didn't pass verification |
206 | */ | 206 | */ |
207 | class id_res_bad_return_to : public id_res_failed { | 207 | class id_res_bad_return_to : public id_res_failed { |
208 | public: | 208 | public: |
209 | id_res_bad_return_to(OPKELE_E_PARS) | 209 | id_res_bad_return_to(OPKELE_E_PARS) |
210 | : id_res_failed(OPKELE_E_CONS) { } | 210 | : id_res_failed(OPKELE_E_CONS) { } |
211 | }; | 211 | }; |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * thrown if OP isn't authorized to make an assertion | 214 | * thrown if OP isn't authorized to make an assertion |
215 | */ | 215 | */ |
216 | class id_res_unauthorized : public id_res_failed { | 216 | class id_res_unauthorized : public id_res_failed { |
217 | public: | 217 | public: |
218 | id_res_unauthorized(OPKELE_E_PARS) | 218 | id_res_unauthorized(OPKELE_E_PARS) |
219 | : id_res_failed(OPKELE_E_CONS) { } | 219 | : id_res_failed(OPKELE_E_CONS) { } |
220 | }; | 220 | }; |
221 | 221 | ||
222 | /** | 222 | /** |
223 | * openssl malfunction occured | 223 | * openssl malfunction occured |
224 | */ | 224 | */ |
225 | class exception_openssl : public exception { | 225 | class exception_openssl : public exception { |
226 | public: | 226 | public: |
227 | unsigned long _error; | 227 | unsigned long _error; |
228 | string _ssl_string; | 228 | string _ssl_string; |
229 | exception_openssl(OPKELE_E_PARS); | 229 | exception_openssl(OPKELE_E_PARS); |
230 | ~exception_openssl() throw() { } | 230 | ~exception_openssl() throw() { } |
231 | }; | 231 | }; |
232 | 232 | ||
233 | /** | 233 | /** |
234 | * network operation related error occured | 234 | * network operation related error occured |
235 | */ | 235 | */ |
236 | class exception_network : public exception { | 236 | class exception_network : public exception { |
237 | public: | 237 | public: |
238 | exception_network(OPKELE_E_PARS) | 238 | exception_network(OPKELE_E_PARS) |
239 | : exception(OPKELE_E_CONS) { } | 239 | : exception(OPKELE_E_CONS) { } |
240 | }; | 240 | }; |
241 | 241 | ||
242 | /** | 242 | /** |
243 | * network operation related error occured, specifically, related to | 243 | * network operation related error occured, specifically, related to |
244 | * libcurl | 244 | * libcurl |
245 | */ | 245 | */ |
246 | class exception_curl : public exception_network { | 246 | class exception_curl : public exception_network { |
247 | public: | 247 | public: |
248 | CURLcode _error; | 248 | CURLcode _error; |
249 | string _curl_string; | 249 | string _curl_string; |
250 | exception_curl(OPKELE_E_PARS); | 250 | exception_curl(OPKELE_E_PARS); |
251 | exception_curl(OPKELE_E_PARS,CURLcode e); | 251 | exception_curl(OPKELE_E_PARS,CURLcode e); |
252 | ~exception_curl() throw() { } | 252 | ~exception_curl() throw() { } |
253 | }; | 253 | }; |
254 | 254 | ||
255 | /** | 255 | /** |
256 | * htmltidy related error occured | ||
257 | */ | ||
258 | class exception_tidy : public exception { | ||
259 | public: | ||
260 | int _rc; | ||
261 | exception_tidy(OPKELE_E_PARS); | ||
262 | exception_tidy(OPKELE_E_PARS,int r); | ||
263 | ~exception_tidy() throw() { } | ||
264 | }; | ||
265 | |||
266 | /** | ||
256 | * exception thrown in case of failed discovery | 267 | * exception thrown in case of failed discovery |
257 | */ | 268 | */ |
258 | class failed_discovery : public exception { | 269 | class failed_discovery : public exception { |
259 | public: | 270 | public: |
260 | failed_discovery(OPKELE_E_PARS) | 271 | failed_discovery(OPKELE_E_PARS) |
261 | : exception(OPKELE_E_CONS) { } | 272 | : exception(OPKELE_E_CONS) { } |
262 | }; | 273 | }; |
263 | 274 | ||
264 | /** | 275 | /** |
265 | * unsuccessfull xri resolution | 276 | * unsuccessfull xri resolution |
266 | */ | 277 | */ |
267 | class failed_xri_resolution : public failed_discovery { | 278 | class failed_xri_resolution : public failed_discovery { |
268 | public: | 279 | public: |
269 | long _code; | 280 | long _code; |
270 | failed_xri_resolution(OPKELE_E_PARS,long _c=-1) | 281 | failed_xri_resolution(OPKELE_E_PARS,long _c=-1) |
271 | : failed_discovery(OPKELE_E_CONS), _code(_c) { } | 282 | : failed_discovery(OPKELE_E_CONS), _code(_c) { } |
272 | }; | 283 | }; |
273 | 284 | ||
274 | /** | 285 | /** |
275 | * not implemented (think pure virtual) member function executed, signfies | 286 | * not implemented (think pure virtual) member function executed, signfies |
276 | * programmer error | 287 | * programmer error |
277 | */ | 288 | */ |
278 | class not_implemented : public exception { | 289 | class not_implemented : public exception { |
279 | public: | 290 | public: |
280 | not_implemented(OPKELE_E_PARS) | 291 | not_implemented(OPKELE_E_PARS) |
281 | : exception(OPKELE_E_CONS) { } | 292 | : exception(OPKELE_E_CONS) { } |
282 | }; | 293 | }; |
283 | 294 | ||
284 | /** | 295 | /** |
285 | * internal error, indicates internal libopkele problem | 296 | * internal error, indicates internal libopkele problem |
286 | */ | 297 | */ |
287 | class internal_error : public exception { | 298 | class internal_error : public exception { |
288 | public: | 299 | public: |
289 | internal_error(OPKELE_E_PARS) | 300 | internal_error(OPKELE_E_PARS) |
290 | : exception(OPKELE_E_CONS) { } | 301 | : exception(OPKELE_E_CONS) { } |
291 | }; | 302 | }; |
292 | 303 | ||
293 | /** | 304 | /** |
294 | * thrown in case of unsupported parameter encountered (e.g. unsupported | 305 | * thrown in case of unsupported parameter encountered (e.g. unsupported |
295 | * association type). | 306 | * association type). |
296 | */ | 307 | */ |
297 | class unsupported : public exception { | 308 | class unsupported : public exception { |
298 | public: | 309 | public: |
299 | unsupported(OPKELE_E_PARS) | 310 | unsupported(OPKELE_E_PARS) |
300 | : exception(OPKELE_E_CONS) { } | 311 | : exception(OPKELE_E_CONS) { } |
301 | }; | 312 | }; |
302 | 313 | ||
303 | } | 314 | } |
304 | 315 | ||
305 | #endif /* __OPKELE_EXCEPTION_H */ | 316 | #endif /* __OPKELE_EXCEPTION_H */ |
diff --git a/include/opkele/tidy.h b/include/opkele/tidy.h new file mode 100644 index 0000000..888e7d4 --- a/dev/null +++ b/include/opkele/tidy.h | |||
@@ -0,0 +1,73 @@ | |||
1 | #ifndef __OPKELE_TIDY_H | ||
2 | #define __OPKELE_TIDY_H | ||
3 | |||
4 | #include <cassert> | ||
5 | #include <tidy.h> | ||
6 | #include <buffio.h> | ||
7 | |||
8 | namespace opkele { | ||
9 | namespace util { | ||
10 | |||
11 | class tidy_buf_t { | ||
12 | public: | ||
13 | TidyBuffer _x; | ||
14 | |||
15 | tidy_buf_t() { tidyBufInit(&_x); } | ||
16 | virtual ~tidy_buf_t() throw() { | ||
17 | tidyBufFree(&_x); } | ||
18 | |||
19 | inline operator const TidyBuffer&(void) const { return _x; } | ||
20 | inline operator TidyBuffer&(void) { return _x; } | ||
21 | |||
22 | inline operator const char*(void) const { return (const char*)_x.bp; } | ||
23 | inline operator char*(void) { return (char*)_x.bp; } | ||
24 | |||
25 | inline const char *c_str() const { | ||
26 | return (const char*)_x.bp; } | ||
27 | inline size_t size() const { | ||
28 | return _x.size; } | ||
29 | }; | ||
30 | |||
31 | class tidy_doc_t { | ||
32 | public: | ||
33 | TidyDoc _x; | ||
34 | |||
35 | tidy_doc_t() : _x(0) { } | ||
36 | tidy_doc_t(TidyDoc x) : _x(x) { } | ||
37 | virtual ~tidy_doc_t() throw() { | ||
38 | if(_x) tidyRelease(_x); } | ||
39 | |||
40 | tidy_doc_t& operator=(TidyDoc x) { | ||
41 | if(_x) tidyRelease(_x); | ||
42 | _x = x; | ||
43 | return *this; | ||
44 | } | ||
45 | |||
46 | operator const TidyDoc(void) const { return _x; } | ||
47 | operator TidyDoc(void) { return _x; } | ||
48 | |||
49 | inline bool opt_set(TidyOptionId o,bool v) { | ||
50 | assert(_x); | ||
51 | return tidyOptSetBool(_x,o,v?yes:no); } | ||
52 | inline bool opt_set(TidyOptionId o,int v) { | ||
53 | assert(_x); | ||
54 | return tidyOptSetInt(_x,o,v); } | ||
55 | |||
56 | inline int parse_string(const string& s) { | ||
57 | assert(_x); | ||
58 | return tidyParseString(_x,s.c_str()); } | ||
59 | inline int clean_and_repair() { | ||
60 | assert(_x); | ||
61 | return tidyCleanAndRepair(_x); } | ||
62 | inline int save_buffer(TidyBuffer& ob) { | ||
63 | assert(_x); | ||
64 | return tidySaveBuffer(_x,&ob); } | ||
65 | |||
66 | static inline TidyDoc create() { | ||
67 | return tidyCreate(); } | ||
68 | }; | ||
69 | |||
70 | } | ||
71 | } | ||
72 | |||
73 | #endif /* __OPKELE_TIDY_H */ | ||