2 * Copyright (C) 1994-2001, Index Data
6 * Revision 1.45 2002-04-12 14:40:42 adam
9 * Revision 1.44 2002/04/11 20:09:47 adam
10 * work on string tag indexing
12 * Revision 1.43 2002/03/21 23:06:36 adam
13 * Source 'tag' in abs-file
15 * Revision 1.42 2002/02/20 17:30:01 adam
16 * Work on new API. Locking system re-implemented
18 * Revision 1.41 2001/05/22 21:01:47 adam
19 * Removed print of data1 tree on stdout so that inetd works again.
21 * Revision 1.40 2001/03/29 21:31:31 adam
22 * Fixed "record begin" for Tcl filter.
24 * Revision 1.39 2000/12/05 19:09:15 adam
25 * Fixed problem where indexer could crash if abstract syntax was undefined.
27 * Revision 1.38 2000/12/05 14:44:58 adam
28 * Fixed minor bug that could cause zmbol to break it data were emitted
29 * with not parent tags.
31 * Revision 1.37 2000/12/05 12:22:53 adam
32 * Termlist source implemented (so that we can index values of XML/SGML
35 * Revision 1.36 2000/12/05 10:01:44 adam
36 * Fixed bug regarding user-defined attribute sets.
38 * Revision 1.35 2000/11/29 15:21:31 adam
39 * Fixed problem with passwd db.
41 * Revision 1.34 2000/02/25 13:24:49 adam
42 * Fixed bug regarding pointer conversion that showed up on OSF V5.
44 * Revision 1.33 1999/11/30 13:48:04 adam
45 * Improved installation. Updated for inclusion of YAZ header files.
47 * Revision 1.32 1999/09/07 07:19:21 adam
48 * Work on character mapping. Implemented replace rules.
50 * Revision 1.31 1999/07/14 10:56:43 adam
51 * Fixed potential memory leak.
53 * Revision 1.30 1999/07/06 12:26:41 adam
54 * Retrieval handler obeys schema and handles XML transfer syntax.
56 * Revision 1.29 1999/05/26 07:49:14 adam
59 * Revision 1.28 1999/05/21 12:00:17 adam
60 * Better diagnostics for extraction process.
62 * Revision 1.27 1999/05/20 12:57:18 adam
63 * Implemented TCL filter. Updated recctrl system.
65 * Revision 1.26 1999/03/02 16:15:44 quinn
66 * Added "tagsysno" and "tagrank" directives to zebra.cfg.
68 * Revision 1.25 1999/02/18 15:01:26 adam
71 * Revision 1.24 1999/02/02 14:51:28 adam
72 * Updated WIN32 code specific sections. Changed header.
74 * Revision 1.23 1998/10/18 07:51:10 adam
75 * Changed one logf call.
77 * Revision 1.22 1998/10/16 08:14:37 adam
78 * Updated record control system.
80 * Revision 1.21 1998/07/01 09:16:10 adam
81 * Element localno only added when it's greater than 0.
83 * Revision 1.20 1998/05/20 10:12:26 adam
84 * Implemented automatic EXPLAIN database maintenance.
85 * Modified Zebra to work with ASN.1 compiled version of YAZ.
87 * Revision 1.19 1998/03/11 11:19:05 adam
88 * Changed the way sequence numbers are generated.
90 * Revision 1.18 1998/03/05 08:41:31 adam
93 * Revision 1.17 1998/02/10 12:03:06 adam
96 * Revision 1.16 1998/01/29 13:38:17 adam
97 * Fixed problem with mapping to record with unknown schema.
99 * Revision 1.15 1998/01/26 10:37:57 adam
100 * Better diagnostics.
102 * Revision 1.14 1997/11/06 11:41:01 adam
103 * Implemented "begin variant" for the sgml.regx filter.
105 * Revision 1.13 1997/10/31 12:35:44 adam
106 * Added a few log statements.
108 * Revision 1.12 1997/10/29 12:02:22 adam
109 * Using oid_ent_to_oid used instead of the non thread-safe oid_getoidbyent.
111 * Revision 1.11 1997/10/27 14:34:00 adam
112 * Work on generic character mapping depending on "structure" field
113 * in abstract syntax file.
115 * Revision 1.10 1997/09/18 08:59:21 adam
116 * Extra generic handle for the character mapping routines.
118 * Revision 1.9 1997/09/17 12:19:21 adam
119 * Zebra version corresponds to YAZ version 1.4.
120 * Changed Zebra server so that it doesn't depend on global common_resource.
122 * Revision 1.8 1997/09/09 13:38:14 adam
123 * Partial port to WIN95/NT.
125 * Revision 1.7 1997/09/05 15:30:10 adam
126 * Changed prototype for chr_map_input - added const.
127 * Added support for C++, headers uses extern "C" for public definitions.
129 * Revision 1.6 1997/09/04 13:54:40 adam
130 * Added MARC filter - type grs.marc.<syntax> where syntax refers
131 * to abstract syntax. New method tellf in retrieve/extract method.
133 * Revision 1.5 1997/07/15 16:29:03 adam
134 * Initialized dummy variable to keep checker gcc happy.
136 * Revision 1.4 1997/04/30 08:56:08 quinn
139 * Revision 1.2 1996/10/11 16:06:43 quinn
140 * Revision 1.3 1997/02/24 10:41:50 adam
141 * Cleanup of code and commented out the "end element-end-record" code.
143 * Revision 1.2 1996/10/11 16:06:43 quinn
144 * Fixed arguments to nodetogr
146 * Revision 1.1 1996/10/11 10:57:25 adam
147 * New module recctrl. Used to manage records (extract/retrieval).
149 * Revision 1.29 1996/10/08 10:30:21 quinn
150 * Fixed type mismatch
152 * Revision 1.28 1996/10/07 16:06:40 quinn
155 * Revision 1.27 1996/06/11 10:54:12 quinn
158 * Revision 1.26 1996/06/06 12:08:45 quinn
159 * Added showRecord function
161 * Revision 1.25 1996/06/04 14:18:53 quinn
164 * Revision 1.24 1996/06/04 13:27:54 quinn
165 * More work on charmapping
167 * Revision 1.23 1996/06/04 10:19:01 adam
168 * Minor changes - removed include of ctype.h.
170 * Revision 1.22 1996/06/03 10:15:27 quinn
171 * Various character-mapping.
173 * Revision 1.21 1996/05/31 13:27:24 quinn
174 * Character-conversion in phrases, too.
176 * Revision 1.19 1996/05/16 15:31:14 quinn
179 * Revision 1.18 1996/05/09 07:28:56 quinn
180 * Work towards phrases and multiple registers
182 * Revision 1.17 1996/05/01 13:46:37 adam
183 * First work on multiple records in one file.
184 * New option, -offset, to the "unread" command in the filter module.
186 * Revision 1.16 1996/01/17 14:57:54 adam
187 * Prototype changed for reader functions in extract/retrieve. File
188 * is identified by 'void *' instead of 'int.
190 * Revision 1.15 1996/01/08 19:15:47 adam
191 * New input filter that works!
193 * Revision 1.14 1995/12/15 12:36:11 adam
194 * Retrieval calls data1_read_regx when subType is specified.
196 * Revision 1.13 1995/12/15 12:24:43 quinn
197 * *** empty log message ***
199 * Revision 1.12 1995/12/15 12:20:28 quinn
200 * *** empty log message ***
202 * Revision 1.11 1995/12/15 12:07:57 quinn
203 * Changed extraction strategy.
205 * Revision 1.10 1995/12/14 11:10:48 quinn
208 * Revision 1.9 1995/12/13 17:14:05 quinn
209 * *** empty log message ***
211 * Revision 1.8 1995/12/13 15:33:18 quinn
212 * *** empty log message ***
214 * Revision 1.7 1995/12/13 13:45:39 quinn
215 * Changed data1 to use nmem.
217 * Revision 1.6 1995/12/04 14:22:30 adam
218 * Extra arg to recType_byName.
219 * Started work on new regular expression parsed input to
220 * structured records.
222 * Revision 1.5 1995/11/28 14:18:37 quinn
225 * Revision 1.4 1995/11/21 13:14:49 quinn
226 * Fixed end-of-data-field problem (maybe).
228 * Revision 1.3 1995/11/15 19:13:09 adam
229 * Work on record management.
235 #include <sys/types.h>
246 #define GRS_MAX_WORD 512
252 struct grs_handler *next;
255 struct grs_handlers {
256 struct grs_handler *handlers;
259 static int read_grs_type (struct grs_handlers *h,
260 struct grs_read_info *p, const char *type,
263 struct grs_handler *gh = h->handlers;
264 const char *cp = strchr (type, '.');
266 if (cp == NULL || cp == type)
268 cp = strlen(type) + type;
272 strcpy (p->type, cp+1);
273 for (gh = h->handlers; gh; gh = gh->next)
275 if (!memcmp (type, gh->type->type, cp-type))
280 gh->clientData = (*gh->type->init)();
282 p->clientData = gh->clientData;
283 *root = (gh->type->read)(p);
284 gh->clientData = p->clientData;
291 static void grs_add_handler (struct grs_handlers *h, RecTypeGrs t)
293 struct grs_handler *gh = (struct grs_handler *) malloc (sizeof(*gh));
294 gh->next = h->handlers;
301 static void *grs_init(RecType recType)
303 struct grs_handlers *h = (struct grs_handlers *) malloc (sizeof(*h));
306 grs_add_handler (h, recTypeGrs_sgml);
307 grs_add_handler (h, recTypeGrs_regx);
309 grs_add_handler (h, recTypeGrs_tcl);
311 grs_add_handler (h, recTypeGrs_marc);
315 static void grs_destroy(void *clientData)
317 struct grs_handlers *h = (struct grs_handlers *) clientData;
318 struct grs_handler *gh = h->handlers, *gh_next;
323 (*gh->type->destroy)(gh->clientData);
330 static void index_xpath (data1_node *n, struct recExtractCtrl *p,
331 int level, RecWord *wrd, int use)
334 char tag_path_full[1024];
342 wrd->string = n->u.data.data;
343 wrd->length = n->u.data.len;
344 wrd->attrSet = VAL_IDXPATH,
346 if (p->flagShowRecords)
348 printf("%*s data=", (level + 1) * 4, "");
349 for (i = 0; i<wrd->length && i < 8; i++)
350 fputc (wrd->string[i], stdout);
359 for (nn = n; nn; nn = nn->parent)
361 if (n->which == DATA1N_tag)
363 size_t tlen = strlen(nn->u.tag.tag);
364 if (tlen + flen > (sizeof(tag_path_full)-2))
366 memcpy (tag_path_full + flen, nn->u.tag.tag, tlen);
368 tag_path_full[flen++] = '/';
370 else if (n->which == DATA1N_root)
372 size_t tlen = strlen(nn->u.root.type);
373 if (tlen + flen > (sizeof(tag_path_full)-2))
375 memcpy (tag_path_full + flen, nn->u.root.type, tlen);
377 tag_path_full[flen++] = '/';
382 wrd->string = tag_path_full;
384 wrd->attrSet = VAL_IDXPATH,
386 if (p->flagShowRecords)
388 printf("%*s tag=", (level + 1) * 4, "");
389 for (i = 0; i<wrd->length && i < 40; i++)
390 fputc (wrd->string[i], stdout);
403 static void index_termlist (data1_node *par, data1_node *n,
404 struct recExtractCtrl *p, int level, RecWord *wrd)
406 data1_termlist *tlist = 0;
407 data1_datatype dtype = DATA1K_string;
409 * cycle up towards the root until we find a tag with an att..
410 * this has the effect of indexing locally defined tags with
411 * the attribute of their ancestor in the record.
414 while (!par->u.tag.element)
415 if (!par->parent || !(par=get_parent_tag(p->dh, par->parent)))
417 if (!par || !(tlist = par->u.tag.element->termlists))
419 if (par->u.tag.element->tag)
420 dtype = par->u.tag.element->tag->kind;
422 for (; tlist; tlist = tlist->next)
425 /* consider source */
428 if (!strcmp (tlist->source, "data") && n->which == DATA1N_data)
430 wrd->string = n->u.data.data;
431 wrd->length = n->u.data.len;
433 else if (!strcmp (tlist->source, "tag") && n->which == DATA1N_tag)
435 wrd->string = n->u.tag.tag;
436 wrd->length = strlen(n->u.tag.tag);
438 else if (sscanf (tlist->source, "attr(%511[^)])", xattr) == 1 &&
439 n->which == DATA1N_tag)
441 data1_xattr *p = n->u.tag.attributes;
442 while (p && strcmp (p->name, xattr))
446 wrd->string = p->value;
447 wrd->length = strlen(p->value);
452 if (p->flagShowRecords)
455 printf("%*sIdx: [%s]", (level + 1) * 4, "",
457 printf("%s:%s [%d] %s",
458 tlist->att->parent->name,
459 tlist->att->name, tlist->att->value,
462 for (i = 0; i<wrd->length && i < 8; i++)
463 fputc (wrd->string[i], stdout);
467 fputc ('\n', stdout);
471 wrd->reg_type = *tlist->structure;
472 wrd->attrSet = (int) (tlist->att->parent->reference);
473 wrd->attrUse = tlist->att->locals->local;
480 static int dumpkeys(data1_node *n, struct recExtractCtrl *p, int level)
483 (*p->init)(p, &wrd); /* set defaults */
484 for (; n; n = n->next)
486 if (p->flagShowRecords) /* display element description to user */
488 if (n->which == DATA1N_root)
490 printf("%*s", level * 4, "");
491 printf("Record type: '%s'\n", n->u.root.type);
493 else if (n->which == DATA1N_tag)
497 printf("%*s", level * 4, "");
498 if (!(e = n->u.tag.element))
499 printf("Local tag: '%s'\n", n->u.tag.tag);
502 printf("Elm: '%s' ", e->name);
505 data1_tag *t = e->tag;
507 printf("TagNam: '%s' ", t->names->name);
510 printf("%s[%d],", t->tagset->name, t->tagset->type);
513 if (t->which == DATA1T_numeric)
514 printf("%d)", t->value.numeric);
516 printf("'%s')", t->value.string);
523 if (n->which == DATA1N_tag)
525 index_termlist (n, n, p, level, &wrd);
526 /* index start tag */
527 if (!n->root->u.root.absyn)
528 index_xpath (n, p, level, &wrd, 1);
532 if (dumpkeys(n->child, p, level + 1) < 0)
536 if (n->which == DATA1N_data)
538 data1_node *par = get_parent_tag(p->dh, n);
540 if (p->flagShowRecords)
542 printf("%*s", level * 4, "");
544 if (n->u.data.len > 32)
545 printf("'%.24s ... %.6s'\n", n->u.data.data,
546 n->u.data.data + n->u.data.len-6);
547 else if (n->u.data.len > 0)
548 printf("'%.*s'\n", n->u.data.len, n->u.data.data);
554 index_termlist (par, n, p, level, &wrd);
555 if (!n->root->u.root.absyn)
556 index_xpath (n, p, level, &wrd, 1016);
560 if (n->which == DATA1N_tag)
563 if (!n->root->u.root.absyn)
564 index_xpath (n, p, level, &wrd, 2);
568 if (p->flagShowRecords && n->which == DATA1N_root)
570 printf("%*s-------------\n\n", level * 4, "");
576 int grs_extract_tree(struct recExtractCtrl *p, data1_node *n)
579 int oidtmp[OID_SIZE];
581 oe.proto = PROTO_Z3950;
582 oe.oclass = CLASS_SCHEMA;
585 oe.value = n->u.root.absyn->reference;
587 if ((oid_ent_to_oid (&oe, oidtmp)))
588 (*p->schemaAdd)(p, oidtmp);
590 return dumpkeys(n, p, 0);
593 static int grs_extract_sub(struct grs_handlers *h, struct recExtractCtrl *p,
597 struct grs_read_info gri;
599 int oidtmp[OID_SIZE];
601 gri.readf = p->readf;
602 gri.seekf = p->seekf;
603 gri.tellf = p->tellf;
606 gri.offset = p->offset;
610 if (read_grs_type (h, &gri, p->subType, &n))
611 return RECCTRL_EXTRACT_ERROR;
613 return RECCTRL_EXTRACT_EOF;
614 oe.proto = PROTO_Z3950;
615 oe.oclass = CLASS_SCHEMA;
617 if (!n->u.root.absyn)
618 return RECCTRL_EXTRACT_ERROR;
622 oe.value = n->u.root.absyn->reference;
623 if ((oid_ent_to_oid (&oe, oidtmp)))
624 (*p->schemaAdd)(p, oidtmp);
627 data1_pr_tree (p->dh, n, stdout);
629 if (dumpkeys(n, p, 0) < 0)
631 data1_free_tree(p->dh, n);
632 return RECCTRL_EXTRACT_ERROR;
634 data1_free_tree(p->dh, n);
635 return RECCTRL_EXTRACT_OK;
638 static int grs_extract(void *clientData, struct recExtractCtrl *p)
641 NMEM mem = nmem_create ();
642 struct grs_handlers *h = (struct grs_handlers *) clientData;
644 ret = grs_extract_sub(h, p, mem);
650 * Return: -1: Nothing done. 0: Ok. >0: Bib-1 diagnostic.
652 static int process_comp(data1_handle dh, data1_node *n, Z_RecordComposition *c)
654 data1_esetname *eset;
660 case Z_RecordComp_simple:
661 if (c->u.simple->which != Z_ElementSetNames_generic)
662 return 26; /* only generic form supported. Fix this later */
663 if (!(eset = data1_getesetbyname(dh, n->u.root.absyn,
664 c->u.simple->u.generic)))
666 logf(LOG_LOG, "Unknown esetname '%s'", c->u.simple->u.generic);
667 return 25; /* invalid esetname */
669 logf(LOG_DEBUG, "Esetname '%s' in simple compspec",
670 c->u.simple->u.generic);
673 case Z_RecordComp_complex:
674 if (c->u.complex->generic)
676 /* insert check for schema */
677 if ((p = c->u.complex->generic->elementSpec))
681 case Z_ElementSpec_elementSetName:
683 data1_getesetbyname(dh, n->u.root.absyn,
684 p->u.elementSetName)))
686 logf(LOG_LOG, "Unknown esetname '%s'",
687 p->u.elementSetName);
688 return 25; /* invalid esetname */
690 logf(LOG_DEBUG, "Esetname '%s' in complex compspec",
691 p->u.elementSetName);
694 case Z_ElementSpec_externalSpec:
695 if (p->u.externalSpec->which == Z_External_espec1)
697 logf(LOG_DEBUG, "Got Espec-1");
698 espec = p->u.externalSpec-> u.espec1;
702 logf(LOG_LOG, "Unknown external espec.");
703 return 25; /* bad. what is proper diagnostic? */
714 logf (LOG_DEBUG, "Element: Espec-1 match");
715 return data1_doespec1(dh, n, espec);
719 logf (LOG_DEBUG, "Element: all match");
724 static int grs_retrieve(void *clientData, struct recRetrieveCtrl *p)
726 data1_node *node = 0, *onode = 0;
729 int res, selected = 0;
731 struct grs_read_info gri;
733 struct grs_handlers *h = (struct grs_handlers *) clientData;
734 int requested_schema = VAL_NONE;
737 gri.readf = p->readf;
738 gri.seekf = p->seekf;
739 gri.tellf = p->tellf;
746 logf (LOG_DEBUG, "grs_retrieve");
747 if (read_grs_type (h, &gri, p->subType, &node))
760 data1_pr_tree (p->dh, node, stdout);
762 logf (LOG_DEBUG, "grs_retrieve: size");
763 if ((dnew = data1_insert_taggeddata(p->dh, node, node,
766 dnew->u.data.what = DATA1I_text;
767 dnew->u.data.data = dnew->lbuf;
768 sprintf(dnew->u.data.data, "%d", p->recordSize);
769 dnew->u.data.len = strlen(dnew->u.data.data);
772 tagname = res_get_def(p->res, "tagrank", "rank");
773 if (strcmp(tagname, "0") && p->score >= 0 &&
774 (dnew = data1_insert_taggeddata(p->dh, node, node, tagname, mem)))
776 logf (LOG_DEBUG, "grs_retrieve: %s", tagname);
777 dnew->u.data.what = DATA1I_num;
778 dnew->u.data.data = dnew->lbuf;
779 sprintf(dnew->u.data.data, "%d", p->score);
780 dnew->u.data.len = strlen(dnew->u.data.data);
783 tagname = res_get_def(p->res, "tagsysno", "localControlNumber");
784 if (strcmp(tagname, "0") && p->localno > 0 &&
785 (dnew = data1_insert_taggeddata(p->dh, node, node, tagname, mem)))
787 logf (LOG_DEBUG, "grs_retrieve: %s", tagname);
788 dnew->u.data.what = DATA1I_text;
789 dnew->u.data.data = dnew->lbuf;
790 sprintf(dnew->u.data.data, "%d", p->localno);
791 dnew->u.data.len = strlen(dnew->u.data.data);
794 if (p->comp && p->comp->which == Z_RecordComp_complex &&
795 p->comp->u.complex->generic &&
796 p->comp->u.complex->generic->schema)
798 oident *oe = oid_getentbyoid (p->comp->u.complex->generic->schema);
800 requested_schema = oe->value;
803 /* If schema has been specified, map if possible, then check that
804 * we got the right one
806 if (requested_schema != VAL_NONE)
808 logf (LOG_DEBUG, "grs_retrieve: schema mapping");
809 for (map = node->u.root.absyn->maptabs; map; map = map->next)
811 if (map->target_absyn_ref == requested_schema)
814 if (!(node = data1_map_record(p->dh, onode, map, mem)))
823 if (node->u.root.absyn &&
824 requested_schema != node->u.root.absyn->reference)
832 * Does the requested format match a known syntax-mapping? (this reflects
833 * the overlap of schema and formatting which is inherent in the MARC
836 logf (LOG_DEBUG, "grs_retrieve: syntax mapping");
837 if (node->u.root.absyn)
838 for (map = node->u.root.absyn->maptabs; map; map = map->next)
840 if (map->target_absyn_ref == p->input_format)
843 if (!(node = data1_map_record(p->dh, onode, map, mem)))
852 logf (LOG_DEBUG, "grs_retrieve: schemaIdentifier");
853 if (node->u.root.absyn &&
854 node->u.root.absyn->reference != VAL_NONE &&
855 p->input_format == VAL_GRS1)
859 int oidtmp[OID_SIZE];
861 oe.proto = PROTO_Z3950;
862 oe.oclass = CLASS_SCHEMA;
863 oe.value = node->u.root.absyn->reference;
865 if ((oid = oid_ent_to_oid (&oe, oidtmp)))
868 data1_handle dh = p->dh;
872 for (ii = oid; *ii >= 0; ii++)
876 sprintf(p, "%d", *ii);
881 if ((dnew = data1_insert_taggeddata(dh, node, node,
882 "schemaIdentifier", mem)))
884 dnew->u.data.what = DATA1I_oid;
885 dnew->u.data.data = (char *) nmem_malloc(mem, p - tmp);
886 memcpy(dnew->u.data.data, tmp, p - tmp);
887 dnew->u.data.len = p - tmp;
892 logf (LOG_DEBUG, "grs_retrieve: element spec");
893 if (p->comp && (res = process_comp(p->dh, node, p->comp)) > 0)
897 data1_free_tree(p->dh, onode);
898 data1_free_tree(p->dh, node);
902 else if (p->comp && !res)
906 data1_pr_tree (p->dh, node, stdout);
908 logf (LOG_DEBUG, "grs_retrieve: transfer syntax mapping");
909 switch (p->output_format = (p->input_format != VAL_NONE ?
910 p->input_format : VAL_SUTRS))
912 data1_marctab *marctab;
916 if (!(p->rec_buf = data1_nodetoidsgml(p->dh, node, selected,
921 char *new_buf = (char*) odr_malloc (p->odr, p->rec_len);
922 memcpy (new_buf, p->rec_buf, p->rec_len);
923 p->rec_buf = new_buf;
928 if (!(p->rec_buf = data1_nodetogr(p->dh, node, selected,
930 p->diagnostic = 238; /* not available in requested syntax */
932 p->rec_len = (size_t) (-1);
935 if (!(p->rec_buf = data1_nodetoexplain(p->dh, node, selected,
939 p->rec_len = (size_t) (-1);
942 if (!(p->rec_buf = data1_nodetosummary(p->dh, node, selected,
946 p->rec_len = (size_t) (-1);
949 if (!(p->rec_buf = data1_nodetobuf(p->dh, node, selected,
954 char *new_buf = (char*) odr_malloc (p->odr, p->rec_len);
955 memcpy (new_buf, p->rec_buf, p->rec_len);
956 p->rec_buf = new_buf;
960 if (!(p->rec_buf = data1_nodetosoif(p->dh, node, selected,
965 char *new_buf = (char*) odr_malloc (p->odr, p->rec_len);
966 memcpy (new_buf, p->rec_buf, p->rec_len);
967 p->rec_buf = new_buf;
971 if (!node->u.root.absyn)
976 for (marctab = node->u.root.absyn->marc; marctab;
977 marctab = marctab->next)
978 if (marctab->reference == p->input_format)
985 if (!(p->rec_buf = data1_nodetomarc(p->dh, marctab, node,
986 selected, &p->rec_len)))
990 char *new_buf = (char*) odr_malloc (p->odr, p->rec_len);
991 memcpy (new_buf, p->rec_buf, p->rec_len);
992 p->rec_buf = new_buf;
996 data1_free_tree(p->dh, node);
998 data1_free_tree(p->dh, onode);
1003 static struct recType grs_type =
1012 RecType recTypeGrs = &grs_type;