1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2010 Index Data
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
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
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
24 #include <idzebra/data1.h>
26 #define DATA1_FLAG_XML 1
28 struct data1_handle_info {
36 data1_absyn_cache absyn_cache;
37 data1_attset_cache attset_cache;
45 data1_handle data1_create(void)
47 data1_handle p = (data1_handle)xmalloc (sizeof(*p));
52 p->wrbuf = wrbuf_alloc();
57 p->absyn_cache = NULL;
58 p->attset_cache = NULL;
59 p->mem = nmem_create ();
63 NMEM data1_nmem_get (data1_handle dh)
68 data1_absyn_cache *data1_absyn_cache_get (data1_handle dh)
70 return &dh->absyn_cache;
73 data1_attset_cache *data1_attset_cache_get (data1_handle dh)
75 return &dh->attset_cache;
78 void data1_destroy (data1_handle dh)
84 We need to destroy DFAs, in xp_element (xelm) definitions
87 data1_absyn_destroy(dh);
89 wrbuf_destroy(dh->wrbuf);
98 nmem_destroy (dh->mem);
103 WRBUF data1_get_wrbuf (data1_handle dp)
108 char **data1_get_read_buf (data1_handle dp, int **lenp)
110 *lenp = &dp->read_len;
111 yaz_log (YLOG_DEBUG, "data1_get_read_buf lenp=%u", **lenp);
112 return &dp->read_buf;
115 char **data1_get_map_buf (data1_handle dp, int **lenp)
117 *lenp = &dp->map_len;
118 yaz_log (YLOG_DEBUG, "data1_get_map_buf lenp=%u", **lenp);
122 void data1_set_tabpath (data1_handle dp, const char *p)
124 xfree (dp->tab_path);
127 dp->tab_path = xstrdup (p);
130 void data1_set_tabroot (data1_handle dp, const char *p)
132 xfree (dp->tab_root);
135 dp->tab_root = xstrdup (p);
138 const char *data1_get_tabpath (data1_handle dp)
143 const char *data1_get_tabroot (data1_handle dp)
148 FILE *data1_path_fopen (data1_handle dh, const char *file, const char *mode)
151 const char *path = data1_get_tabpath(dh);
152 const char *root = data1_get_tabroot(dh);
154 yaz_log(YLOG_DEBUG, "data1_path_fopen path=%s root=%s "
155 "file=%s mode=%s", path ? path : "NULL",
156 root ? root : "NULL", file, mode);
159 f = yaz_fopen(path, file, mode, root);
162 yaz_log(YLOG_WARN|YLOG_ERRNO, "Couldn't open %s", file);
164 yaz_log(YLOG_LOG, "for root=%s", root);
166 yaz_log(YLOG_LOG, "for profilePath=%s", path);
171 int data1_is_xmlmode(data1_handle dh)
178 * c-file-style: "Stroustrup"
179 * indent-tabs-mode: nil
181 * vim: shiftwidth=4 tabstop=8 expandtab