summaryrefslogtreecommitdiffabout
path: root/lib
authorMichael Krelin <hacker@klever.net>2007-11-28 18:01:36 (UTC)
committer Michael Krelin <hacker@klever.net>2007-11-28 18:01:36 (UTC)
commit73d98f3652b498b9a74b183bef395714c7d73fda (patch) (unidiff)
tree0d206adb4e28d321c5050b7c04274cf6a8a97e51 /lib
parent7ddb513bec854479fc9efb2a79044a978055d800 (diff)
downloadlibopkele-73d98f3652b498b9a74b183bef395714c7d73fda.zip
libopkele-73d98f3652b498b9a74b183bef395714c7d73fda.tar.gz
libopkele-73d98f3652b498b9a74b183bef395714c7d73fda.tar.bz2
added a trivial expat wrapper
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'lib') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/Makefile.am7
-rw-r--r--lib/expat.cc96
2 files changed, 100 insertions, 3 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 0fe705a..7309353 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,14 +1,15 @@
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
@@ -23,6 +24,6 @@ libopkele_la_SOURCES = \
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}