Implemented FilterFrontendNet which is a network server based on
[metaproxy-moved-to-github.git] / src / p2_xmlerror.cpp
1 /* $Id: p2_xmlerror.cpp,v 1.2 2005-10-08 23:29:32 adam Exp $
2    Copyright (c) 1998-2005, Index Data.
3
4 This file is part of the yaz-proxy.
5
6 YAZ proxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with YAZ proxy; see the file LICENSE.  If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.
20  */
21
22 #include "config.hpp"
23 #include <stdio.h>
24 #include <string.h>
25 #include <yaz/log.h>
26
27 #include "p2_xmlerror.h"
28
29 #if HAVE_XSLT
30 #include <libxml/parser.h>
31 #include <libxslt/xsltutils.h>
32 #endif
33
34 #if HAVE_XSLT
35 static void p2_xml_error_handler(void *ctx, const char *fmt, ...)
36 {
37     char buf[1024];
38     size_t sz;
39
40     va_list ap;
41     va_start(ap, fmt);
42
43 #ifdef WIN32
44     vsprintf(buf, fmt, ap);
45 #else
46     vsnprintf(buf, sizeof(buf), fmt, ap);
47 #endif
48     sz = strlen(buf);
49     if (sz > 0 && buf[sz-1] == '\n')
50         buf[sz-1] = '\0';
51         
52     yaz_log(YLOG_WARN, "%s: %s", (char*) ctx, buf);
53
54     va_end (ap);
55 }
56 #endif
57
58 void p2_xmlerror_setup()
59 {
60 #if HAVE_XSLT
61     xmlSetGenericErrorFunc((void *) "XML", p2_xml_error_handler);
62     xsltSetGenericErrorFunc((void *) "XSLT", p2_xml_error_handler);
63 #endif
64 }
65 /*
66  * Local variables:
67  * c-basic-offset: 4
68  * indent-tabs-mode: nil
69  * End:
70  * vim: shiftwidth=4 tabstop=8 expandtab
71  */