Implemented loadable filters.
[idzebra-moved-to-github.git] / recctrl / marcread.c
1 /* $Id: marcread.c,v 1.25 2004-09-27 10:44:50 adam Exp $
2    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
3    Index Data Aps
4
5 This file is part of the Zebra server.
6
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
10 version.
11
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
15 for more details.
16
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
20 02111-1307, USA.
21 */
22
23 #include <stdio.h>
24 #include <ctype.h>
25 #include <assert.h>
26
27 #include <yaz/log.h>
28 #include <yaz/yaz-util.h>
29 #include <yaz/marcdisp.h>
30 #include "grsread.h"
31 #include "marcomp.h"
32 #include "inline.h"
33
34 #define MARC_DEBUG 0
35 #define MARCOMP_DEBUG 0
36
37 struct marc_info {
38     char type[256];
39 };
40
41 static data1_node *grs_read_iso2709 (struct grs_read_info *p, int marc_xml)
42 {
43     struct marc_info *mi = (struct marc_info*) p->clientData;
44     char buf[100000];
45     int entry_p;
46     int record_length;
47     int indicator_length;
48     int identifier_length;
49     int base_address;
50     int length_data_entry;
51     int length_starting;
52     int length_implementation;
53     int read_bytes;
54 #if MARC_DEBUG
55     FILE *outf = stdout;
56 #endif
57     data1_node *res_root, *res_top;
58     char *absynName;
59     data1_marctab *marctab;
60
61     if ((*p->readf)(p->fh, buf, 5) != 5)
62         return NULL;
63     record_length = atoi_n (buf, 5);
64     if (record_length < 25)
65     {
66         logf (LOG_WARN, "MARC record length < 25, is %d", record_length);
67         return NULL;
68     }
69     /* read remaining part - attempt to read one byte furhter... */
70     read_bytes = (*p->readf)(p->fh, buf+5, record_length-4);
71     if (read_bytes < record_length-5)
72     {
73         logf (LOG_WARN, "Couldn't read whole MARC record");
74         return NULL;
75     }
76     if (read_bytes == record_length - 4)
77     {
78         off_t cur_offset = (*p->tellf)(p->fh);
79         if (cur_offset <= 27)
80             return NULL;
81         if (p->endf)
82             (*p->endf)(p->fh, cur_offset - 1);
83     }
84     absynName = mi->type;
85     res_root = data1_mk_root (p->dh, p->mem, absynName);
86     if (!res_root)
87     {
88         yaz_log (LOG_WARN, "cannot read MARC without an abstract syntax");
89         return 0;
90     }
91     if (marc_xml)
92     {
93         data1_node *lead;
94         const char *attr[] = { "xmlns", "http://www.loc.gov/MARC21/slim", 0};
95                          
96         res_top = data1_mk_tag (p->dh, p->mem, "record", attr, res_root);
97
98         lead = data1_mk_tag(p->dh, p->mem, "leader", 0, res_top);
99         data1_mk_text_n(p->dh, p->mem, buf, 24, lead);
100     }
101     else
102         res_top = data1_mk_tag (p->dh, p->mem, absynName, 0, res_root);
103
104     if ((marctab = res_root->u.root.absyn->marc))
105     {
106         memcpy(marctab->leader, buf, 24);
107         memcpy(marctab->implementation_codes, buf+6, 4);
108         marctab->implementation_codes[4] = '\0';
109         memcpy(marctab->user_systems, buf+17, 3);
110         marctab->user_systems[3] = '\0';
111     }
112
113     if (marctab && marctab->force_indicator_length >= 0)
114         indicator_length = marctab->force_indicator_length;
115     else
116         indicator_length = atoi_n (buf+10, 1);
117     if (marctab && marctab->force_identifier_length >= 0)
118         identifier_length = marctab->force_identifier_length;
119     else
120         identifier_length = atoi_n (buf+11, 1);
121     base_address = atoi_n (buf+12, 5);
122
123     length_data_entry = atoi_n (buf+20, 1);
124     length_starting = atoi_n (buf+21, 1);
125     length_implementation = atoi_n (buf+22, 1);
126
127     for (entry_p = 24; buf[entry_p] != ISO2709_FS; )
128         entry_p += 3+length_data_entry+length_starting;
129     base_address = entry_p+1;
130     for (entry_p = 24; buf[entry_p] != ISO2709_FS; )
131     {
132         int data_length;
133         int data_offset;
134         int end_offset;
135         int i, i0;
136         char tag[4];
137         data1_node *res;
138         data1_node *parent = res_top;
139
140         memcpy (tag, buf+entry_p, 3);
141         entry_p += 3;
142         tag[3] = '\0';
143
144         if (marc_xml)
145             res = parent;
146         else
147             res = data1_mk_tag_n (p->dh, p->mem, tag, 3, 0 /* attr */, parent);
148         
149 #if MARC_DEBUG
150         fprintf (outf, "%s ", tag);
151 #endif
152         data_length = atoi_n (buf+entry_p, length_data_entry);
153         entry_p += length_data_entry;
154         data_offset = atoi_n (buf+entry_p, length_starting);
155         entry_p += length_starting;
156         i = data_offset + base_address;
157         end_offset = i+data_length-1;
158
159         if (memcmp (tag, "00", 2) && indicator_length)
160         {
161             /* generate indicator node */
162             if (marc_xml)
163             {
164                 const char *attr[10];
165                 int j;
166
167                 attr[0] = "tag";
168                 attr[1] = tag;
169                 attr[2] = 0;
170
171                 res = data1_mk_tag(p->dh, p->mem, "datafield", attr, res);
172
173                 for (j = 0; j<indicator_length; j++)
174                 {
175                     char str1[18], str2[2];
176                     sprintf (str1, "ind%d", j+1);
177                     str2[0] = buf[i+j];
178                     str2[1] = '\0';
179
180                     attr[0] = str1;
181                     attr[1] = str2;
182                     
183                     data1_tag_add_attr (p->dh, p->mem, res, attr);
184                 }
185             }
186             else
187             {
188 #if MARC_DEBUG
189                 int j;
190 #endif
191                 res = data1_mk_tag_n (p->dh, p->mem, 
192                                       buf+i, indicator_length, 0 /* attr */, res);
193 #if MARC_DEBUG
194                 for (j = 0; j<indicator_length; j++)
195                     fprintf (outf, "%c", buf[j+i]);
196 #endif
197             }
198             i += indicator_length;
199         } 
200         else
201         {
202             if (marc_xml)
203             {
204                 const char *attr[10];
205                 
206                 attr[0] = "tag";
207                 attr[1] = tag;
208                 attr[2] = 0;
209                 
210                 res = data1_mk_tag(p->dh, p->mem, "controlfield", attr, res);
211             }
212         }
213         parent = res;
214         /* traverse sub fields */
215         i0 = i;
216         while (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS && i < end_offset)
217         {
218             if (memcmp (tag, "00", 2) && identifier_length)
219             {
220                 data1_node *res;
221                 if (marc_xml)
222                 {
223                     int j;
224                     const char *attr[3];
225                     char code[10];
226                     
227                     for (j = 1; j<identifier_length && j < 9; j++)
228                         code[j-1] = buf[i+j];
229                     code[j-1] = 0;
230                     attr[0] = "code";
231                     attr[1] = code;
232                     attr[2] = 0;
233                     res = data1_mk_tag(p->dh, p->mem, "subfield",
234                                        attr, parent);
235                 }
236                 else
237                 {
238                     res = data1_mk_tag_n (p->dh, p->mem,
239                                            buf+i+1, identifier_length-1, 
240                                            0 /* attr */, parent);
241                 }
242 #if MARC_DEBUG
243                 fprintf (outf, " $"); 
244                 for (j = 1; j<identifier_length; j++)
245                     fprintf (outf, "%c", buf[j+i]);
246                 fprintf (outf, " ");
247 #endif
248                 i += identifier_length;
249                 i0 = i;
250                 while (buf[i] != ISO2709_RS && buf[i] != ISO2709_IDFS &&
251                      buf[i] != ISO2709_FS && i < end_offset)
252                 {
253 #if MARC_DEBUG
254                     fprintf (outf, "%c", buf[i]);
255 #endif
256                     i++;
257                 }
258                 data1_mk_text_n (p->dh, p->mem, buf + i0, i - i0, res);
259                 i0 = i;
260             }
261             else
262             {
263 #if MARC_DEBUG
264                 fprintf (outf, "%c", buf[i]);
265 #endif
266                 i++;
267             }
268         }
269         if (i > i0)
270         {
271             data1_mk_text_n (p->dh, p->mem, buf + i0, i - i0, parent);
272         }
273 #if MARC_DEBUG
274         fprintf (outf, "\n");
275         if (i < end_offset)
276             fprintf (outf, "-- separator but not at end of field\n");
277         if (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
278             fprintf (outf, "-- no separator at end of field\n");
279 #endif
280     }
281     return res_root;
282 }
283
284 /*
285  * Locate some data under this node. This routine should handle variants
286  * prettily.
287  */
288 static char *get_data(data1_node *n, int *len)
289 {
290     char *r;
291
292     while (n)
293     {
294         if (n->which == DATA1N_data)
295         {
296             int i;
297             *len = n->u.data.len;
298
299             for (i = 0; i<*len; i++)
300                 if (!d1_isspace(n->u.data.data[i]))
301                     break;
302             while (*len && d1_isspace(n->u.data.data[*len - 1]))
303                 (*len)--;
304             *len = *len - i;
305             if (*len > 0)
306                 return n->u.data.data + i;
307         }
308         if (n->which == DATA1N_tag)
309             n = n->child;
310         else if (n->which == DATA1N_data)
311             n = n->next;
312         else
313             break;      
314     }
315     r = "";
316     *len = strlen(r);
317     return r;
318 }
319
320 static data1_node *lookup_subfield(data1_node *node, const char *name)
321 {
322     data1_node *p;
323     
324     for (p=node; p; p=p->next)
325     {
326         if (!yaz_matchstr(p->u.tag.tag, name))
327             return p;
328     }
329     return 0;
330 }
331
332 static inline_subfield *lookup_inline_subfield(inline_subfield *pisf,
333                                                const char *name)
334 {
335     inline_subfield *p;
336     
337     for (p=pisf; p; p=p->next)
338     {
339         if (!yaz_matchstr(p->name, name))
340             return p;
341     }
342     return 0;
343 }
344
345 static inline_subfield *cat_inline_subfield(mc_subfield *psf, WRBUF buf,
346                                             inline_subfield *pisf)
347 {
348     mc_subfield *p;
349     
350     for (p = psf; p && pisf; p = p->next)
351     {
352         if (p->which == MC_SF)
353         {
354             inline_subfield *found = lookup_inline_subfield(pisf, p->name);
355             
356             if (found)
357             {
358                 if (strcmp(p->prefix, "_"))
359                 {
360                     wrbuf_puts(buf, " ");
361                     wrbuf_puts(buf, p->prefix);
362                 }
363                 if (p->interval.start == -1)
364                 {
365                     wrbuf_puts(buf, found->data);
366                 }
367                 else
368                 {
369                     wrbuf_write(buf, found->data+p->interval.start,
370                                 p->interval.end-p->interval.start);
371                     wrbuf_puts(buf, "");
372                 }
373                 if (strcmp(p->suffix, "_"))
374                 {
375                     wrbuf_puts(buf, p->suffix);
376                     wrbuf_puts(buf, " ");
377                 }
378 #if MARCOMP_DEBUG
379                 logf(LOG_LOG, "cat_inline_subfield(): add subfield $%s", found->name);
380 #endif          
381                 pisf = found->next;
382             }
383         }
384         else if (p->which == MC_SFVARIANT)
385         {
386             inline_subfield *next;
387             
388             do {
389                 next = cat_inline_subfield(p->u.child, buf, pisf);
390                 if (next == pisf)
391                     break;
392                 pisf = next;
393             } while (pisf);
394         }
395         else if (p->which == MC_SFGROUP)
396         {
397             mc_subfield *pp;
398             int found;
399             
400             for (pp = p->u.child, found = 0; pp; pp = pp->next)
401             {
402                 if (!yaz_matchstr(pisf->name, p->name))
403                 {
404                     found = 1;
405                     break;
406                 }
407             }
408             if (found)
409             {
410                 wrbuf_puts(buf, " (");
411                 pisf = cat_inline_subfield(p->u.child, buf, pisf);
412                 wrbuf_puts(buf, ") ");
413             }
414         }
415     }
416     return pisf; 
417 }
418
419 static void cat_inline_field(mc_field *pf, WRBUF buf, data1_node *subfield)
420 {    
421     if (!pf || !subfield)
422         return;
423
424     for (;subfield;)
425     {
426         int len;
427         inline_field *pif=NULL;
428         data1_node *psubf;
429         
430         if (yaz_matchstr(subfield->u.tag.tag, "1"))
431         {
432             subfield = subfield->next;
433             continue;
434         }
435         
436         psubf = subfield;
437         pif = inline_mk_field();
438         do
439         {
440             int i;
441             if ((i=inline_parse(pif, psubf->u.tag.tag, get_data(psubf, &len)))<0)
442             {
443                 logf(LOG_WARN, "inline subfield ($%s): parse error",
444                     psubf->u.tag.tag);
445                 inline_destroy_field(pif);
446                 return; 
447             }
448             psubf = psubf->next;
449         } while (psubf && yaz_matchstr(psubf->u.tag.tag, "1"));
450         
451         subfield = psubf;
452         
453         if (pif && !yaz_matchstr(pif->name, pf->name))
454         {
455             if (!pf->list && pif->list)
456             {
457                 wrbuf_puts(buf, pif->list->data);
458             }
459             else
460             {
461                 int ind1, ind2;
462
463                 /*
464                     check indicators
465                 */
466
467                 ind1 = (pif->ind1[0] == ' ') ? '_':pif->ind1[0];
468                 ind2 = (pif->ind2[0] == ' ') ? '_':pif->ind2[0];
469     
470                 if (((pf->ind1[0] == '.') || (ind1 == pf->ind1[0])) &&
471                     ((pf->ind2[0] == '.') || (ind2 == pf->ind2[0])))
472                 {
473                     cat_inline_subfield(pf->list, buf, pif->list);
474                     
475                     /*
476                         add separator for inline fields
477                     */
478                     if (wrbuf_len(buf))
479                     {
480                         wrbuf_puts(buf, "\n");
481                     }
482                 }
483                 else
484                 {
485                     logf(LOG_WARN, "In-line field %s missed -- indicators do not match", pif->name);
486                 }
487             }
488         }
489         inline_destroy_field(pif);
490     }
491 #if MARCOMP_DEBUG    
492     logf(LOG_LOG, "cat_inline_field(): got buffer {%s}", buf);
493 #endif
494 }
495
496 static data1_node *cat_subfield(mc_subfield *psf, WRBUF buf,
497                                 data1_node *subfield)
498 {
499     mc_subfield *p;
500     
501     for (p = psf; p && subfield; p = p->next)
502     {
503         if (p->which == MC_SF)
504         {
505             data1_node *found = lookup_subfield(subfield, p->name);
506             
507             if (found)
508             {
509                 int len;
510                 
511                 if (strcmp(p->prefix, "_"))
512                 {
513                     wrbuf_puts(buf, " ");
514                     wrbuf_puts(buf, p->prefix);
515                 }
516                 
517                 if (p->u.in_line)
518                 {
519                     cat_inline_field(p->u.in_line, buf, found);
520                 }
521                 else if (p->interval.start == -1)
522                 {
523                     wrbuf_puts(buf, get_data(found, &len));
524                 }
525                 else
526                 {
527                     wrbuf_write(buf, get_data(found, &len)+p->interval.start,
528                         p->interval.end-p->interval.start);
529                     wrbuf_puts(buf, "");
530                 }
531                 if (strcmp(p->suffix, "_"))
532                 {
533                     wrbuf_puts(buf, p->suffix);
534                     wrbuf_puts(buf, " ");
535                 }
536 #if MARCOMP_DEBUG               
537                 logf(LOG_LOG, "cat_subfield(): add subfield $%s", found->u.tag.tag);
538 #endif          
539                 subfield = found->next;
540             }
541         }
542         else if (p->which == MC_SFVARIANT)
543         {
544             data1_node *next;
545             do {
546                 next = cat_subfield(p->u.child, buf, subfield);
547                 if (next == subfield)
548                     break;
549                 subfield = next;
550             } while (subfield);
551         }
552         else if (p->which == MC_SFGROUP)
553         {
554             mc_subfield *pp;
555             int found;
556             
557             for (pp = p->u.child, found = 0; pp; pp = pp->next)
558             {
559                 if (!yaz_matchstr(subfield->u.tag.tag, pp->name))
560                 {
561                     found = 1;
562                     break;
563                 }
564             }
565             if (found)
566             {
567                 wrbuf_puts(buf, " (");
568                 subfield = cat_subfield(p->u.child, buf, subfield);
569                 wrbuf_puts(buf, ") ");
570             }
571         }
572     }
573     return subfield;
574 }
575
576 static data1_node *cat_field(struct grs_read_info *p, mc_field *pf,
577                              WRBUF buf, data1_node *field)
578 {
579     data1_node *subfield;
580     int ind1, ind2;
581     
582     if (!pf || !field)
583         return 0;
584
585     
586     if (yaz_matchstr(field->u.tag.tag, pf->name))
587         return field->next;
588
589     subfield = field->child;
590     
591     if (!subfield)
592         return field->next;
593
594     /*
595         check subfield without indicators
596     */
597     
598     if (!pf->list && subfield->which == DATA1N_data)
599     {
600         int len;
601         
602         if (pf->interval.start == -1)
603         {
604             wrbuf_puts(buf, get_data(field, &len));
605         }
606         else
607         {
608             wrbuf_write(buf, get_data(field, &len)+pf->interval.start,
609                         pf->interval.end-pf->interval.start);
610             wrbuf_puts(buf, "");
611         }
612 #if MARCOMP_DEBUG
613         logf(LOG_LOG, "cat_field(): got buffer {%s}", buf);
614 #endif
615         return field->next;
616     }
617     
618     /*
619         check indicators
620     */
621
622     ind1 = (subfield->u.tag.tag[0] == ' ') ? '_':subfield->u.tag.tag[0];
623     ind2 = (subfield->u.tag.tag[1] == ' ') ? '_':subfield->u.tag.tag[1];
624     
625     if (!(
626         ((pf->ind1[0] == '.') || (ind1 == pf->ind1[0])) &&
627         ((pf->ind2[0] == '.') || (ind2 == pf->ind2[0]))
628         ))
629     {
630 #if MARCOMP_DEBUG
631         logf(LOG_WARN, "Field %s missed -- does not match indicators", field->u.tag.tag);
632 #endif
633         return field->next;
634     }
635     
636     subfield = subfield->child;
637     
638     if (!subfield)
639         return field->next;
640
641     cat_subfield(pf->list, buf, subfield);
642
643 #if MARCOMP_DEBUG    
644     logf(LOG_LOG, "cat_field(): got buffer {%s}", buf);
645 #endif
646     
647     return field->next;    
648 }
649
650 static int is_empty(char *s)
651 {
652     char *p = s;
653     
654     for (p = s; *p; p++)
655     {
656         if (!isspace(*p))
657             return 0;
658     }
659     return 1;
660 }
661
662 static void parse_data1_tree(struct grs_read_info *p, const char *mc_stmnt,
663                              data1_node *root)
664 {
665     data1_marctab *marctab = root->u.root.absyn->marc;
666     data1_node *top = root->child;
667     data1_node *field;
668     mc_context *c;
669     mc_field *pf;
670     WRBUF buf;
671     
672     c = mc_mk_context(mc_stmnt+3);
673     
674     if (!c)
675         return;
676         
677     pf = mc_getfield(c);
678     
679     if (!pf)
680     {
681         mc_destroy_context(c);
682         return;
683     }
684     buf = wrbuf_alloc();
685 #if MARCOMP_DEBUG    
686     logf(LOG_LOG, "parse_data1_tree(): statement -{%s}", mc_stmnt);
687 #endif
688     if (!yaz_matchstr(pf->name, "ldr"))
689     {
690         data1_node *new;
691 #if MARCOMP_DEBUG
692         logf(LOG_LOG,"parse_data1_tree(): try LEADER from {%d} to {%d} positions",
693             pf->interval.start, pf->interval.end);
694 #endif  
695         new = data1_mk_tag_n(p->dh, p->mem, mc_stmnt, strlen(mc_stmnt), 0, top);
696         data1_mk_text_n(p->dh, p->mem, marctab->leader+pf->interval.start,
697             pf->interval.end-pf->interval.start+1, new);
698     }
699     else
700     {
701         field=top->child;
702         
703         while(field)
704         {
705             if (!yaz_matchstr(field->u.tag.tag, pf->name))
706             {
707                 data1_node *new;
708                 char *pb;
709 #if MARCOMP_DEBUG               
710                 logf(LOG_LOG, "parse_data1_tree(): try field {%s}", field->u.tag.tag);
711 #endif          
712                 wrbuf_rewind(buf);
713                 wrbuf_puts(buf, "");
714
715                 field = cat_field(p, pf, buf, field);
716                 
717                 pb = wrbuf_buf(buf);
718                 for (pb = strtok(pb, "\n"); pb; pb = strtok(NULL, "\n"))
719                 {
720                         if (!is_empty(pb))
721                         {
722                                 new = data1_mk_tag_n(p->dh, p->mem, mc_stmnt, strlen(mc_stmnt), 0, top);
723                                 data1_mk_text_n(p->dh, p->mem, pb, strlen(pb), new);
724                         }
725                 }
726             }
727             else
728             {
729                 field = field->next;
730             }
731         }
732     }
733     mc_destroy_field(pf);
734     mc_destroy_context(c);
735     wrbuf_free(buf, 1);
736 }
737
738 data1_node *grs_read_marcxml(struct grs_read_info *p)
739 {
740     data1_node *root = grs_read_iso2709(p, 1);
741     data1_element *e;
742
743     if (!root)
744         return 0;
745         
746     for (e=root->u.root.absyn->main_elements; e; e=e->next)
747     {
748         data1_tag *tag = e->tag;
749         
750         if (tag && tag->which == DATA1T_string &&
751             !yaz_matchstr(tag->value.string, "mc?"))
752                 parse_data1_tree(p, tag->value.string, root);
753     }
754     return root;
755 }
756
757 data1_node *grs_read_marc(struct grs_read_info *p)
758 {
759     data1_node *root = grs_read_iso2709(p, 0);
760     data1_element *e;
761
762     if (!root)
763         return 0;
764         
765     for (e=root->u.root.absyn->main_elements; e; e=e->next)
766     {
767         data1_tag *tag = e->tag;
768         
769         if (tag && tag->which == DATA1T_string &&
770             !yaz_matchstr(tag->value.string, "mc?"))
771                 parse_data1_tree(p, tag->value.string, root);
772     }
773     return root;
774 }
775
776 static void *init_marc(Res res, RecType rt)
777 {
778     struct marc_info *p = xmalloc(sizeof(*p));
779     strcpy(p->type, "");
780     return p;
781 }
782
783 static void config_marc(void *clientData, Res res, const char *args)
784 {
785     struct marc_info *p = (struct marc_info*) clientData;
786     if (strlen(args) < sizeof(p->type))
787         strcpy(p->type, args);
788 }
789
790 static void destroy_marc(void *clientData)
791 {
792     struct marc_info *p = (struct marc_info*) clientData;
793     xfree (p);
794 }
795
796
797 static int extract_marc(void *clientData, struct recExtractCtrl *ctrl)
798 {
799     return zebra_grs_extract(clientData, ctrl, grs_read_marc);
800 }
801
802 static int retrieve_marc(void *clientData, struct recRetrieveCtrl *ctrl)
803 {
804     return zebra_grs_retrieve(clientData, ctrl, grs_read_marc);
805 }
806
807 static struct recType marc_type = {
808     "grs.marc",
809     init_marc,
810     config_marc,
811     destroy_marc,
812     extract_marc,
813     retrieve_marc,
814 };
815
816 static int extract_marcxml(void *clientData, struct recExtractCtrl *ctrl)
817 {
818     return zebra_grs_extract(clientData, ctrl, grs_read_marcxml);
819 }
820
821 static int retrieve_marcxml(void *clientData, struct recRetrieveCtrl *ctrl)
822 {
823     return zebra_grs_retrieve(clientData, ctrl, grs_read_marcxml);
824 }
825
826 static struct recType marcxml_type = {
827     "grs.marcxml",
828     init_marc,
829     config_marc,
830     destroy_marc,
831     extract_marcxml,
832     retrieve_marcxml,
833 };
834
835 RecType
836 #ifdef IDZEBRA_STATIC_GRS_MARC
837 idzebra_filter_grs_marc
838 #else
839 idzebra_filter
840 #endif
841
842 [] = {
843     &marc_type,
844     &marcxml_type,
845     0,
846 };
847