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
23 #include <yaz/oid_db.h>
27 data1_vartype *data1_getvartypebyct (data1_handle dh, data1_varset *set,
28 const char *zclass, const char *type)
33 for (c = set->classes; c; c = c->next)
34 if (!data1_matchstr(c->name, zclass))
36 for (t = c->types; t; t = t->next)
37 if (!data1_matchstr(t->name, type))
39 yaz_log(YLOG_WARN, "Unknown variant type %s in class %s",
43 yaz_log(YLOG_WARN, "Unknown variant class %s", zclass);
47 data1_vartype *data1_getvartypeby_absyn (data1_handle dh, data1_absyn *absyn,
48 char *zclass, char *type)
50 return data1_getvartypebyct(dh, absyn->varset, zclass, type);
53 data1_varset *data1_read_varset (data1_handle dh, const char *file)
55 NMEM mem = data1_nmem_get (dh);
56 data1_varset *res = (data1_varset *)nmem_malloc(mem, sizeof(*res));
57 data1_varclass **classp = &res->classes, *zclass = 0;
58 data1_vartype **typep = 0;
62 char *argv[50],line[512];
68 if (!(f = data1_path_fopen(dh, file, "r")))
70 yaz_log(YLOG_WARN|YLOG_ERRNO, "%s", file);
73 while ((argc = readconf_line(f, &lineno, line, 512, argv, 50)))
74 if (!strcmp(argv[0], "class"))
80 yaz_log(YLOG_WARN, "%s:%d: Bad # or args to class",
84 *classp = r = zclass = (data1_varclass *)
85 nmem_malloc(mem, sizeof(*r));
87 r->zclass = atoi(argv[1]);
88 r->name = nmem_strdup(mem, argv[2]);
94 else if (!strcmp(argv[0], "type"))
100 yaz_log(YLOG_WARN, "%s:%d: Directive class must precede type",
106 yaz_log(YLOG_WARN, "%s:%d: Bad # or args to type",
110 *typep = r = (data1_vartype *)nmem_malloc(mem, sizeof(*r));
111 r->name = nmem_strdup(mem, argv[2]);
113 r->type = atoi(argv[1]);
114 if (!(r->datatype = data1_maptype (dh, argv[3])))
116 yaz_log(YLOG_WARN, "%s:%d: Unknown datatype '%s'",
117 file, lineno, argv[3]);
124 else if (!strcmp(argv[0], "name"))
128 yaz_log(YLOG_WARN, "%s:%d: Bad # args for name",
132 res->name = nmem_strdup(mem, argv[1]);
134 else if (!strcmp(argv[0], "reference"))
138 yaz_log(YLOG_WARN, "%s:%d: Bad # args for reference",
142 res->oid = yaz_string_to_oid_nmem(yaz_oid_std(),
143 CLASS_VARSET, argv[1], mem);
146 yaz_log(YLOG_WARN, "%s:%d: Unknown reference '%s'",
147 file, lineno, argv[1]);
152 yaz_log(YLOG_WARN, "%s:%d: Unknown directive '%s'",
153 file, lineno, argv[0]);
161 * c-file-style: "Stroustrup"
162 * indent-tabs-mode: nil
164 * vim: shiftwidth=4 tabstop=8 expandtab