summaryrefslogtreecommitdiffabout
path: root/lib
Side-by-side diff
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
@@ -2,2 +2,3 @@ lib_LTLIBRARIES = libopkele.la
+DEFAULT_INCLUDES = -I${top_builddir}
INCLUDES = \
@@ -7,6 +8,6 @@ INCLUDES = \
${LIBCURL_CPPFLAGS} \
- ${PCRE_CFLAGS}
+ ${PCRE_CFLAGS} ${EXPAT_CFLAGS}
libopkele_la_LIBADD = \
${LIBCURL} \
- ${PCRE_LIBS} \
+ ${PCRE_LIBS} ${EXPAT_LIBS} \
${OPENSSL_LIBS} \
@@ -25,3 +26,3 @@ libopkele_la_SOURCES = \
extension_chain.cc \
- curl.cc
+ curl.cc expat.cc
libopkele_la_LDFLAGS = \
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 @@
+#include <opkele/expat.h>
+
+namespace opkele {
+
+ namespace util {
+
+ expat_t::~expat_t() throw() {
+ if(_x)
+ XML_ParserFree(_x);
+ }
+
+ expat_t& expat_t::operator=(XML_Parser x) {
+ if(_x)
+ XML_ParserFree(_x);
+ _x = x;
+ }
+
+ static void _start_element(void* ud,const XML_Char *n,const XML_Char **a) {
+ ((expat_t*)ud)->start_element(n,a);
+ }
+ static void _end_element(void *ud,const XML_Char *n) {
+ ((expat_t*)ud)->end_element(n);
+ }
+
+ void expat_t::set_element_handler() {
+ assert(_x);
+ XML_SetElementHandler(_x,_start_element,_end_element);
+ }
+
+ static void _character_data(void *ud,const XML_Char *s,int l) {
+ ((expat_t*)ud)->character_data(s,l);
+ }
+
+ void expat_t::set_character_data_handler() {
+ assert(_x);
+ XML_SetCharacterDataHandler(_x,_character_data);
+ }
+
+ static void _processing_instruction(void *ud,const XML_Char *t,const XML_Char *d) {
+ ((expat_t*)ud)->processing_instruction(t,d);
+ }
+
+ void expat_t::set_processing_instruction_handler() {
+ assert(_x);
+ XML_SetProcessingInstructionHandler(_x,_processing_instruction);
+ }
+
+ static void _comment(void *ud,const XML_Char *d) {
+ ((expat_t*)ud)->comment(d);
+ }
+
+ void expat_t::set_comment_handler() {
+ assert(_x);
+ XML_SetCommentHandler(_x,_comment);
+ }
+
+ static void _start_cdata_section(void *ud) {
+ ((expat_t*)ud)->start_cdata_section();
+ }
+ static void _end_cdata_section(void *ud) {
+ ((expat_t*)ud)->end_cdata_section();
+ }
+
+ void expat_t::set_cdata_section_handler() {
+ assert(_x);
+ XML_SetCdataSectionHandler(_x,_start_cdata_section,_end_cdata_section);
+ }
+
+ static void _default_handler(void *ud,const XML_Char *s,int l) {
+ ((expat_t*)ud)->default_handler(s,l);
+ }
+
+ void expat_t::set_default_handler() {
+ assert(_x);
+ XML_SetDefaultHandler(_x,_default_handler);
+ }
+ void expat_t::set_default_handler_expand() {
+ assert(_x);
+ XML_SetDefaultHandlerExpand(_x,_default_handler);
+ }
+
+ static void _start_namespace_decl(void *ud,const XML_Char *p,const XML_Char *u) {
+ ((expat_t*)ud)->start_namespace_decl(p,u);
+ }
+ static void _end_namespace_decl(void *ud,const XML_Char *p) {
+ ((expat_t*)ud)->end_namespace_decl(p);
+ }
+
+ void expat_t::set_namespace_decl_handler() {
+ assert(_x);
+ XML_SetNamespaceDeclHandler(_x,_start_namespace_decl,_end_namespace_decl);
+ }
+
+ }
+
+}