-rw-r--r-- | configure.ac | 13 | ||||
-rw-r--r-- | include/Makefile.am | 2 | ||||
-rw-r--r-- | include/opkele/exception.h | 11 | ||||
-rw-r--r-- | include/opkele/tidy.h | 73 | ||||
-rw-r--r-- | lib/exception.cc | 6 | ||||
-rw-r--r-- | libopkele.pc.in | 4 |
6 files changed, 106 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index 51bacd5..5772ead 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -101,32 +101,45 @@ LIBCURL_CHECK_CONFIG(,,,[ | |||
101 | AC_MSG_ERROR([no required libcurl library. get one from http://curl.haxx.se/]) | 101 | AC_MSG_ERROR([no required libcurl library. get one from http://curl.haxx.se/]) |
102 | ]) | 102 | ]) |
103 | 103 | ||
104 | AC_CHECK_HEADER([expat.h],[ | 104 | AC_CHECK_HEADER([expat.h],[ |
105 | AC_CHECK_LIB([expat],[XML_ParserCreate],[ | 105 | AC_CHECK_LIB([expat],[XML_ParserCreate],[ |
106 | EXPAT_LIBS=-lexpat | 106 | EXPAT_LIBS=-lexpat |
107 | EXPAT_CFLAGS= | 107 | EXPAT_CFLAGS= |
108 | AC_SUBST([EXPAT_LIBS]) | 108 | AC_SUBST([EXPAT_LIBS]) |
109 | AC_SUBST([EXPAT_CFLAGS]) | 109 | AC_SUBST([EXPAT_CFLAGS]) |
110 | ],[ | 110 | ],[ |
111 | AC_MSG_ERROR([no required expat library. get one from http://expat.sourceforge.net/]) | 111 | AC_MSG_ERROR([no required expat library. get one from http://expat.sourceforge.net/]) |
112 | ]) | 112 | ]) |
113 | ],[ | 113 | ],[ |
114 | AC_MSG_ERROR([no required expat library. get one from http://expat.sourceforge.net/]) | 114 | AC_MSG_ERROR([no required expat library. get one from http://expat.sourceforge.net/]) |
115 | ]) | 115 | ]) |
116 | 116 | ||
117 | AC_CHECK_HEADER([tidy.h],[ | ||
118 | AC_CHECK_LIB([tidy],[tidyParseBuffer],[ | ||
119 | TIDY_LIBS=-ltidy | ||
120 | TIDY_CFLAGS= | ||
121 | AC_SUBST([TIDY_LIBS]) | ||
122 | AC_SUBST([TIDY_CFLAGS]) | ||
123 | ],[ | ||
124 | AC_MSG_ERROR([no required htmltidy library found. get one from http://tidy.sourceforge.nt/]) | ||
125 | ]) | ||
126 | ],[ | ||
127 | AC_MSG_ERROR([no required htmltidy library found. get one from http://tidy.sourceforge.nt/]) | ||
128 | ]) | ||
129 | |||
117 | if test -n "$PCRE_LIBS" -a -n "$PCRE_CFLAGS" ; then | 130 | if test -n "$PCRE_LIBS" -a -n "$PCRE_CFLAGS" ; then |
118 | AC_SUBST([PCRE_CFLAGS]) | 131 | AC_SUBST([PCRE_CFLAGS]) |
119 | AC_SUBST([PCRE_LIBS]) | 132 | AC_SUBST([PCRE_LIBS]) |
120 | : | 133 | : |
121 | else | 134 | else |
122 | PKG_CHECK_MODULES([PCRE],[libpcre],,[ | 135 | PKG_CHECK_MODULES([PCRE],[libpcre],,[ |
123 | AC_MSG_ERROR([no libpcre found, go get it at http://www.pcre.org/]) | 136 | AC_MSG_ERROR([no libpcre found, go get it at http://www.pcre.org/]) |
124 | ]) | 137 | ]) |
125 | fi | 138 | fi |
126 | 139 | ||
127 | curl_ssl_verify_host="true" | 140 | curl_ssl_verify_host="true" |
128 | AC_ARG_ENABLE([ssl-verify-host], | 141 | AC_ARG_ENABLE([ssl-verify-host], |
129 | AC_HELP_STRING([--disable-ssl-verify-host],[disable cURL cert/host relationships verification]), | 142 | AC_HELP_STRING([--disable-ssl-verify-host],[disable cURL cert/host relationships verification]), |
130 | [ test "${enableval}" = "no" && curl_ssl_verify_host="false" ] | 143 | [ test "${enableval}" = "no" && curl_ssl_verify_host="false" ] |
131 | ) | 144 | ) |
132 | ${curl_ssl_verify_host} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYHOST],,[defined if cURL is not to verify cert/host]) | 145 | ${curl_ssl_verify_host} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYHOST],,[defined if cURL is not to verify cert/host]) |
diff --git a/include/Makefile.am b/include/Makefile.am index 1076c12..51dcea1 100644 --- a/include/Makefile.am +++ b/include/Makefile.am | |||
@@ -3,19 +3,19 @@ nobase_include_HEADERS = \ | |||
3 | opkele/opkele-config.h \ | 3 | opkele/opkele-config.h \ |
4 | opkele/types.h \ | 4 | opkele/types.h \ |
5 | opkele/association.h \ | 5 | opkele/association.h \ |
6 | opkele/exception.h \ | 6 | opkele/exception.h \ |
7 | opkele/server.h \ | 7 | opkele/server.h \ |
8 | opkele/consumer.h \ | 8 | opkele/consumer.h \ |
9 | opkele/extension.h \ | 9 | opkele/extension.h \ |
10 | opkele/sreg.h \ | 10 | opkele/sreg.h \ |
11 | opkele/extension_chain.h \ | 11 | opkele/extension_chain.h \ |
12 | opkele/xconsumer.h \ | 12 | opkele/xconsumer.h \ |
13 | opkele/xserver.h \ | 13 | opkele/xserver.h \ |
14 | opkele/discovery.h \ | 14 | opkele/discovery.h \ |
15 | opkele/uris.h \ | 15 | opkele/uris.h \ |
16 | opkele/tr1-mem.h | 16 | opkele/tr1-mem.h |
17 | EXTRA_DIST = \ | 17 | EXTRA_DIST = \ |
18 | opkele/data.h \ | 18 | opkele/data.h \ |
19 | opkele/curl.h opkele/expat.h \ | 19 | opkele/curl.h opkele/expat.h opkele/tidy.h \ |
20 | opkele/util.h \ | 20 | opkele/util.h \ |
21 | opkele/debug.h | 21 | opkele/debug.h |
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 | |||
@@ -240,32 +240,43 @@ namespace opkele { | |||
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) { } |
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 */ | ||
diff --git a/lib/exception.cc b/lib/exception.cc index 0b775f7..e32594b 100644 --- a/lib/exception.cc +++ b/lib/exception.cc | |||
@@ -29,17 +29,23 @@ namespace opkele { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | # endif | 31 | # endif |
32 | 32 | ||
33 | exception_openssl::exception_openssl(OPKELE_E_PARS) | 33 | exception_openssl::exception_openssl(OPKELE_E_PARS) |
34 | : exception(OPKELE_E_CONS_ w+" ["+ERR_error_string(ERR_peek_last_error(),0)+']'), | 34 | : exception(OPKELE_E_CONS_ w+" ["+ERR_error_string(ERR_peek_last_error(),0)+']'), |
35 | _error(ERR_peek_last_error()), | 35 | _error(ERR_peek_last_error()), |
36 | _ssl_string(ERR_error_string(_error,0)) { | 36 | _ssl_string(ERR_error_string(_error,0)) { |
37 | } | 37 | } |
38 | 38 | ||
39 | exception_curl::exception_curl(OPKELE_E_PARS) | 39 | exception_curl::exception_curl(OPKELE_E_PARS) |
40 | : exception_network(OPKELE_E_CONS), _error(CURLE_OK) { } | 40 | : exception_network(OPKELE_E_CONS), _error(CURLE_OK) { } |
41 | exception_curl::exception_curl(OPKELE_E_PARS,CURLcode e) | 41 | exception_curl::exception_curl(OPKELE_E_PARS,CURLcode e) |
42 | : exception_network(OPKELE_E_CONS_ w+" ["+curl_easy_strerror(e)+']'), | 42 | : exception_network(OPKELE_E_CONS_ w+" ["+curl_easy_strerror(e)+']'), |
43 | _error(e), _curl_string(curl_easy_strerror(e)) { } | 43 | _error(e), _curl_string(curl_easy_strerror(e)) { } |
44 | 44 | ||
45 | exception_tidy::exception_tidy(OPKELE_E_PARS) | ||
46 | : exception(OPKELE_E_CONS), _rc(0) { } | ||
47 | exception_tidy::exception_tidy(OPKELE_E_PARS,int r) | ||
48 | : exception(OPKELE_E_CONS), | ||
49 | _rc(r) { } | ||
50 | |||
45 | } | 51 | } |
diff --git a/libopkele.pc.in b/libopkele.pc.in index 0a95e96..011f2fe 100644 --- a/libopkele.pc.in +++ b/libopkele.pc.in | |||
@@ -1,11 +1,11 @@ | |||
1 | prefix=@prefix@ | 1 | prefix=@prefix@ |
2 | exec_prefix=@exec_prefix@ | 2 | exec_prefix=@exec_prefix@ |
3 | libdir=@libdir@ | 3 | libdir=@libdir@ |
4 | includedir=@includedir@ | 4 | includedir=@includedir@ |
5 | 5 | ||
6 | Name: libopkele | 6 | Name: libopkele |
7 | Description: C++ implementation of OpenID protocol | 7 | Description: C++ implementation of OpenID protocol |
8 | Version: @VERSION@ | 8 | Version: @VERSION@ |
9 | Requires: openssl libpcre @KONFORKA_KONFORKA@ | 9 | Requires: openssl libpcre @KONFORKA_KONFORKA@ |
10 | Cflags: -I${includedir} @LIBCURL_CPPFLAGS@ @PCRE_CFLAGS@ @EXPAT_CFLAGS@ | 10 | Cflags: -I${includedir} @LIBCURL_CPPFLAGS@ @PCRE_CFLAGS@ @EXPAT_CFLAGS@ @TIDY_CFLAGS@ |
11 | Libs: -L${libdir} -lopkele @LIBCURL@ @PCRE_LIBS@ @EXPAT_LIBS@ | 11 | Libs: -L${libdir} -lopkele @LIBCURL@ @PCRE_LIBS@ @EXPAT_LIBS@ @TIDY_LIBS@ |