summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--configure.ac13
-rw-r--r--include/Makefile.am2
-rw-r--r--include/opkele/expat.h91
-rw-r--r--lib/Makefile.am7
-rw-r--r--lib/expat.cc96
-rw-r--r--libopkele.pc.in4
6 files changed, 207 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac
index 48a5efb..2b94b41 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,64 +37,77 @@ AC_ARG_ENABLE([konforka],
37 test "${enableval}" = "no" && WANT_KONFORKA="no" 37 test "${enableval}" = "no" && WANT_KONFORKA="no"
38 ] 38 ]
39) 39)
40if test "${WANT_KONFORKA}" = "yes" ; then 40if test "${WANT_KONFORKA}" = "yes" ; then
41 PKG_CHECK_MODULES([KONFORKA],[konforka],[ 41 PKG_CHECK_MODULES([KONFORKA],[konforka],[
42 AC_SUBST([KONFORKA_CFLAGS]) 42 AC_SUBST([KONFORKA_CFLAGS])
43 AC_SUBST([KONFORKA_LIBS]) 43 AC_SUBST([KONFORKA_LIBS])
44 AC_DEFINE([HAVE_KONFORKA],,[defined in presence of konforka library]) 44 AC_DEFINE([HAVE_KONFORKA],,[defined in presence of konforka library])
45 AC_DEFINE([OPKELE_HAVE_KONFORKA],,[defined in presence of konforka library]) 45 AC_DEFINE([OPKELE_HAVE_KONFORKA],,[defined in presence of konforka library])
46 AC_SUBST([KONFORKA_KONFORKA],[konforka]) 46 AC_SUBST([KONFORKA_KONFORKA],[konforka])
47 ],[true]) 47 ],[true])
48fi 48fi
49 49
50WANT_DOXYGEN="yes" 50WANT_DOXYGEN="yes"
51AC_ARG_ENABLE([doxygen], 51AC_ARG_ENABLE([doxygen],
52 AC_HELP_STRING([--disable-doxygen],[do not generate documentation]), 52 AC_HELP_STRING([--disable-doxygen],[do not generate documentation]),
53 [ 53 [
54 test "${enableval}" = "no" && WANT_DOXYGEN="no" 54 test "${enableval}" = "no" && WANT_DOXYGEN="no"
55 ] 55 ]
56) 56)
57if test "${WANT_DOXYGEN}" = "yes" ; then 57if test "${WANT_DOXYGEN}" = "yes" ; then
58 AC_WITH_DOXYGEN 58 AC_WITH_DOXYGEN
59 AC_WITH_DOT 59 AC_WITH_DOT
60else 60else
61 AM_CONDITIONAL([HAVE_DOXYGEN],[false]) 61 AM_CONDITIONAL([HAVE_DOXYGEN],[false])
62 AM_CONDITIONAL([HAVE_DOT],[false]) 62 AM_CONDITIONAL([HAVE_DOT],[false])
63fi 63fi
64 64
65LIBCURL_CHECK_CONFIG(,,,[ 65LIBCURL_CHECK_CONFIG(,,,[
66 AC_MSG_ERROR([no required libcurl library. get one from http://curl.haxx.se/]) 66 AC_MSG_ERROR([no required libcurl library. get one from http://curl.haxx.se/])
67]) 67])
68 68
69AC_CHECK_HEADER([expat.h],[
70 AC_CHECK_LIB([expat],[XML_ParserCreate],[
71 EXPAT_LIBS=-lexpat
72 EXPAT_CFLAGS=
73 AC_SUBST([EXPAT_LIBS])
74 AC_SUBST([EXPAT_CFLAGS])
75 ],[
76 AC_MSG_ERROR([no required expat library. get one from http://expat.sourceforge.net/])
77 ])
78],[
79 AC_MSG_ERROR([no required expat library. get one from http://expat.sourceforge.net/])
80])
81
69if test -n "$PCRE_LIBS" -a -n "$PCRE_CFLAGS" ; then 82if test -n "$PCRE_LIBS" -a -n "$PCRE_CFLAGS" ; then
70 AC_SUBST([PCRE_CFLAGS]) 83 AC_SUBST([PCRE_CFLAGS])
71 AC_SUBST([PCRE_LIBS]) 84 AC_SUBST([PCRE_LIBS])
72 : 85 :
73else 86else
74 PKG_CHECK_MODULES([PCRE],[libpcre],,[ 87 PKG_CHECK_MODULES([PCRE],[libpcre],,[
75 AC_MSG_ERROR([no libpcre found, go get it at http://www.pcre.org/]) 88 AC_MSG_ERROR([no libpcre found, go get it at http://www.pcre.org/])
76 ]) 89 ])
77fi 90fi
78 91
79curl_ssl_verify_host="true" 92curl_ssl_verify_host="true"
80AC_ARG_ENABLE([ssl-verify-host], 93AC_ARG_ENABLE([ssl-verify-host],
81 AC_HELP_STRING([--disable-ssl-verify-host],[disable cURL cert/host relationships verification]), 94 AC_HELP_STRING([--disable-ssl-verify-host],[disable cURL cert/host relationships verification]),
82 [ test "${enableval}" = "no" && curl_ssl_verify_host="false" ] 95 [ test "${enableval}" = "no" && curl_ssl_verify_host="false" ]
83) 96)
84${curl_ssl_verify_host} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYHOST],,[defined if cURL is not to verify cert/host]) 97${curl_ssl_verify_host} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYHOST],,[defined if cURL is not to verify cert/host])
85 98
86curl_ssl_verify_peer="true" 99curl_ssl_verify_peer="true"
87AC_ARG_ENABLE([ssl-verify-peer], 100AC_ARG_ENABLE([ssl-verify-peer],
88 AC_HELP_STRING([--disable-ssl-verify-peer],[disable cURL cert validity verification]), 101 AC_HELP_STRING([--disable-ssl-verify-peer],[disable cURL cert validity verification]),
89 [ test "${enableval}" = "no" && curl_ssl_verify_peer="false" ] 102 [ test "${enableval}" = "no" && curl_ssl_verify_peer="false" ]
90) 103)
91${curl_ssl_verify_peer} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYPEER],,[defined if cURL is not to verify cert validity]) 104${curl_ssl_verify_peer} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYPEER],,[defined if cURL is not to verify cert validity])
92 105
93postels_law=true 106postels_law=true
94AC_ARG_ENABLE([postels-law], 107AC_ARG_ENABLE([postels-law],
95 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)]), 108 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)]),
96 [ test "${enableval}" = "no" && postels_law=false ] 109 [ test "${enableval}" = "no" && postels_law=false ]
97) 110)
98$postels_law && AC_DEFINE([POSTELS_LAW],,[defined if we want to adhere to Postel's Law]) 111$postels_law && AC_DEFINE([POSTELS_LAW],,[defined if we want to adhere to Postel's Law])
99 112
100AC_DEFINE_UNQUOTED([OPKELE_SRC_DIR],["$PWD"],[source directory]) 113AC_DEFINE_UNQUOTED([OPKELE_SRC_DIR],["$PWD"],[source directory])
diff --git a/include/Makefile.am b/include/Makefile.am
index b31786d..0385cfb 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,17 +1,17 @@
1nobase_include_HEADERS = \ 1nobase_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
14EXTRA_DIST = \ 14EXTRA_DIST = \
15 opkele/data.h \ 15 opkele/data.h \
16 opkele/util.h \ 16 opkele/util.h \
17 opkele/curl.h 17 opkele/curl.h opkele/expat.h
diff --git a/include/opkele/expat.h b/include/opkele/expat.h
new file mode 100644
index 0000000..60c41ac
--- a/dev/null
+++ b/include/opkele/expat.h
@@ -0,0 +1,91 @@
1#ifndef __OPKELE_EXPAT_H
2#define __OPKELE_EXPAT_H
3
4#include <cassert>
5#include <expat.h>
6
7namespace opkele {
8
9 namespace util {
10
11 class expat_t {
12 public:
13 XML_Parser _x;
14
15 expat_t() : _x(0) { }
16 expat_t(XML_Parser x) : _x(x) { }
17 virtual ~expat_t() throw();
18
19 expat_t& operator=(XML_Parser x);
20
21 operator const XML_Parser(void) const { return _x; }
22 operator XML_Parser(void) { return _x; }
23
24 inline bool parse(const char *s,int len,bool final=false) {
25 assert(_x);
26 return XML_Parse(_x,s,len,final);
27 }
28
29 virtual void start_element(const XML_Char *n,const XML_Char **a) { }
30 virtual void end_element(const XML_Char *n) { }
31 void set_element_handler();
32
33 virtual void character_data(const XML_Char *s,int l) { }
34 void set_character_data_handler();
35
36 virtual void processing_instruction(const XML_Char *t,const XML_Char *d) { }
37 void set_processing_instruction_handler();
38
39 virtual void comment(const XML_Char *d) { }
40 void set_comment_handler();
41
42 virtual void start_cdata_section() { }
43 virtual void end_cdata_section() { }
44 void set_cdata_section_handler();
45
46 virtual void default_handler(const XML_Char *s,int l) { }
47 void set_default_handler();
48 void set_default_handler_expand();
49
50 virtual void start_namespace_decl(const XML_Char *p,const XML_Char *u) { }
51 virtual void end_namespace_decl(const XML_Char *p) { }
52 void set_namespace_decl_handler();
53
54 inline enum XML_Error get_error_code() {
55 assert(_x); return XML_GetErrorCode(_x); }
56 static inline const XML_LChar *error_string(XML_Error c) {
57 return XML_ErrorString(c); }
58
59 inline long get_current_byte_index() {
60 assert(_x); return XML_GetCurrentByteIndex(_x); }
61 inline int get_current_line_number() {
62 assert(_x); return XML_GetCurrentLineNumber(_x); }
63 inline int get_current_column_number() {
64 assert(_x); return XML_GetCurrentColumnNumber(_x); }
65
66 inline void set_user_data() {
67 assert(_x); XML_SetUserData(_x,this); }
68
69 inline bool set_base(const XML_Char *b) {
70 assert(_x); return XML_SetBase(_x,b); }
71 inline const XML_Char *get_base() {
72 assert(_x); return XML_GetBase(_x); }
73
74 inline int get_specified_attribute_count() {
75 assert(_x); return XML_GetSpecifiedAttributeCount(_x); }
76
77 inline bool set_param_entity_parsing(enum XML_ParamEntityParsing c) {
78 assert(_x); return XML_SetParamEntityParsing(_x,c); }
79
80 inline static XML_Parser parser_create(const XML_Char *e=0) {
81 return XML_ParserCreate(e); }
82 inline static XML_Parser parser_create_ns(const XML_Char *e=0,XML_Char s='\t') {
83 return XML_ParserCreateNS(e,s); }
84
85 };
86
87 }
88
89}
90
91#endif /* __OPKELE_EXPAT_H */
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 0fe705a..7309353 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,28 +1,29 @@
1lib_LTLIBRARIES = libopkele.la 1lib_LTLIBRARIES = libopkele.la
2 2
3DEFAULT_INCLUDES = -I${top_builddir}
3INCLUDES = \ 4INCLUDES = \
4 -I${top_srcdir}/include/ \ 5 -I${top_srcdir}/include/ \
5 ${KONFORKA_CFLAGS} \ 6 ${KONFORKA_CFLAGS} \
6 ${OPENSSL_CFLAGS} \ 7 ${OPENSSL_CFLAGS} \
7 ${LIBCURL_CPPFLAGS} \ 8 ${LIBCURL_CPPFLAGS} \
8 ${PCRE_CFLAGS} 9 ${PCRE_CFLAGS} ${EXPAT_CFLAGS}
9libopkele_la_LIBADD = \ 10libopkele_la_LIBADD = \
10 ${LIBCURL} \ 11 ${LIBCURL} \
11 ${PCRE_LIBS} \ 12 ${PCRE_LIBS} ${EXPAT_LIBS} \
12 ${OPENSSL_LIBS} \ 13 ${OPENSSL_LIBS} \
13 ${KONFORKA_LIBS} 14 ${KONFORKA_LIBS}
14 15
15libopkele_la_SOURCES = \ 16libopkele_la_SOURCES = \
16 params.cc \ 17 params.cc \
17 util.cc \ 18 util.cc \
18 server.cc \ 19 server.cc \
19 secret.cc \ 20 secret.cc \
20 data.cc \ 21 data.cc \
21 consumer.cc \ 22 consumer.cc \
22 exception.cc \ 23 exception.cc \
23 extension.cc \ 24 extension.cc \
24 sreg.cc \ 25 sreg.cc \
25 extension_chain.cc \ 26 extension_chain.cc \
26 curl.cc 27 curl.cc expat.cc
27libopkele_la_LDFLAGS = \ 28libopkele_la_LDFLAGS = \
28 -version-info 2:0:0 29 -version-info 2:0:0
diff --git a/lib/expat.cc b/lib/expat.cc
new file mode 100644
index 0000000..fa6fdde
--- a/dev/null
+++ b/lib/expat.cc
@@ -0,0 +1,96 @@
1#include <opkele/expat.h>
2
3namespace opkele {
4
5 namespace util {
6
7 expat_t::~expat_t() throw() {
8 if(_x)
9 XML_ParserFree(_x);
10 }
11
12 expat_t& expat_t::operator=(XML_Parser x) {
13 if(_x)
14 XML_ParserFree(_x);
15 _x = x;
16 }
17
18 static void _start_element(void* ud,const XML_Char *n,const XML_Char **a) {
19 ((expat_t*)ud)->start_element(n,a);
20 }
21 static void _end_element(void *ud,const XML_Char *n) {
22 ((expat_t*)ud)->end_element(n);
23 }
24
25 void expat_t::set_element_handler() {
26 assert(_x);
27 XML_SetElementHandler(_x,_start_element,_end_element);
28 }
29
30 static void _character_data(void *ud,const XML_Char *s,int l) {
31 ((expat_t*)ud)->character_data(s,l);
32 }
33
34 void expat_t::set_character_data_handler() {
35 assert(_x);
36 XML_SetCharacterDataHandler(_x,_character_data);
37 }
38
39 static void _processing_instruction(void *ud,const XML_Char *t,const XML_Char *d) {
40 ((expat_t*)ud)->processing_instruction(t,d);
41 }
42
43 void expat_t::set_processing_instruction_handler() {
44 assert(_x);
45 XML_SetProcessingInstructionHandler(_x,_processing_instruction);
46 }
47
48 static void _comment(void *ud,const XML_Char *d) {
49 ((expat_t*)ud)->comment(d);
50 }
51
52 void expat_t::set_comment_handler() {
53 assert(_x);
54 XML_SetCommentHandler(_x,_comment);
55 }
56
57 static void _start_cdata_section(void *ud) {
58 ((expat_t*)ud)->start_cdata_section();
59 }
60 static void _end_cdata_section(void *ud) {
61 ((expat_t*)ud)->end_cdata_section();
62 }
63
64 void expat_t::set_cdata_section_handler() {
65 assert(_x);
66 XML_SetCdataSectionHandler(_x,_start_cdata_section,_end_cdata_section);
67 }
68
69 static void _default_handler(void *ud,const XML_Char *s,int l) {
70 ((expat_t*)ud)->default_handler(s,l);
71 }
72
73 void expat_t::set_default_handler() {
74 assert(_x);
75 XML_SetDefaultHandler(_x,_default_handler);
76 }
77 void expat_t::set_default_handler_expand() {
78 assert(_x);
79 XML_SetDefaultHandlerExpand(_x,_default_handler);
80 }
81
82 static void _start_namespace_decl(void *ud,const XML_Char *p,const XML_Char *u) {
83 ((expat_t*)ud)->start_namespace_decl(p,u);
84 }
85 static void _end_namespace_decl(void *ud,const XML_Char *p) {
86 ((expat_t*)ud)->end_namespace_decl(p);
87 }
88
89 void expat_t::set_namespace_decl_handler() {
90 assert(_x);
91 XML_SetNamespaceDeclHandler(_x,_start_namespace_decl,_end_namespace_decl);
92 }
93
94 }
95
96}
diff --git a/libopkele.pc.in b/libopkele.pc.in
index bc67362..0a95e96 100644
--- a/libopkele.pc.in
+++ b/libopkele.pc.in
@@ -1,11 +1,11 @@
1prefix=@prefix@ 1prefix=@prefix@
2exec_prefix=@exec_prefix@ 2exec_prefix=@exec_prefix@
3libdir=@libdir@ 3libdir=@libdir@
4includedir=@includedir@ 4includedir=@includedir@
5 5
6Name: libopkele 6Name: libopkele
7Description: C++ implementation of OpenID protocol 7Description: C++ implementation of OpenID protocol
8Version: @VERSION@ 8Version: @VERSION@
9Requires: openssl libpcre @KONFORKA_KONFORKA@ 9Requires: openssl libpcre @KONFORKA_KONFORKA@
10Cflags: -I${includedir} @LIBCURL_CPPFLAGS@ @PCRE_CFLAGS@ 10Cflags: -I${includedir} @LIBCURL_CPPFLAGS@ @PCRE_CFLAGS@ @EXPAT_CFLAGS@
11Libs: -L${libdir} -lopkele @LIBCURL@ @PCRE_LIBS@ 11Libs: -L${libdir} -lopkele @LIBCURL@ @PCRE_LIBS@ @EXPAT_LIBS@