From 1aac63eecd76d5d060da84037a355c153d747ca7 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 19 Jan 2010 09:45:06 +0100 Subject: [PATCH] Remove redundant function libxml2_error_to_yazlog Function libxml2_error_to_yazlog is redundant and not in used by applications other than YAZ itself. yaz_log_xml_errors does the same - and is used at least by Pazpar2. --- include/yaz/Makefile.am | 2 +- include/yaz/libxml2_error.h | 61 ----------------------------------------- src/Makefile.am | 2 +- src/libxml2_error.c | 63 ------------------------------------------- test/tst_record_conv.c | 2 +- test/tst_retrieval.c | 2 +- win/makefile | 1 - 7 files changed, 4 insertions(+), 129 deletions(-) delete mode 100644 include/yaz/libxml2_error.h delete mode 100644 src/libxml2_error.c diff --git a/include/yaz/Makefile.am b/include/yaz/Makefile.am index 0c10a06..246dbd8 100644 --- a/include/yaz/Makefile.am +++ b/include/yaz/Makefile.am @@ -10,7 +10,7 @@ pkginclude_HEADERS= backend.h ccl.h ccl_xml.h cql.h rpn2cql.h comstack.h \ readconf.h record_conv.h retrieval.h statserv.h \ tcpip.h test.h timing.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 xmltypes.h snprintf.h query-charset.h \ + xmlquery.h xmltypes.h snprintf.h query-charset.h \ mutex.h oid_db.h oid_util.h oid_std.h tokenizer.h copy_types.h \ icu.h match_glob.h poll.h daemon.h sc.h \ \ diff --git a/include/yaz/libxml2_error.h b/include/yaz/libxml2_error.h deleted file mode 100644 index d3b9a64..0000000 --- a/include/yaz/libxml2_error.h +++ /dev/null @@ -1,61 +0,0 @@ -/* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2010 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. - */ - -/** - * \file libxml2_error.h - * \brief Libxml2 error handler - */ - -#ifndef YAZ_LIBXML2_ERROR_H -#define YAZ_LIBXML2_ERROR_H - -#include -#include - -YAZ_BEGIN_CDECL - -/** \brief direct Libxml2/Libxslt errors to yaz_log - \param level yaz_log level to use - \param lead_msg leading message (or NULL if none) - \retval 0 successful; libxml2 is present - \retval -1 failure; libxml2 is not present -*/ -YAZ_EXPORT -int libxml2_error_to_yazlog(int level, const char *lead_msg); - -YAZ_END_CDECL - -#endif -/* - * Local variables: - * c-basic-offset: 4 - * c-file-style: "Stroustrup" - * indent-tabs-mode: nil - * End: - * vim: shiftwidth=4 tabstop=8 expandtab - */ - diff --git a/src/Makefile.am b/src/Makefile.am index 2e8107d..23eeeef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -82,7 +82,7 @@ libyaz_la_SOURCES=version.c options.c log.c \ odr_null.c ber_null.c odr_int.c ber_int.c odr_tag.c odr_cons.c \ odr_seq.c odr_oct.c ber_oct.c odr_bit.c ber_bit.c odr_oid.c \ ber_oid.c odr_use.c odr_choice.c odr_any.c ber_any.c odr.c odr_mem.c \ - dumpber.c odr_enum.c odr-priv.h libxml2_error.c \ + dumpber.c odr_enum.c odr-priv.h \ comstack.c tcpip.c waislen.c unix.c \ prt-ext.c \ ill-get.c \ diff --git a/src/libxml2_error.c b/src/libxml2_error.c deleted file mode 100644 index 332c7af..0000000 --- a/src/libxml2_error.c +++ /dev/null @@ -1,63 +0,0 @@ -/* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2010 Index Data - * See the file LICENSE for details. - */ -/** - * \file libxml2_error.c - * \brief Libxml2 error handling - */ - -#include -#include -#include -#include -#include - -#if YAZ_HAVE_XML2 -#include -#endif - -#if YAZ_HAVE_XSLT -#include -#endif - -static int libxml2_error_level = 0; - -#if YAZ_HAVE_XML2 -static void proxy_xml_error_handler(void *ctx, const char *fmt, ...) -{ - char buf[1024]; - - va_list ap; - va_start(ap, fmt); - - yaz_vsnprintf(buf, sizeof(buf)-1, fmt, ap); - yaz_log(libxml2_error_level, "%s: %s", (char*) ctx, buf); - - 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 - return 0; -#else - return -1; -#endif -} - -/* - * Local variables: - * c-basic-offset: 4 - * c-file-style: "Stroustrup" - * indent-tabs-mode: nil - * End: - * vim: shiftwidth=4 tabstop=8 expandtab - */ - diff --git a/test/tst_record_conv.c b/test/tst_record_conv.c index d1d1659..a8411f2 100644 --- a/test/tst_record_conv.c +++ b/test/tst_record_conv.c @@ -334,7 +334,7 @@ static void tst_convert2(void) int main(int argc, char **argv) { YAZ_CHECK_INIT(argc, argv); - libxml2_error_to_yazlog(0 /* disable log */, 0); + yaz_log_xml_errors(0, 0 /* disable log */); #if YAZ_HAVE_XML2 tst_configure(); #endif diff --git a/test/tst_retrieval.c b/test/tst_retrieval.c index 71b085d..febc71d 100644 --- a/test/tst_retrieval.c +++ b/test/tst_retrieval.c @@ -316,7 +316,7 @@ int main(int argc, char **argv) { YAZ_CHECK_INIT(argc, argv); - libxml2_error_to_yazlog(0 /* disable it */, ""); + yaz_log_xml_errors(0, 0 /* disable it */); #if YAZ_HAVE_XSLT tst_configure(); diff --git a/win/makefile b/win/makefile index 1f26ef2..3815beb 100644 --- a/win/makefile +++ b/win/makefile @@ -444,7 +444,6 @@ MISC_OBJS= \ $(OBJDIR)\iso5426.obj \ $(OBJDIR)\record_conv.obj \ $(OBJDIR)\retrieval.obj \ - $(OBJDIR)\libxml2_error.obj \ $(OBJDIR)\test.obj \ $(OBJDIR)\diagbib1.obj \ $(OBJDIR)\diagsru_update.obj \ -- 1.7.10.4