Added header yaz/xmltypes.h which include libxml2' node definitions
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 13 Dec 2006 11:25:17 +0000 (11:25 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 13 Dec 2006 11:25:17 +0000 (11:25 +0000)
or provide dummy alternatives if libxml2 is disabled (or does not exist).
This allows all Libxml2 related functions to be publicly defined
unconditionally. Also provides a more type safe system for applications
using these functions.

include/yaz/Makefile.am
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 [new file with mode: 0644]
src/elementset.c
src/marcdisp.c
src/record_conv.c
src/retrieval.c

index 449f834..7f818ee 100644 (file)
@@ -1,4 +1,4 @@
-## $Id: Makefile.am,v 1.35 2006-12-13 10:35:44 adam Exp $
+## $Id: Makefile.am,v 1.36 2006-12-13 11:25:17 adam Exp $
 
 pkginclude_HEADERS= backend.h ccl.h cql.h comstack.h \
  diagbib1.h diagsrw.h diagsru_update.h sortspec.h log.h logrpn.h marcdisp.h \
 
 pkginclude_HEADERS= backend.h ccl.h cql.h comstack.h \
  diagbib1.h diagsrw.h diagsru_update.h sortspec.h log.h logrpn.h marcdisp.h \
@@ -7,7 +7,7 @@ pkginclude_HEADERS= backend.h ccl.h cql.h comstack.h \
  readconf.h record_conv.h retrieval.h statserv.h \
  tcpip.h test.h unix.h tpath.h wrbuf.h xmalloc.h \
  yaz-ccl.h yaz-iconv.h yaz-util.h yaz-version.h yconfig.h proto.h \
  readconf.h record_conv.h retrieval.h statserv.h \
  tcpip.h test.h unix.h tpath.h wrbuf.h xmalloc.h \
  yaz-ccl.h yaz-iconv.h yaz-util.h yaz-version.h yconfig.h proto.h \
- xmlquery.h libxml2_error.h \
+ xmlquery.h libxml2_error.h xmltypes.h \
  \
  ill.h ill-core.h item-req.h z-accdes1.h z-accform1.h \
  z-acckrb1.h z-core.h z-date.h z-diag1.h z-espec1.h z-estask.h z-exp.h \
  \
  ill.h ill-core.h item-req.h z-accdes1.h z-accform1.h \
  z-acckrb1.h z-core.h z-date.h z-diag1.h z-espec1.h z-estask.h z-exp.h \
index 9c59961..97fad09 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: marcdisp.h,v 1.20 2006-12-07 11:08:04 adam Exp $ */
+/* $Id: marcdisp.h,v 1.21 2006-12-13 11:25:17 adam Exp $ */
 
 /**
  * \file marcdisp.h
 
 /**
  * \file marcdisp.h
@@ -38,6 +38,8 @@
 #include <stdio.h>
 #include <yaz/wrbuf.h>
 
 #include <stdio.h>
 #include <yaz/wrbuf.h>
 
+#include <yaz/xmltypes.h>
+
 YAZ_BEGIN_CDECL
 
 /** \brief a yaz_marc_t handle (private content) */
 YAZ_BEGIN_CDECL
 
 /** \brief a yaz_marc_t handle (private content) */
@@ -147,11 +149,11 @@ YAZ_EXPORT int yaz_marc_read_iso2709(yaz_marc_t mt,
 
 /** \brief parses MARCXML/MarcXchange record from xmlNode pointer 
     \param mt handle
 
 /** \brief parses MARCXML/MarcXchange record from xmlNode pointer 
     \param mt handle
-    \param xmlnode is a pointer to root xmlNode pointer 
+    \param ptr is a pointer to root xml node 
 
     Returns 0=OK, -1=ERROR
 */
 
     Returns 0=OK, -1=ERROR
 */
-YAZ_EXPORT int yaz_marc_read_xml(yaz_marc_t mt, const void *xmlnode);
+YAZ_EXPORT int yaz_marc_read_xml(yaz_marc_t mt, const xmlNode *ptr);
 
 /** \brief writes record in line format
     \param mt handle
 
 /** \brief writes record in line format
     \param mt handle
@@ -167,7 +169,6 @@ YAZ_EXPORT int yaz_marc_write_line(yaz_marc_t mt, WRBUF wrbuf);
 
     Sets leader[9]='a' . Returns 0=OK, -1=ERROR . 
 */
 
     Sets leader[9]='a' . Returns 0=OK, -1=ERROR . 
 */
-
 YAZ_EXPORT int yaz_marc_write_marcxml(yaz_marc_t mt, WRBUF wrbuf);
 
 /** \brief writes record in MarcXchange XML
 YAZ_EXPORT int yaz_marc_write_marcxml(yaz_marc_t mt, WRBUF wrbuf);
 
 /** \brief writes record in MarcXchange XML
index 4b5bf74..08eb524 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: nmem_xml.h,v 1.1 2006-10-27 12:19:15 adam Exp $ */
+/* $Id: nmem_xml.h,v 1.2 2006-12-13 11:25:17 adam Exp $ */
 
 /**
  * \file nmem_xml.h
 
 /**
  * \file nmem_xml.h
@@ -35,8 +35,7 @@
 
 #include <yaz/nmem.h>
 
 
 #include <yaz/nmem.h>
 
-#if YAZ_HAVE_XML2
-#include <libxml/parser.h>
+#include <yaz/xmltypes.h>
 
 YAZ_BEGIN_CDECL
 
 
 YAZ_BEGIN_CDECL
 
@@ -46,7 +45,6 @@ YAZ_EXPORT char *nmem_text_node_cdata(const xmlNode *ptr, NMEM nmem);
 YAZ_END_CDECL
 
 #endif
 YAZ_END_CDECL
 
 #endif
-#endif
 /*
  * Local variables:
  * c-basic-offset: 4
 /*
  * Local variables:
  * c-basic-offset: 4
index 07f9c90..b96046e 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: record_conv.h,v 1.6 2006-12-12 10:41:38 marc Exp $ */
+/* $Id: record_conv.h,v 1.7 2006-12-13 11:25:17 adam Exp $ */
 
 /**
  * \file record_conv.h
 
 /**
  * \file record_conv.h
@@ -37,6 +37,7 @@
 #include <stddef.h>
 #include <yaz/wrbuf.h>
 #include <yaz/yconfig.h>
 #include <stddef.h>
 #include <yaz/wrbuf.h>
 #include <yaz/yconfig.h>
+#include <yaz/xmltypes.h>
 
 YAZ_BEGIN_CDECL
 
 
 YAZ_BEGIN_CDECL
 
@@ -75,11 +76,9 @@ YAZ_EXPORT void yaz_record_conv_destroy(yaz_record_conv_t p);
       <xslt stylesheet="mods2dc.xsl"/>
     </backend>
     \endverbatim
       <xslt stylesheet="mods2dc.xsl"/>
     </backend>
     \endverbatim
-
-
 */
 YAZ_EXPORT
 */
 YAZ_EXPORT
-int yaz_record_conv_configure(yaz_record_conv_t p, const void *node);
+int yaz_record_conv_configure(yaz_record_conv_t p, const xmlNode *node);
 
 /** performs record conversion
     \param p record conversion handle
 
 /** performs record conversion
     \param p record conversion handle
index 22ba84b..e1cb75d 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: retrieval.h,v 1.6 2006-10-09 21:02:41 adam Exp $ */
+/* $Id: retrieval.h,v 1.7 2006-12-13 11:25:17 adam Exp $ */
 
 /**
  * \file retrieval.h
 
 /**
  * \file retrieval.h
@@ -82,7 +82,7 @@ YAZ_EXPORT void yaz_retrieval_destroy(yaz_retrieval_t p);
     \endverbatim
 */
 YAZ_EXPORT
     \endverbatim
 */
 YAZ_EXPORT
-int yaz_retrieval_configure(yaz_retrieval_t p, const void *node);
+int yaz_retrieval_configure(yaz_retrieval_t p, const xmlNode *node);
 
 
 /** performs retrieval request based on schema and format
 
 
 /** performs retrieval request based on schema and format
index 2e22a67..069dab8 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: xmlquery.h,v 1.7 2006-10-13 11:30:37 adam Exp $ */
+/* $Id: xmlquery.h,v 1.8 2006-12-13 11:25:17 adam Exp $ */
 
 /** \file xmlquery.h
     \brief Query / XML conversions
 
 /** \file xmlquery.h
     \brief Query / XML conversions
 #ifndef YAZ_XMLQUERY_H
 #define YAZ_XMLQUERY_H
 
 #ifndef YAZ_XMLQUERY_H
 #define YAZ_XMLQUERY_H
 
-#if YAZ_HAVE_XML2
 #include <yaz/yconfig.h>
 #include <yaz/proto.h>
 #include <yaz/yconfig.h>
 #include <yaz/proto.h>
-
-#include <libxml/parser.h>
+#include <yaz/xmltypes.h>
 
 YAZ_BEGIN_CDECL
 
 
 YAZ_BEGIN_CDECL
 
@@ -50,7 +48,6 @@ YAZ_EXPORT void yaz_xml2query(const void *xmlnodep, Z_Query **query, ODR odr,
 YAZ_END_CDECL
 
 #endif
 YAZ_END_CDECL
 
 #endif
-#endif
 
 /*
  * Local variables:
 
 /*
  * Local variables:
diff --git a/include/yaz/xmltypes.h b/include/yaz/xmltypes.h
new file mode 100644 (file)
index 0000000..7f14df7
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 1995-2006, Index Data
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Index Data nor the names of its contributors
+ *       may be used to endorse or promote products derived from this
+ *       software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/* $Id: xmltypes.h,v 1.1 2006-12-13 11:25:17 adam Exp $ */
+
+/**
+ * \file xmltypes.h
+ * \brief Define fundamental Libxml2 types for functions YAZ provide.
+ * \details If Libxml2 is not installed, we define dummy types instead.
+ */
+#ifndef YAZ_XMLTYPES_H
+#define YAZ_XMLTYPES_H
+
+#if YAZ_HAVE_XML2
+#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:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 173bc0f..ee75e70 100644 (file)
@@ -2,11 +2,11 @@
  * Copyright (C) 1995-2006, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2006, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: elementset.c,v 1.1 2006-11-14 08:48:26 adam Exp $
+ * $Id: elementset.c,v 1.2 2006-12-13 11:25:17 adam Exp $
  */
 /**
  */
 /**
- * \file tpath.c
- * \brief File Path utilities
+ * \file elementset.c
+ * \brief Z39.50 element set utilities
  */
 
 #if HAVE_CONFIG_H
  */
 
 #if HAVE_CONFIG_H
index 6c8a603..994c5a6 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2006, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2006, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: marcdisp.c,v 1.36 2006-12-07 11:08:05 adam Exp $
+ * $Id: marcdisp.c,v 1.37 2006-12-13 11:25:17 adam Exp $
  */
 
 /**
  */
 
 /**
@@ -956,10 +956,11 @@ static int yaz_marc_read_xml_fields(yaz_marc_t mt, const xmlNode *ptr)
         }
     return 0;
 }
         }
     return 0;
 }
+#endif
 
 
-int yaz_marc_read_xml(yaz_marc_t mt, const void *xmlnode)
+int yaz_marc_read_xml(yaz_marc_t mt, const xmlNode *ptr)
 {
 {
-    const xmlNode *ptr = xmlnode;
+#if YAZ_HAVE_XML2
     for(; ptr; ptr = ptr->next)
         if (ptr->type == XML_ELEMENT_NODE)
         {
     for(; ptr; ptr = ptr->next)
         if (ptr->type == XML_ELEMENT_NODE)
         {
@@ -983,13 +984,10 @@ int yaz_marc_read_xml(yaz_marc_t mt, const void *xmlnode)
     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
 #else
-int yaz_marc_read_xml(yaz_marc_t mt, const void *xmlnode)
-{
     return -1;
     return -1;
-}
 #endif
 #endif
+}
 
 int yaz_marc_read_iso2709(yaz_marc_t mt, const char *buf, int bsize)
 {
 
 int yaz_marc_read_iso2709(yaz_marc_t mt, const char *buf, int bsize)
 {
index bf148e9..086eec5 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 2005-2006, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 2005-2006, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: record_conv.c,v 1.12 2006-12-12 10:41:38 marc Exp $
+ * $Id: record_conv.c,v 1.13 2006-12-13 11:25:17 adam Exp $
  */
 /**
  * \file record_conv.c
  */
 /**
  * \file record_conv.c
@@ -339,10 +339,8 @@ static int conv_marc(yaz_record_conv_t p, const xmlNode *ptr)
     return 0;
 }
 
     return 0;
 }
 
-int yaz_record_conv_configure(yaz_record_conv_t p, const void *ptr_v)
+int yaz_record_conv_configure(yaz_record_conv_t p, const xmlNode *ptr)
 {
 {
-    const xmlNode *ptr = ptr_v; 
-
     yaz_record_conv_reset(p);
 
     /* parsing element children */
     yaz_record_conv_reset(p);
 
     /* parsing element children */
index eecea4c..32afd87 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 2005-2006, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 2005-2006, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: retrieval.c,v 1.13 2006-12-12 10:41:38 marc Exp $
+ * $Id: retrieval.c,v 1.14 2006-12-13 11:25:17 adam Exp $
  */
 /**
  * \file retrieval.c
  */
 /**
  * \file retrieval.c
@@ -234,10 +234,8 @@ static int conf_retrieval(yaz_retrieval_t p, const xmlNode *ptr)
     return 0;
 }
 
     return 0;
 }
 
-int yaz_retrieval_configure(yaz_retrieval_t p, const void *ptr_v)
+int yaz_retrieval_configure(yaz_retrieval_t p, const xmlNode *ptr)
 {
 {
-    const xmlNode *ptr = ptr_v; 
-
     yaz_retrieval_reset(p);
 
     if (ptr && ptr->type == XML_ELEMENT_NODE &&
     yaz_retrieval_reset(p);
 
     if (ptr && ptr->type == XML_ELEMENT_NODE &&