Bump copyright year
[idzebra-moved-to-github.git] / test / xslt / xslt5.c
1 /* This file is part of the Zebra server.
2    Copyright (C) 2004-2013 Index Data
3
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 */
19
20 #if HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23 #include <stdio.h>
24 #include "testlib.h"
25
26 #if YAZ_HAVE_XML2
27 #include <libxml/xmlversion.h>
28 #endif
29
30 static void tst(int argc, char **argv)
31 {
32     char path[256];
33     char profile_path[256];
34     char record_buf[20000];
35     FILE *f;
36     size_t r;
37
38     ZebraService zs = tl_start_up(0, argc, argv);
39     ZebraHandle  zh = zebra_open(zs, 0);
40
41     tl_check_filter(zs, "alvis");
42
43     YAZ_CHECK_EQ(zebra_select_database(zh, "Default"), ZEBRA_OK);
44
45     zebra_init(zh);
46
47     sprintf(profile_path, "%s:%s/../../tab",
48             tl_get_srcdir(), tl_get_srcdir());
49     zebra_set_resource(zh, "profilePath", profile_path);
50
51     zebra_set_resource(zh, "recordType", "alvis.marcschema-one.xml");
52
53     sprintf(path, "%.200s/marc-missing-ns.xml", tl_get_srcdir());
54     f = fopen(path, "rb");
55     YAZ_CHECK(f);
56     if (f)
57     {
58         r = fread(record_buf, 1, sizeof(record_buf)-1, f);
59         YAZ_CHECK(r > 0);
60         fclose(f);
61         YAZ_CHECK(r > 2);
62         record_buf[r] = '\0';
63
64 #if 0
65 /* disable this test for now: bug #730 */
66 /* http://xmlsoft.org/html/libxml-parser.html#xmlReadIO */
67 #if YAZ_HAVE_XML2
68         /* On Mac OSX using Libxml 2.6.16, we xmlTextReaderExpand does
69            not return 0 ptr even though the record has an error in it */
70 #if LIBXML_VERSION >= 20617
71         YAZ_CHECK_EQ(zebra_add_record(zh, record_buf, strlen(record_buf)),
72                      ZEBRA_FAIL);
73 #else
74         zebra_add_record(zh, record_buf, strlen(record_buf));
75 #endif
76 #endif
77 #endif
78     }
79     YAZ_CHECK(tl_close_down(zh, zs));
80 }
81
82 TL_MAIN
83
84 /*
85  * Local variables:
86  * c-basic-offset: 4
87  * c-file-style: "Stroustrup"
88  * indent-tabs-mode: nil
89  * End:
90  * vim: shiftwidth=4 tabstop=8 expandtab
91  */
92