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 | |
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-- | 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 | |||
@@ -21,178 +21,191 @@ if headrev=$(cd $srcdir && git rev-parse --verify HEAD 2>/dev/null) ; then | |||
21 | ( cd $srcdir && git diff-index $headrev | read dirt ) && PACKAGE_SRC_VERSION="${PACKAGE_SRC_VERSION}-dirty" | 21 | ( cd $srcdir && git diff-index $headrev | read dirt ) && PACKAGE_SRC_VERSION="${PACKAGE_SRC_VERSION}-dirty" |
22 | else | 22 | else |
23 | PACKAGE_SRC_VERSION="$PACKAGE_VERSION" | 23 | PACKAGE_SRC_VERSION="$PACKAGE_VERSION" |
24 | fi | 24 | fi |
25 | AC_MSG_RESULT([$PACKAGE_SRC_VERSION]) | 25 | AC_MSG_RESULT([$PACKAGE_SRC_VERSION]) |
26 | AC_SUBST([PACKAGE_SRC_VERSION]) | 26 | AC_SUBST([PACKAGE_SRC_VERSION]) |
27 | AC_DEFINE_UNQUOTED([PACKAGE_SRC_VERSION],["$PACKAGE_SRC_VERSION"],[more or less precise source tree version]) | 27 | AC_DEFINE_UNQUOTED([PACKAGE_SRC_VERSION],["$PACKAGE_SRC_VERSION"],[more or less precise source tree version]) |
28 | 28 | ||
29 | tr1_mem_std="false" | 29 | tr1_mem_std="false" |
30 | tr1_mem_boost="false" | 30 | tr1_mem_boost="false" |
31 | AC_CHECK_SHAREDPTR(std::tr1,tr1/memory,[ tr1_mem_std=true ]) | 31 | AC_CHECK_SHAREDPTR(std::tr1,tr1/memory,[ tr1_mem_std=true ]) |
32 | AC_CHECK_SHAREDPTR(boost,boost/shared_ptr.hpp,[ tr1_mem_boost=true ]) | 32 | AC_CHECK_SHAREDPTR(boost,boost/shared_ptr.hpp,[ tr1_mem_boost=true ]) |
33 | tr1_mem="" | 33 | tr1_mem="" |
34 | AC_ARG_WITH([tr1-memory], | 34 | AC_ARG_WITH([tr1-memory], |
35 | AC_HELP_STRING([--with-tr1-memory=<boost|std>],[select tr1/memory (shared_ptr<>) implementation to use]), | 35 | AC_HELP_STRING([--with-tr1-memory=<boost|std>],[select tr1/memory (shared_ptr<>) implementation to use]), |
36 | [ tr1_mem="$withval" ] | 36 | [ tr1_mem="$withval" ] |
37 | ) | 37 | ) |
38 | AC_MSG_CHECKING([for tr1/memory implementation to use]) | 38 | AC_MSG_CHECKING([for tr1/memory implementation to use]) |
39 | test -z "$tr1_mem" && $tr1_mem_std && tr1_mem=std | 39 | test -z "$tr1_mem" && $tr1_mem_std && tr1_mem=std |
40 | test -z "$tr1_mem" && $tr1_mem_boost && tr1_mem=boost | 40 | test -z "$tr1_mem" && $tr1_mem_boost && tr1_mem=boost |
41 | if test -z "$tr1_mem" ; then | 41 | if test -z "$tr1_mem" ; then |
42 | AC_MSG_RESULT([none found]) | 42 | AC_MSG_RESULT([none found]) |
43 | else | 43 | else |
44 | AC_MSG_RESULT([$tr1_mem]) | 44 | AC_MSG_RESULT([$tr1_mem]) |
45 | fi | 45 | fi |
46 | case "$tr1_mem" in | 46 | case "$tr1_mem" in |
47 | std) | 47 | std) |
48 | $tr1_mem_std || AC_MSG_ERROR([std implementation requested, but not found]) | 48 | $tr1_mem_std || AC_MSG_ERROR([std implementation requested, but not found]) |
49 | OPKELE_TR1_MEM_NS=std::tr1 | 49 | OPKELE_TR1_MEM_NS=std::tr1 |
50 | OPKELE_TR1_MEM_HEADER=tr1/memory | 50 | OPKELE_TR1_MEM_HEADER=tr1/memory |
51 | ;; | 51 | ;; |
52 | boost) | 52 | boost) |
53 | $tr1_mem_boost || AC_MSG_ERROR([boost implementation requested, but not found]) | 53 | $tr1_mem_boost || AC_MSG_ERROR([boost implementation requested, but not found]) |
54 | OPKELE_TR1_MEM_NS=boost | 54 | OPKELE_TR1_MEM_NS=boost |
55 | OPKELE_TR1_MEM_HEADER=boost/shared_ptr.hpp | 55 | OPKELE_TR1_MEM_HEADER=boost/shared_ptr.hpp |
56 | ;; | 56 | ;; |
57 | *) | 57 | *) |
58 | AC_MSG_ERROR([no shared_ptr<> implementation found]) | 58 | AC_MSG_ERROR([no shared_ptr<> implementation found]) |
59 | ;; | 59 | ;; |
60 | esac | 60 | esac |
61 | AC_SUBST([OPKELE_TR1_MEM_NS]) | 61 | AC_SUBST([OPKELE_TR1_MEM_NS]) |
62 | AC_SUBST([OPKELE_TR1_MEM_HEADER]) | 62 | AC_SUBST([OPKELE_TR1_MEM_HEADER]) |
63 | 63 | ||
64 | PKG_CHECK_MODULES([OPENSSL],[openssl],,[ | 64 | PKG_CHECK_MODULES([OPENSSL],[openssl],,[ |
65 | AC_MSG_ERROR([no openssl library found. get one from http://www.openssl.org/]) | 65 | AC_MSG_ERROR([no openssl library found. get one from http://www.openssl.org/]) |
66 | ]) | 66 | ]) |
67 | 67 | ||
68 | WANT_KONFORKA="yes" | 68 | WANT_KONFORKA="yes" |
69 | AC_ARG_ENABLE([konforka], | 69 | AC_ARG_ENABLE([konforka], |
70 | AC_HELP_STRING([--disable-konforka],[do not use konforka library (default: use if found)]), | 70 | AC_HELP_STRING([--disable-konforka],[do not use konforka library (default: use if found)]), |
71 | [ | 71 | [ |
72 | test "${enableval}" = "no" && WANT_KONFORKA="no" | 72 | test "${enableval}" = "no" && WANT_KONFORKA="no" |
73 | ] | 73 | ] |
74 | ) | 74 | ) |
75 | if test "${WANT_KONFORKA}" = "yes" ; then | 75 | if test "${WANT_KONFORKA}" = "yes" ; then |
76 | PKG_CHECK_MODULES([KONFORKA],[konforka],[ | 76 | PKG_CHECK_MODULES([KONFORKA],[konforka],[ |
77 | AC_SUBST([KONFORKA_CFLAGS]) | 77 | AC_SUBST([KONFORKA_CFLAGS]) |
78 | AC_SUBST([KONFORKA_LIBS]) | 78 | AC_SUBST([KONFORKA_LIBS]) |
79 | AC_DEFINE([HAVE_KONFORKA],,[defined in presence of konforka library]) | 79 | AC_DEFINE([HAVE_KONFORKA],,[defined in presence of konforka library]) |
80 | AC_DEFINE([OPKELE_HAVE_KONFORKA],,[defined in presence of konforka library]) | 80 | AC_DEFINE([OPKELE_HAVE_KONFORKA],,[defined in presence of konforka library]) |
81 | AC_SUBST([KONFORKA_KONFORKA],[konforka]) | 81 | AC_SUBST([KONFORKA_KONFORKA],[konforka]) |
82 | ],[true]) | 82 | ],[true]) |
83 | fi | 83 | fi |
84 | 84 | ||
85 | WANT_DOXYGEN="yes" | 85 | WANT_DOXYGEN="yes" |
86 | AC_ARG_ENABLE([doxygen], | 86 | AC_ARG_ENABLE([doxygen], |
87 | AC_HELP_STRING([--disable-doxygen],[do not generate documentation]), | 87 | AC_HELP_STRING([--disable-doxygen],[do not generate documentation]), |
88 | [ | 88 | [ |
89 | test "${enableval}" = "no" && WANT_DOXYGEN="no" | 89 | test "${enableval}" = "no" && WANT_DOXYGEN="no" |
90 | ] | 90 | ] |
91 | ) | 91 | ) |
92 | if test "${WANT_DOXYGEN}" = "yes" ; then | 92 | if test "${WANT_DOXYGEN}" = "yes" ; then |
93 | AC_WITH_DOXYGEN | 93 | AC_WITH_DOXYGEN |
94 | AC_WITH_DOT | 94 | AC_WITH_DOT |
95 | else | 95 | else |
96 | AM_CONDITIONAL([HAVE_DOXYGEN],[false]) | 96 | AM_CONDITIONAL([HAVE_DOXYGEN],[false]) |
97 | AM_CONDITIONAL([HAVE_DOT],[false]) | 97 | AM_CONDITIONAL([HAVE_DOT],[false]) |
98 | fi | 98 | fi |
99 | 99 | ||
100 | LIBCURL_CHECK_CONFIG(,,,[ | 100 | 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]) |
133 | 146 | ||
134 | curl_ssl_verify_peer="true" | 147 | curl_ssl_verify_peer="true" |
135 | AC_ARG_ENABLE([ssl-verify-peer], | 148 | AC_ARG_ENABLE([ssl-verify-peer], |
136 | AC_HELP_STRING([--disable-ssl-verify-peer],[disable cURL cert validity verification]), | 149 | AC_HELP_STRING([--disable-ssl-verify-peer],[disable cURL cert validity verification]), |
137 | [ test "${enableval}" = "no" && curl_ssl_verify_peer="false" ] | 150 | [ test "${enableval}" = "no" && curl_ssl_verify_peer="false" ] |
138 | ) | 151 | ) |
139 | ${curl_ssl_verify_peer} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYPEER],,[defined if cURL is not to verify cert validity]) | 152 | ${curl_ssl_verify_peer} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYPEER],,[defined if cURL is not to verify cert validity]) |
140 | 153 | ||
141 | postels_law=true | 154 | postels_law=true |
142 | AC_ARG_ENABLE([postels-law], | 155 | AC_ARG_ENABLE([postels-law], |
143 | AC_HELP_STRING([--disable-postels-law],[Be strict, do not adhere to Postel's Law ("be conservative in what you do, be liberal in what you accept from others", RFC 793)]), | 156 | AC_HELP_STRING([--disable-postels-law],[Be strict, do not adhere to Postel's Law ("be conservative in what you do, be liberal in what you accept from others", RFC 793)]), |
144 | [ test "${enableval}" = "no" && postels_law=false ] | 157 | [ test "${enableval}" = "no" && postels_law=false ] |
145 | ) | 158 | ) |
146 | $postels_law && AC_DEFINE([POSTELS_LAW],,[defined if we want to adhere to Postel's Law]) | 159 | $postels_law && AC_DEFINE([POSTELS_LAW],,[defined if we want to adhere to Postel's Law]) |
147 | 160 | ||
148 | AC_DEFINE_UNQUOTED([OPKELE_SRC_DIR],["$PWD"],[source directory]) | 161 | AC_DEFINE_UNQUOTED([OPKELE_SRC_DIR],["$PWD"],[source directory]) |
149 | 162 | ||
150 | nitpick=false | 163 | nitpick=false |
151 | AC_ARG_ENABLE([nitpicking], | 164 | AC_ARG_ENABLE([nitpicking], |
152 | AC_HELP_STRING([--enable-nitpicking],[make compiler somewhat overly fastidious about the code it deals with]), | 165 | AC_HELP_STRING([--enable-nitpicking],[make compiler somewhat overly fastidious about the code it deals with]), |
153 | [ test "$enableval" = "no" || nitpick=true ] | 166 | [ test "$enableval" = "no" || nitpick=true ] |
154 | ) | 167 | ) |
155 | if $nitpick ; then | 168 | if $nitpick ; then |
156 | CPP_NITPICK="-pedantic -Wall -Wextra -Wundef -Wshadow \ | 169 | CPP_NITPICK="-pedantic -Wall -Wextra -Wundef -Wshadow \ |
157 | -Wunsafe-loop-optimizations -Wconversion -Wmissing-format-attribute \ | 170 | -Wunsafe-loop-optimizations -Wconversion -Wmissing-format-attribute \ |
158 | -Wredundant-decls -ansi" | 171 | -Wredundant-decls -ansi" |
159 | # -Wlogical-op -Wmissing-noreturn | 172 | # -Wlogical-op -Wmissing-noreturn |
160 | C_NITPICK="$CPP_NITPICK" | 173 | C_NITPICK="$CPP_NITPICK" |
161 | CXX_NITPICK="$C_NITPICK" | 174 | CXX_NITPICK="$C_NITPICK" |
162 | 175 | ||
163 | CPPFLAGS="$CPPFLAGS $CPP_NITPICK" | 176 | CPPFLAGS="$CPPFLAGS $CPP_NITPICK" |
164 | CFLAGS="$CFLAGS $C_NITPICK" | 177 | CFLAGS="$CFLAGS $C_NITPICK" |
165 | CXXFLAGS="$CXXFLAGS $CXX_NITPICK" | 178 | CXXFLAGS="$CXXFLAGS $CXX_NITPICK" |
166 | fi | 179 | fi |
167 | 180 | ||
168 | ndebug=true | 181 | ndebug=true |
169 | AC_ARG_ENABLE([debug], | 182 | AC_ARG_ENABLE([debug], |
170 | AC_HELP_STRING([--enable-debug],[enable debugging code]), | 183 | AC_HELP_STRING([--enable-debug],[enable debugging code]), |
171 | [ test "$enableval" = "no" || ndebug=false ] | 184 | [ test "$enableval" = "no" || ndebug=false ] |
172 | ) | 185 | ) |
173 | if $ndebug ; then | 186 | if $ndebug ; then |
174 | CPPFLAGS_DEBUG="-DNDEBUG" | 187 | CPPFLAGS_DEBUG="-DNDEBUG" |
175 | else | 188 | else |
176 | CPPFLAGS_DEBUG="" | 189 | CPPFLAGS_DEBUG="" |
177 | fi | 190 | fi |
178 | AC_SUBST([CPPFLAGS_DEBUG]) | 191 | AC_SUBST([CPPFLAGS_DEBUG]) |
179 | 192 | ||
180 | xri_proxy_url="http://beta.xri.net/" | 193 | xri_proxy_url="http://beta.xri.net/" |
181 | AC_MSG_CHECKING([for XRI resolver proxy]) | 194 | AC_MSG_CHECKING([for XRI resolver proxy]) |
182 | AC_ARG_ENABLE([xri-proxy], | 195 | AC_ARG_ENABLE([xri-proxy], |
183 | AC_HELP_STRING([--with-xri-proxy=url],[set xri proxy for use when resolving xri identities, default is http://xr_proxy_url]), | 196 | AC_HELP_STRING([--with-xri-proxy=url],[set xri proxy for use when resolving xri identities, default is http://xr_proxy_url]), |
184 | [ xri_proxy_url="$withval" ] | 197 | [ xri_proxy_url="$withval" ] |
185 | ) | 198 | ) |
186 | AC_MSG_RESULT([$xri_proxy_url]) | 199 | AC_MSG_RESULT([$xri_proxy_url]) |
187 | AC_DEFINE_UNQUOTED([XRI_PROXY_URL],["$xri_proxy_url"],[XRI proxy resolver URL]) | 200 | AC_DEFINE_UNQUOTED([XRI_PROXY_URL],["$xri_proxy_url"],[XRI proxy resolver URL]) |
188 | 201 | ||
189 | AC_CONFIG_FILES([ | 202 | AC_CONFIG_FILES([ |
190 | Makefile | 203 | Makefile |
191 | libopkele.pc | 204 | libopkele.pc |
192 | Doxyfile | 205 | Doxyfile |
193 | include/Makefile | 206 | include/Makefile |
194 | include/opkele/tr1-mem.h | 207 | include/opkele/tr1-mem.h |
195 | lib/Makefile | 208 | lib/Makefile |
196 | test/Makefile | 209 | test/Makefile |
197 | ]) | 210 | ]) |
198 | AC_OUTPUT | 211 | AC_OUTPUT |
diff --git a/include/Makefile.am b/include/Makefile.am index 1076c12..51dcea1 100644 --- a/include/Makefile.am +++ b/include/Makefile.am | |||
@@ -1,21 +1,21 @@ | |||
1 | nobase_include_HEADERS = \ | 1 | nobase_include_HEADERS = \ |
2 | opkele/acconfig.h \ | 2 | opkele/acconfig.h \ |
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 | |||
@@ -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 */ | ||
diff --git a/lib/exception.cc b/lib/exception.cc index 0b775f7..e32594b 100644 --- a/lib/exception.cc +++ b/lib/exception.cc | |||
@@ -1,45 +1,51 @@ | |||
1 | #include <openssl/err.h> | 1 | #include <openssl/err.h> |
2 | #include <curl/curl.h> | 2 | #include <curl/curl.h> |
3 | #include <opkele/exception.h> | 3 | #include <opkele/exception.h> |
4 | #include <opkele/debug.h> | 4 | #include <opkele/debug.h> |
5 | 5 | ||
6 | namespace opkele { | 6 | namespace opkele { |
7 | 7 | ||
8 | # ifndef OPKELE_HAVE_KONFORKA | 8 | # ifndef OPKELE_HAVE_KONFORKA |
9 | 9 | ||
10 | exception::exception(const string& w) | 10 | exception::exception(const string& w) |
11 | : _what(w) | 11 | : _what(w) |
12 | { | 12 | { |
13 | DOUT_("throwing exception(\""<<w<<"\")"); | 13 | DOUT_("throwing exception(\""<<w<<"\")"); |
14 | } | 14 | } |
15 | 15 | ||
16 | exception::~exception() throw() { | 16 | exception::~exception() throw() { |
17 | } | 17 | } |
18 | const char *exception::what() const throw() { | 18 | const char *exception::what() const throw() { |
19 | return _what.c_str(); | 19 | return _what.c_str(); |
20 | } | 20 | } |
21 | 21 | ||
22 | # else | 22 | # else |
23 | 23 | ||
24 | exception::exception(const string& fi,const string& fu,int l,const string& w) | 24 | exception::exception(const string& fi,const string& fu,int l,const string& w) |
25 | : konforka::exception(fi,fu,l,w) | 25 | : konforka::exception(fi,fu,l,w) |
26 | { | 26 | { |
27 | DOUT_("throwing exception(\""<<w<<"\")"); | 27 | DOUT_("throwing exception(\""<<w<<"\")"); |
28 | DOUT_(" from "<<fi<<':'<<fu<<':'<<l); | 28 | DOUT_(" from "<<fi<<':'<<fu<<':'<<l); |
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@ |