1 /* $Id: d1_handle.c,v 1.6 2004-12-13 20:51:28 adam Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
27 #include <idzebra/data1.h>
29 struct data1_handle_info {
37 data1_absyn_cache absyn_cache;
38 data1_attset_cache attset_cache;
47 data1_handle data1_create (void)
49 return data1_createx(0);
52 data1_handle data1_createx (int flags)
54 data1_handle p = (data1_handle)xmalloc (sizeof(*p));
59 p->wrbuf = wrbuf_alloc();
64 p->absyn_cache = NULL;
65 p->attset_cache = NULL;
66 p->mem = nmem_create ();
71 NMEM data1_nmem_get (data1_handle dh)
76 data1_absyn_cache *data1_absyn_cache_get (data1_handle dh)
78 return &dh->absyn_cache;
81 data1_attset_cache *data1_attset_cache_get (data1_handle dh)
83 return &dh->attset_cache;
86 void data1_destroy (data1_handle dh)
92 We need to destroy DFAs, in xp_element (xelm) definitions
95 data1_absyn_destroy(dh);
97 wrbuf_free (dh->wrbuf, 1);
101 xfree (dh->tab_root);
103 xfree (dh->read_buf);
106 nmem_destroy (dh->mem);
111 WRBUF data1_get_wrbuf (data1_handle dp)
116 char **data1_get_read_buf (data1_handle dp, int **lenp)
118 *lenp = &dp->read_len;
119 yaz_log (YLOG_DEBUG, "data1_get_read_buf lenp=%u", **lenp);
120 return &dp->read_buf;
123 char **data1_get_map_buf (data1_handle dp, int **lenp)
125 *lenp = &dp->map_len;
126 yaz_log (YLOG_DEBUG, "data1_get_map_buf lenp=%u", **lenp);
130 void data1_set_tabpath (data1_handle dp, const char *p)
132 xfree (dp->tab_path);
135 dp->tab_path = xstrdup (p);
138 void data1_set_tabroot (data1_handle dp, const char *p)
140 xfree (dp->tab_root);
143 dp->tab_root = xstrdup (p);
146 const char *data1_get_tabpath (data1_handle dp)
151 const char *data1_get_tabroot (data1_handle dp)
156 FILE *data1_path_fopen (data1_handle dh, const char *file, const char *mode)
158 const char *path = data1_get_tabpath(dh);
159 const char *root = data1_get_tabroot(dh);
160 return yaz_fopen (path, file, "r", root);
163 int data1_is_xmlmode(data1_handle dh)
165 return dh->flags & DATA1_FLAG_XML;