Fix mistake: fuzzy matching is 5=103, not 5=102
[yaz-moved-to-github.git] / src / libxml2_error.c
1 /*
2  * Copyright (C) 2006, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: libxml2_error.c,v 1.1 2006-05-07 17:45:41 adam Exp $
6  */
7 /**
8  * \file libxml2_error.c
9  * \brief Libxml2 error handling
10  */
11
12 #include <stdlib.h>
13 #include <stdarg.h>
14 #include <yaz/log.h>
15 #include <yaz/libxml2_error.h>
16
17 #if HAVE_XML2
18 #include <libxml/xmlerror.h>
19 #endif
20
21 #if HAVE_XSLT
22 #include <libxslt/xsltutils.h>
23 #endif
24
25 static int libxml2_error_level = 0;
26
27 static void proxy_xml_error_handler(void *ctx, const char *fmt, ...)
28 {
29     char buf[1024];
30
31     va_list ap;
32     va_start(ap, fmt);
33
34 #ifdef WIN32
35     vsprintf(buf, fmt, ap);
36 #else
37     vsnprintf(buf, sizeof(buf), fmt, ap);
38 #endif
39     yaz_log(libxml2_error_level, "%s: %s", (char*) ctx, buf);
40
41     va_end (ap);
42 }
43
44 int libxml2_error_to_yazlog(int level, const char *lead_msg)
45 {
46     libxml2_error_level = level;
47 #if HAVE_XSLT
48     xsltSetGenericErrorFunc((void *) "XSLT", proxy_xml_error_handler);
49 #endif
50 #if HAVE_XML2
51     xmlSetGenericErrorFunc((void *) "XML", proxy_xml_error_handler);
52     return 0;
53 #else
54     return -1;
55 #endif
56 }
57
58 /*
59  * Local variables:
60  * c-basic-offset: 4
61  * indent-tabs-mode: nil
62  * End:
63  * vim: shiftwidth=4 tabstop=8 expandtab
64  */
65