Omit definitions of xmlNode and xmlDocPtr if YAZ_HAVE_XML2 is unset.
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 16 Oct 2008 08:36:24 +0000 (10:36 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 16 Oct 2008 08:36:24 +0000 (10:36 +0200)
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.

include/yaz/ccl_xml.h
include/yaz/marcdisp.h
include/yaz/nmem_xml.h
include/yaz/record_conv.h
include/yaz/retrieval.h
include/yaz/xmlquery.h
include/yaz/xmltypes.h
src/cclxmlconfig.c
src/libxml2_error.c
src/marc_read_xml.c
src/marcdisp.c

index ae61bf4..d2d9c3b 100644 (file)
@@ -37,6 +37,7 @@
 
 YAZ_BEGIN_CDECL
 
 
 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
 /** \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);
 YAZ_EXPORT
 int ccl_xml_config(CCL_bibset bibset, const xmlNode *ptr,
                    const char **addinfo);
-
+#endif
 YAZ_END_CDECL
 
 #endif
 YAZ_END_CDECL
 
 #endif
index 188ddac..858e558 100644 (file)
@@ -162,6 +162,7 @@ int yaz_marc_read_line(yaz_marc_t mt,
                        void (*ungetbyte)(int b, void *client_data),
                        void *client_data);
 
                        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 
 /** \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);
     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
 
 /** \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);
 
 */  
 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
 /** \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);
                        const char *ns, 
                        const char *format,
                        const char *type);
+#endif
 
 /** \brief sets leader spec (for modifying bytes in 24 byte leader)
     \param mt handle
 
 /** \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);
 
 
                                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)
 /** \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);
 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
 
 /** \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);
 
 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)
 /** \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);
 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
 
 /** \brief returns memory for MARC handle
     \param mt handle
index 6d282c0..fdfe356 100644 (file)
 
 YAZ_BEGIN_CDECL
 
 
 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);
 /** \brief copies TEXT Libxml2 node data to NMEM */
 YAZ_EXPORT char *nmem_text_node_cdata(const xmlNode *ptr, NMEM nmem);
+#endif
 
 YAZ_END_CDECL
 
 
 YAZ_END_CDECL
 
index 763f882..5193d64 100644 (file)
@@ -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);
 
 */
 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)
 /** 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);
 */
 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
 
 /** performs record conversion on record buffer (OCTET aligned)
     \param p record conversion handle
index 9fdccb9..ca6940d 100644 (file)
@@ -54,6 +54,7 @@ YAZ_EXPORT yaz_retrieval_t yaz_retrieval_create(void);
 */
 YAZ_EXPORT void yaz_retrieval_destroy(yaz_retrieval_t p);
 
 */
 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)
 /** 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);
 */
 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
 
 /** performs retrieval request based on schema and format
     \param p retrieval handle
index 05409af..ec9b938 100644 (file)
 
 YAZ_BEGIN_CDECL
 
 
 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);
 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
 YAZ_END_CDECL
 
 #endif
index 0def187..659957c 100644 (file)
@@ -27,8 +27,7 @@
 
 /**
  * \file xmltypes.h
 
 /**
  * \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
  */
 #ifndef YAZ_XMLTYPES_H
 #define YAZ_XMLTYPES_H
 #include <libxml/tree.h>
 #endif
 
 #include <libxml/tree.h>
 #endif
 
-YAZ_BEGIN_CDECL
-
-#if YAZ_HAVE_XML2
-#else
-typedef void xmlNode;
-typedef void *xmlDocPtr;
-#endif
-
-YAZ_END_CDECL
-
 #endif
 /*
  * Local variables:
 #endif
 /*
  * Local variables:
index c339861..42ce896 100644 (file)
@@ -191,12 +191,6 @@ int ccl_xml_config(CCL_bibset bibset, const xmlNode *ptr, const char **addinfo)
     }
     return 0;
 }
     }
     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
 
 /*
 #endif
 
 /*
index 41d9284..d7abcf8 100644 (file)
@@ -23,6 +23,7 @@
 
 static int libxml2_error_level = 0;
 
 
 static int libxml2_error_level = 0;
 
+#if YAZ_HAVE_XML2
 static void proxy_xml_error_handler(void *ctx, const char *fmt, ...)
 {
     char buf[1024];
 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);
 }
 
     va_end (ap);
 }
+#endif
 
 int libxml2_error_to_yazlog(int level, const char *lead_msg)
 {
     libxml2_error_level = level;
 
 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_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;
     return 0;
 #else
     return -1;
index c4b2190..3615a6a 100644 (file)
@@ -217,9 +217,9 @@ static int yaz_marc_read_xml_fields(yaz_marc_t mt, const xmlNode *ptr)
 }
 #endif
 
 }
 #endif
 
+#if YAZ_HAVE_XML2
 int yaz_marc_read_xml(yaz_marc_t mt, const xmlNode *ptr)
 {
 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)
     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);
     if (yaz_marc_read_xml_leader(mt, &ptr))
         return -1;
     return yaz_marc_read_xml_fields(mt, ptr->next);
-#else
-    return -1;
-#endif
 }
 }
+#endif
 
 
 /*
 
 
 /*
index d244210..2f5f0d5 100644 (file)
@@ -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)
 {
 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;
     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;
     }
     wrbuf_destroy(wr_cdata);
     return 0;
-#else
-    return -1;
-#endif
 }
 }
+#endif
 
 int yaz_marc_write_iso2709(yaz_marc_t mt, WRBUF wr)
 {
 
 int yaz_marc_write_iso2709(yaz_marc_t mt, WRBUF wr)
 {