2 * Copyright (c) 1995-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Log: d1_varset.c,v $
7 * Revision 1.11 2002-04-04 20:49:46 adam
8 * New functions yaz_is_abspath, yaz_path_fopen_base
10 * Revision 1.10 1999/11/30 13:47:12 adam
11 * Improved installation. Moved header files to include/yaz.
13 * Revision 1.9 1999/08/27 09:40:32 adam
14 * Renamed logf function to yaz_log. Removed VC++ project files.
16 * Revision 1.8 1998/10/13 16:09:54 adam
17 * Added support for arbitrary OID's for tagsets, schemas and attribute sets.
18 * Added support for multiple attribute set references and tagset references
19 * from an abstract syntax file.
20 * Fixed many bad logs-calls in routines that read the various
21 * specifications regarding data1 (*.abs,*.att,...) and made the messages
22 * consistent whenever possible.
23 * Added extra 'lineno' argument to function readconf_line.
25 * Revision 1.7 1998/02/11 11:53:35 adam
26 * Changed code so that it compiles as C++.
28 * Revision 1.6 1997/09/17 12:10:39 adam
31 * Revision 1.5 1997/09/05 09:50:58 adam
32 * Removed global data1_tabpath - uses data1_get_tabpath() instead.
34 * Revision 1.4 1997/05/14 06:54:04 adam
37 * Revision 1.3 1995/11/01 16:34:58 quinn
38 * Making data1 look for tables in data1_tabpath
40 * Revision 1.2 1995/11/01 13:54:50 quinn
43 * Revision 1.1 1995/11/01 11:56:09 quinn
44 * Added Retrieval (data management) functions en masse.
54 #include <yaz/data1.h>
56 data1_vartype *data1_getvartypebyct (data1_handle dh, data1_varset *set,
57 char *zclass, char *type)
62 for (c = set->classes; c; c = c->next)
63 if (!data1_matchstr(c->name, zclass))
65 for (t = c->types; t; t = t->next)
66 if (!data1_matchstr(t->name, type))
68 yaz_log(LOG_WARN, "Unknown variant type %s in class %s",
72 yaz_log(LOG_WARN, "Unknown variant class %s", zclass);
76 data1_varset *data1_read_varset (data1_handle dh, const char *file)
78 NMEM mem = data1_nmem_get (dh);
79 data1_varset *res = (data1_varset *)nmem_malloc(mem, sizeof(*res));
80 data1_varclass **classp = &res->classes, *zclass = 0;
81 data1_vartype **typep = 0;
85 char *argv[50],line[512];
88 res->reference = VAL_NONE;
91 if (!(f = data1_path_fopen(dh, file, "r")))
93 yaz_log(LOG_WARN|LOG_ERRNO, "%s", file);
96 while ((argc = readconf_line(f, &lineno, line, 512, argv, 50)))
97 if (!strcmp(argv[0], "class"))
103 yaz_log(LOG_WARN, "%s:%d: Bad # or args to class",
107 *classp = r = zclass = (data1_varclass *)
108 nmem_malloc(mem, sizeof(*r));
110 r->zclass = atoi(argv[1]);
111 r->name = nmem_strdup(mem, argv[2]);
117 else if (!strcmp(argv[0], "type"))
123 yaz_log(LOG_WARN, "%s:%d: Directive class must precede type",
129 yaz_log(LOG_WARN, "%s:%d: Bad # or args to type",
133 *typep = r = (data1_vartype *)nmem_malloc(mem, sizeof(*r));
134 r->name = nmem_strdup(mem, argv[2]);
136 r->type = atoi(argv[1]);
137 if (!(r->datatype = data1_maptype (dh, argv[3])))
139 yaz_log(LOG_WARN, "%s:%d: Unknown datatype '%s'",
140 file, lineno, argv[3]);
147 else if (!strcmp(argv[0], "name"))
151 yaz_log(LOG_WARN, "%s:%d: Bad # args for name",
155 res->name = nmem_strdup(mem, argv[1]);
157 else if (!strcmp(argv[0], "reference"))
161 yaz_log(LOG_WARN, "%s:%d: Bad # args for reference",
165 if ((res->reference = oid_getvalbyname(argv[1])) == VAL_NONE)
167 yaz_log(LOG_WARN, "%s:%d: Unknown reference '%s'",
168 file, lineno, argv[1]);
173 yaz_log(LOG_WARN, "%s:%d: Unknown directive '%s'",
174 file, lineno, argv[0]);