2 * Copyright (c) 1995-1997, Index Data.
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation, in whole or in part, for any purpose, is hereby granted,
8 * 1. This copyright and permission notice appear in all copies of the
9 * software and its documentation. Notices of copyright or attribution
10 * which appear at the beginning of any file must remain unchanged.
12 * 2. The names of Index Data or the individual authors may not be used to
13 * endorse or promote products derived from this software without specific
14 * prior written permission.
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19 * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
20 * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
21 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
22 * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
27 * Revision 1.25 1997-09-05 09:50:55 adam
28 * Removed global data1_tabpath - uses data1_get_tabpath() instead.
30 * Revision 1.24 1997/09/01 09:30:39 adam
31 * Added include of yaz-util.h.
33 * Revision 1.23 1997/09/01 08:58:04 adam
34 * Removed declaration of data1_matchstr since it's a macro.
36 * Revision 1.22 1997/09/01 08:49:48 adam
37 * New windows NT/95 port using MSV5.0. To export DLL functions the
38 * YAZ_EXPORT modifier was added. Defined in yconfig.h.
40 * Revision 1.21 1997/05/14 06:53:38 adam
43 * Revision 1.20 1996/10/29 13:34:39 adam
44 * New functions to get/set data1_tabpath.
46 * Revision 1.19 1996/10/11 11:57:16 quinn
49 * Revision 1.18 1996/10/07 15:29:16 quinn
52 * Revision 1.17 1996/07/06 19:58:32 quinn
53 * System headerfiles gathered in yconfig
55 * Revision 1.16 1996/06/10 08:55:34 quinn
56 * Added Summary. Unfinished work
58 * Revision 1.15 1996/06/03 09:46:03 quinn
61 * Revision 1.14 1996/05/09 07:27:11 quinn
62 * Multiple local values supported.
64 * Revision 1.13 1996/02/20 16:32:48 quinn
67 * Revision 1.12 1996/01/18 09:46:34 adam
68 * Changed prototype for reader function parsed to data1_read_record.
70 * Revision 1.11 1995/12/15 16:19:45 quinn
71 * Added formatted_text.
73 * Revision 1.10 1995/12/14 11:09:43 quinn
76 * Revision 1.9 1995/12/13 15:32:47 quinn
79 * Revision 1.8 1995/12/13 13:44:23 quinn
80 * Modified Data1-system to use nmem
82 * Revision 1.7 1995/12/12 16:37:05 quinn
83 * Added destroy element to data1_node.
85 * Revision 1.6 1995/12/11 15:22:12 quinn
86 * Added last_child field to the node.
88 * Revision 1.5 1995/12/05 14:26:40 quinn
89 * Added global lbuf to data1_node.
91 * Revision 1.4 1995/11/13 09:27:29 quinn
92 * Fiddling with the variant stuff.
94 * Revision 1.3 1995/11/01 16:34:52 quinn
95 * Making data1 look for tables in data1_tabpath
97 * Revision 1.2 1995/11/01 13:54:35 quinn
100 * Revision 1.1 1995/11/01 13:07:18 quinn
101 * Data1 module now lives in YAZ.
103 * Revision 1.13 1995/10/25 16:00:49 quinn
104 * USMARC support is now almost operational
106 * Revision 1.12 1995/10/16 14:02:59 quinn
107 * Changes to support element set names and espec1
109 * Revision 1.11 1995/10/13 16:05:10 quinn
110 * Adding Espec1-processing
112 * Revision 1.10 1995/10/11 14:53:46 quinn
115 * Revision 1.9 1995/10/10 16:27:59 quinn
116 * *** empty log message ***
118 * Revision 1.8 1995/10/06 16:44:14 quinn
119 * Work on attribute set mapping, etc.
121 * Revision 1.7 1995/10/06 12:58:36 quinn
124 * Revision 1.6 1995/10/04 09:29:51 quinn
125 * Adjustments to support USGS test data
127 * Revision 1.5 1995/10/03 17:56:44 quinn
130 * Revision 1.4 1995/10/02 14:55:43 quinn
131 * *** empty log message ***
133 * Revision 1.3 1995/09/15 14:41:43 quinn
136 * Revision 1.2 1995/09/14 15:18:14 quinn
139 * Revision 1.1 1995/09/12 11:24:33 quinn
140 * Beginning to add code for structured records.
154 #include <d1_attset.h>
156 #include <yaz-util.h>
162 #define data1_matchstr(s1, s2) yaz_matchstr(s1, s2)
164 #define DATA1_MAX_SYMBOL 31
166 typedef struct data1_name
169 struct data1_name *next;
172 typedef enum data1_datatype
174 DATA1K_structured = 1,
179 DATA1K_generalizedtime,
186 typedef enum data1_structure
192 typedef struct data1_marctab
197 char record_status[2];
198 char implementation_codes[5];
199 int indicator_length;
200 int identifier_length;
201 char user_systems[4];
203 int length_data_entry;
205 int length_implementation;
208 struct data1_marctab *next;
211 typedef struct data1_esetname
215 struct data1_esetname *next;
219 * Variant set definitions.
222 typedef struct data1_vartype
225 struct data1_varclass *zclass;
227 data1_datatype datatype;
228 struct data1_vartype *next;
231 typedef struct data1_varclass
234 struct data1_varset *set;
236 data1_vartype *types;
237 struct data1_varclass *next;
240 typedef struct data1_varset
244 data1_varclass *classes;
253 typedef struct data1_tag
256 #define DATA1T_numeric 1
257 #define DATA1T_string 2
266 struct data1_tagset *tagset;
267 struct data1_tag *next;
270 typedef struct data1_tagset
272 char *name; /* symbolic name */
274 int type; /* type of tagset in current context */
275 data1_tag *tags; /* tags defined by this set */
276 struct data1_tagset *children; /* included tagsets */
277 struct data1_tagset *next; /* sibling */
280 typedef struct data1_termlist
283 data1_structure structure;
284 struct data1_termlist *next;
288 * abstract syntax specification
291 typedef struct data1_element
295 data1_termlist *termlists;
296 struct data1_element *parent;
297 struct data1_element *children;
298 struct data1_element *next;
301 typedef struct data1_absyn
305 data1_tagset *tagset;
306 data1_attset *attset;
307 data1_varset *varset;
308 data1_esetname *esetnames;
309 data1_maptab *maptabs;
311 data1_element *elements;
315 * record data node (tag/data/variant)
318 typedef struct data1_node
320 /* the root of a record (containing global data) */
321 #define DATA1N_root 1
324 /* some data under a leaf tag or variant */
325 #define DATA1N_data 3
326 /* variant specification (a triple, actually) */
327 #define DATA1N_variant 4
335 data1_absyn *absyn; /* abstract syntax for this type */
341 data1_element *element;
343 int make_variantlist;
344 int no_data_requested;
351 #define DATA1I_inctxt 1
352 /* binary data inclusion */
353 #define DATA1I_incbin 2
355 #define DATA1I_text 3
358 /* object identifier */
361 int formatted_text; /* newlines are significant */
363 char *data; /* filename or data */
364 #define DATA1_LOCALDATA 40
365 char lbuf[DATA1_LOCALDATA]; /* small buffer for local data */
380 void (*destroy)(struct data1_node *n);
381 char lbuf[DATA1_LOCALDATA]; /* small buffer for local data */
384 struct data1_node *next;
385 struct data1_node *child;
386 struct data1_node *last_child;
387 struct data1_node *parent;
388 struct data1_node *root;
391 YAZ_EXPORT data1_node *get_parent_tag(data1_node *n);
392 YAZ_EXPORT data1_node *data1_read_node(char **buf, data1_node *parent,
393 int *line, data1_absyn *absyn, NMEM m);
394 YAZ_EXPORT data1_node *data1_read_record(int (*rf)(void *, char *, size_t),
396 YAZ_EXPORT data1_absyn *data1_read_absyn(char *file);
397 YAZ_EXPORT data1_tag *data1_gettagbynum(data1_tagset *s, int type, int value);
398 YAZ_EXPORT data1_tagset *data1_read_tagset(char *file);
399 YAZ_EXPORT data1_element *data1_getelementbytagname(data1_absyn *abs,
400 data1_element *parent,
402 YAZ_EXPORT Z_GenericRecord *data1_nodetogr(data1_node *n, int select, ODR o,
404 YAZ_EXPORT data1_tag *data1_gettagbyname(data1_tagset *s, char *name);
405 YAZ_EXPORT void data1_free_tree(data1_node *t);
406 YAZ_EXPORT char *data1_nodetobuf(data1_node *n, int select, int *len);
407 YAZ_EXPORT data1_node *data1_insert_taggeddata(data1_node *root,
409 char *tagname, NMEM m);
410 YAZ_EXPORT data1_datatype data1_maptype(char *t);
411 YAZ_EXPORT data1_varset *data1_read_varset(char *file);
412 YAZ_EXPORT data1_vartype *data1_getvartypebyct(data1_varset *set,
413 char *zclass, char *type);
414 YAZ_EXPORT Z_Espec1 *data1_read_espec1(char *file, ODR o);
415 YAZ_EXPORT int data1_doespec1(data1_node *n, Z_Espec1 *e);
416 YAZ_EXPORT data1_esetname *data1_getesetbyname(data1_absyn *a, char *name);
417 YAZ_EXPORT data1_element *data1_getelementbyname(data1_absyn *absyn,
419 YAZ_EXPORT data1_node *data1_mk_node(NMEM m);
420 YAZ_EXPORT data1_absyn *data1_get_absyn(char *name);
421 YAZ_EXPORT data1_maptab *data1_read_maptab(char *file);
422 YAZ_EXPORT data1_node *data1_map_record(data1_node *n, data1_maptab *map,
424 YAZ_EXPORT data1_marctab *data1_read_marctab(char *file);
425 YAZ_EXPORT char *data1_nodetomarc(data1_marctab *p, data1_node *n,
426 int selected, int *len);
427 YAZ_EXPORT char *data1_nodetoidsgml(data1_node *n, int select, int *len);
428 YAZ_EXPORT Z_ExplainRecord *data1_nodetoexplain(data1_node *n, int select,
430 YAZ_EXPORT Z_BriefBib *data1_nodetosummary(data1_node *n, int select,
432 YAZ_EXPORT char *data1_nodetosoif(data1_node *n, int select,
434 YAZ_EXPORT void data1_set_tabpath(const char *path);
435 YAZ_EXPORT const char *data1_get_tabpath(void);