X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmarcdisp.c;h=994c5a62638b1bfc705c03c83b4563640ad8c03a;hb=69cc5b167c5afbc8d14c0db30f9a5fb34dda0a24;hp=e5fd62ee464bab483a1abb094a97cd46b6a88876;hpb=e8ac1e56929fe175624fb63e619c184b58ef63b9;p=yaz-moved-to-github.git diff --git a/src/marcdisp.c b/src/marcdisp.c index e5fd62e..994c5a6 100644 --- a/src/marcdisp.c +++ b/src/marcdisp.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2006, Index Data ApS * See the file LICENSE for details. * - * $Id: marcdisp.c,v 1.34 2006-08-28 14:18:22 adam Exp $ + * $Id: marcdisp.c,v 1.37 2006-12-13 11:25:17 adam Exp $ */ /** @@ -25,6 +25,7 @@ #include #include #include +#include #if YAZ_HAVE_XML2 #include @@ -391,6 +392,41 @@ static void yaz_marc_reset(yaz_marc_t mt) mt->subfield_pp = 0; } +int yaz_marc_write_check(yaz_marc_t mt, WRBUF wr) +{ + struct yaz_marc_node *n; + int identifier_length; + const char *leader = 0; + + for (n = mt->nodes; n; n = n->next) + if (n->which == YAZ_MARC_LEADER) + { + leader = n->u.leader; + break; + } + + if (!leader) + return -1; + if (!atoi_n_check(leader+11, 1, &identifier_length)) + return -1; + + for (n = mt->nodes; n; n = n->next) + { + switch(n->which) + { + case YAZ_MARC_COMMENT: + wrbuf_iconv_write(wr, mt->iconv_cd, + n->u.comment, strlen(n->u.comment)); + wrbuf_puts(wr, ")\n"); + break; + default: + break; + } + } + return 0; +} + + int yaz_marc_write_line(yaz_marc_t mt, WRBUF wr) { struct yaz_marc_node *n; @@ -471,6 +507,8 @@ int yaz_marc_write_mode(yaz_marc_t mt, WRBUF wr) return yaz_marc_write_marcxchange(mt, wr, 0, 0); /* no format, type */ case YAZ_MARC_ISO2709: return yaz_marc_write_iso2709(mt, wr); + case YAZ_MARC_CHECK: + return yaz_marc_write_check(mt, wr); } return -1; } @@ -918,10 +956,11 @@ static int yaz_marc_read_xml_fields(yaz_marc_t mt, const xmlNode *ptr) } return 0; } +#endif -int yaz_marc_read_xml(yaz_marc_t mt, const void *xmlnode) +int yaz_marc_read_xml(yaz_marc_t mt, const xmlNode *ptr) { - const xmlNode *ptr = xmlnode; +#if YAZ_HAVE_XML2 for(; ptr; ptr = ptr->next) if (ptr->type == XML_ELEMENT_NODE) { @@ -945,13 +984,10 @@ int yaz_marc_read_xml(yaz_marc_t mt, const void *xmlnode) if (yaz_marc_read_xml_leader(mt, &ptr)) return -1; return yaz_marc_read_xml_fields(mt, ptr->next); -} #else -int yaz_marc_read_xml(yaz_marc_t mt, const void *xmlnode) -{ return -1; -} #endif +} int yaz_marc_read_iso2709(yaz_marc_t mt, const char *buf, int bsize) {