From: Adam Dickmeiss Date: Thu, 16 Oct 2008 08:36:24 +0000 (+0200) Subject: Omit definitions of xmlNode and xmlDocPtr if YAZ_HAVE_XML2 is unset. X-Git-Tag: v3.0.38~26 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=3fa6bf34c5496f69a63469a3184251d38758c85d Omit definitions of xmlNode and xmlDocPtr if YAZ_HAVE_XML2 is unset. When YAZ is compiled without Libxml2 support (YAZ_HAVE_XML2 is unset), the types xmlNode and xmlDocPtr are no longer defined in xmltypes.h. Problem was that these dummy definitions could clash with other apps that used Libxml2 anyway. --- diff --git a/include/yaz/ccl_xml.h b/include/yaz/ccl_xml.h index ae61bf4..d2d9c3b 100644 --- a/include/yaz/ccl_xml.h +++ b/include/yaz/ccl_xml.h @@ -37,6 +37,7 @@ YAZ_BEGIN_CDECL +#if YAZ_HAVE_XML2 /** \brief configures CCL bibset using XML configuration \param bibset CCL bibliographic profile \param ptr xml node pointer pointing to "cclmap" element @@ -64,7 +65,7 @@ YAZ_BEGIN_CDECL YAZ_EXPORT int ccl_xml_config(CCL_bibset bibset, const xmlNode *ptr, const char **addinfo); - +#endif YAZ_END_CDECL #endif diff --git a/include/yaz/marcdisp.h b/include/yaz/marcdisp.h index 188ddac..858e558 100644 --- a/include/yaz/marcdisp.h +++ b/include/yaz/marcdisp.h @@ -162,6 +162,7 @@ int yaz_marc_read_line(yaz_marc_t mt, void (*ungetbyte)(int b, void *client_data), void *client_data); +#if YAZ_HAVE_XML2 /** \brief parses MARCXML/MarcXchange record from xmlNode pointer \param mt handle \param ptr is a pointer to root xml node @@ -169,6 +170,7 @@ int yaz_marc_read_line(yaz_marc_t mt, Returns 0=OK, -1=ERROR */ YAZ_EXPORT int yaz_marc_read_xml(yaz_marc_t mt, const xmlNode *ptr); +#endif /** \brief writes record in line format \param mt handle @@ -214,6 +216,7 @@ YAZ_EXPORT int yaz_marc_write_iso2709(yaz_marc_t mt, WRBUF wrbuf); */ YAZ_EXPORT int yaz_marc_write_mode(yaz_marc_t mt, WRBUF wrbuf); +#if YAZ_HAVE_XML2 /** \brief writes MARC record as libxml2 tree \param mt handle \param root_ptr pointer to record node @@ -228,6 +231,7 @@ int yaz_marc_write_xml(yaz_marc_t mt, xmlNode **root_ptr, const char *ns, const char *format, const char *type); +#endif /** \brief sets leader spec (for modifying bytes in 24 byte leader) \param mt handle @@ -298,6 +302,7 @@ void yaz_marc_add_controlfield(yaz_marc_t mt, const char *tag, const char *data, size_t data_len); +#if YAZ_HAVE_XML2 /** \brief adds controlfield to MARC structure using xml Nodes \param mt handle \param ptr_tag value of tag (TEXT xmlNode) @@ -306,7 +311,7 @@ void yaz_marc_add_controlfield(yaz_marc_t mt, const char *tag, YAZ_EXPORT void yaz_marc_add_controlfield_xml(yaz_marc_t mt, const xmlNode *ptr_tag, const xmlNode *ptr_data); - +#endif /** \brief adds datafield to MARC structure using strings \param mt handle @@ -318,6 +323,7 @@ YAZ_EXPORT void yaz_marc_add_datafield(yaz_marc_t mt, const char *tag, const char *indicator, size_t indicator_len); +#if YAZ_HAVE_XML2 /** \brief adds datafield to MARC structure using xml Nodes \param mt handle \param ptr_tag value of tag (TEXT xmlNode) @@ -327,7 +333,7 @@ void yaz_marc_add_datafield(yaz_marc_t mt, const char *tag, YAZ_EXPORT void yaz_marc_add_datafield_xml(yaz_marc_t mt, const xmlNode *ptr_tag, const char *indicator, size_t indicator_len); - +#endif /** \brief returns memory for MARC handle \param mt handle diff --git a/include/yaz/nmem_xml.h b/include/yaz/nmem_xml.h index 6d282c0..fdfe356 100644 --- a/include/yaz/nmem_xml.h +++ b/include/yaz/nmem_xml.h @@ -38,8 +38,10 @@ YAZ_BEGIN_CDECL +#if YAZ_HAVE_XML2 /** \brief copies TEXT Libxml2 node data to NMEM */ YAZ_EXPORT char *nmem_text_node_cdata(const xmlNode *ptr, NMEM nmem); +#endif YAZ_END_CDECL diff --git a/include/yaz/record_conv.h b/include/yaz/record_conv.h index 763f882..5193d64 100644 --- a/include/yaz/record_conv.h +++ b/include/yaz/record_conv.h @@ -54,6 +54,7 @@ YAZ_EXPORT yaz_record_conv_t yaz_record_conv_create(void); */ YAZ_EXPORT void yaz_record_conv_destroy(yaz_record_conv_t p); +#if YAZ_HAVE_XML2 /** configures record conversion \param p record conversion handle \param node xmlNode pointer (root element of XML config) @@ -79,6 +80,7 @@ YAZ_EXPORT void yaz_record_conv_destroy(yaz_record_conv_t p); */ YAZ_EXPORT int yaz_record_conv_configure(yaz_record_conv_t p, const xmlNode *node); +#endif /** performs record conversion on record buffer (OCTET aligned) \param p record conversion handle diff --git a/include/yaz/retrieval.h b/include/yaz/retrieval.h index 9fdccb9..ca6940d 100644 --- a/include/yaz/retrieval.h +++ b/include/yaz/retrieval.h @@ -54,6 +54,7 @@ YAZ_EXPORT yaz_retrieval_t yaz_retrieval_create(void); */ YAZ_EXPORT void yaz_retrieval_destroy(yaz_retrieval_t p); +#if YAZ_HAVE_XML2 /** configures retrieval \param p retrieval handle \param node xmlNode pointer (root element of XML config) @@ -86,7 +87,7 @@ YAZ_EXPORT void yaz_retrieval_destroy(yaz_retrieval_t p); */ YAZ_EXPORT int yaz_retrieval_configure(yaz_retrieval_t p, const xmlNode *node); - +#endif /** performs retrieval request based on schema and format \param p retrieval handle diff --git a/include/yaz/xmlquery.h b/include/yaz/xmlquery.h index 05409af..ec9b938 100644 --- a/include/yaz/xmlquery.h +++ b/include/yaz/xmlquery.h @@ -38,12 +38,13 @@ YAZ_BEGIN_CDECL +#if YAZ_HAVE_XML2 YAZ_EXPORT void yaz_query2xml(const Z_Query *q, xmlDocPtr *docp); YAZ_EXPORT void yaz_rpnquery2xml(const Z_RPNQuery *rpn, xmlDocPtr *docp); YAZ_EXPORT void yaz_xml2query(const xmlNode *xmlnodep, Z_Query **query, ODR odr, int *error_code, const char **addinfo); - +#endif YAZ_END_CDECL #endif diff --git a/include/yaz/xmltypes.h b/include/yaz/xmltypes.h index 0def187..659957c 100644 --- a/include/yaz/xmltypes.h +++ b/include/yaz/xmltypes.h @@ -27,8 +27,7 @@ /** * \file xmltypes.h - * \brief Define fundamental Libxml2 types for functions YAZ provide. - * \details If Libxml2 is not installed, we define dummy types instead. + * \brief Define xmlNode and xmlDocPtr if Libxml2 is present */ #ifndef YAZ_XMLTYPES_H #define YAZ_XMLTYPES_H @@ -37,16 +36,6 @@ #include #endif -YAZ_BEGIN_CDECL - -#if YAZ_HAVE_XML2 -#else -typedef void xmlNode; -typedef void *xmlDocPtr; -#endif - -YAZ_END_CDECL - #endif /* * Local variables: diff --git a/src/cclxmlconfig.c b/src/cclxmlconfig.c index c339861..42ce896 100644 --- a/src/cclxmlconfig.c +++ b/src/cclxmlconfig.c @@ -191,12 +191,6 @@ int ccl_xml_config(CCL_bibset bibset, const xmlNode *ptr, const char **addinfo) } return 0; } -#else -int ccl_xml_config(CCL_bibset bibset, const xmlNode *ptr, const char **addinfo) -{ - *addinfo = "CCL XML configuration not supported. Libxml2 is disabled"; - return -1; -} #endif /* diff --git a/src/libxml2_error.c b/src/libxml2_error.c index 41d9284..d7abcf8 100644 --- a/src/libxml2_error.c +++ b/src/libxml2_error.c @@ -23,6 +23,7 @@ static int libxml2_error_level = 0; +#if YAZ_HAVE_XML2 static void proxy_xml_error_handler(void *ctx, const char *fmt, ...) { char buf[1024]; @@ -35,15 +36,16 @@ static void proxy_xml_error_handler(void *ctx, const char *fmt, ...) va_end (ap); } +#endif int libxml2_error_to_yazlog(int level, const char *lead_msg) { libxml2_error_level = level; +#if YAZ_HAVE_XML2 + xmlSetGenericErrorFunc((void *) "XML", proxy_xml_error_handler); #if YAZ_HAVE_XSLT xsltSetGenericErrorFunc((void *) "XSLT", proxy_xml_error_handler); #endif -#if YAZ_HAVE_XML2 - xmlSetGenericErrorFunc((void *) "XML", proxy_xml_error_handler); return 0; #else return -1; diff --git a/src/marc_read_xml.c b/src/marc_read_xml.c index c4b2190..3615a6a 100644 --- a/src/marc_read_xml.c +++ b/src/marc_read_xml.c @@ -217,9 +217,9 @@ static int yaz_marc_read_xml_fields(yaz_marc_t mt, const xmlNode *ptr) } #endif +#if YAZ_HAVE_XML2 int yaz_marc_read_xml(yaz_marc_t mt, const xmlNode *ptr) { -#if YAZ_HAVE_XML2 yaz_marc_reset(mt); for(; ptr; ptr = ptr->next) @@ -245,10 +245,8 @@ int yaz_marc_read_xml(yaz_marc_t mt, const xmlNode *ptr) if (yaz_marc_read_xml_leader(mt, &ptr)) return -1; return yaz_marc_read_xml_fields(mt, ptr->next); -#else - return -1; -#endif } +#endif /* diff --git a/src/marcdisp.c b/src/marcdisp.c index d244210..2f5f0d5 100644 --- a/src/marcdisp.c +++ b/src/marcdisp.c @@ -718,12 +718,12 @@ int yaz_marc_write_marcxchange(yaz_marc_t mt, WRBUF wr, } +#if YAZ_HAVE_XML2 int yaz_marc_write_xml(yaz_marc_t mt, xmlNode **root_ptr, const char *ns, const char *format, const char *type) { -#if YAZ_HAVE_XML2 struct yaz_marc_node *n; int identifier_length; const char *leader = 0; @@ -828,10 +828,8 @@ int yaz_marc_write_xml(yaz_marc_t mt, xmlNode **root_ptr, } wrbuf_destroy(wr_cdata); return 0; -#else - return -1; -#endif } +#endif int yaz_marc_write_iso2709(yaz_marc_t mt, WRBUF wr) {