X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmarcdisp.c;h=1b02e110102ee69115fa60872122dea250e58bc1;hb=05a79698b4956c63642ebd0b4deedf56098c255c;hp=652db12585327e8800cd5e4df2c92388dc90132a;hpb=00106dc85fcaa3b02f9a0d471ea90a594bf3a175;p=yaz-moved-to-github.git diff --git a/src/marcdisp.c b/src/marcdisp.c index 652db12..1b02e11 100644 --- a/src/marcdisp.c +++ b/src/marcdisp.c @@ -2,7 +2,12 @@ * Copyright (c) 1995-2004, Index Data * See the file LICENSE for details. * - * $Id: marcdisp.c,v 1.4 2004-03-15 21:39:06 adam Exp $ + * $Id: marcdisp.c,v 1.9 2004-11-25 09:43:10 adam Exp $ + */ + +/** + * \file marcdisp.c + * \brief Implements MARC display - and conversion utilities */ #if HAVE_CONFIG_H @@ -43,7 +48,6 @@ void yaz_marc_destroy(yaz_marc_t mt) static void marc_cdata (yaz_marc_t mt, const char *buf, size_t len, WRBUF wr) { - size_t i; if (mt->xml == YAZ_MARC_ISO2709) wrbuf_iconv_write(wr, mt->iconv_cd, buf, len); else if (mt->xml == YAZ_MARC_LINE) @@ -135,7 +139,13 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr) wr, "\n" " "); - marc_cdata(mt, buf, 24, wr); +#if 1 + marc_cdata(mt, buf, 9, wr); + marc_cdata(mt, "a", 1, wr); /* set leader to signal unicode */ + marc_cdata(mt, buf+10, 14, wr); +#else + marc_cdata(mt, buf, 24, wr); /* leave header as is .. */ +#endif wrbuf_printf(wr, "\n"); break; } @@ -237,7 +247,7 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr) int end_offset; int i, j; char tag[4]; - int identifier_flag = 1; + int identifier_flag = 0; memcpy (tag, buf+entry_p, 3); entry_p += 3; @@ -251,11 +261,13 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr) if (indicator_length < 4 && indicator_length > 0) { - if (buf[i + indicator_length] != ISO2709_IDFS) - identifier_flag = 0; + if (buf[i + indicator_length] == ISO2709_IDFS) + identifier_flag = 1; + else if (buf[i + indicator_length + 1] == ISO2709_IDFS) + identifier_flag = 2; } - else if (!memcmp (tag, "00", 2)) - identifier_flag = 0; + else if (memcmp (tag, "00", 2)) + identifier_flag = 1; switch(mt->xml) { @@ -266,23 +278,30 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr) wrbuf_puts (wr, " "); break; case YAZ_MARC_SIMPLEXML: - wrbuf_printf (wr, "xml) @@ -296,13 +315,19 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr) wrbuf_putc(wr, buf[i]); break; case YAZ_MARC_SIMPLEXML: - wrbuf_printf(wr, " Indicator%d=\"%c\"", j+1, buf[i]); + wrbuf_printf(wr, " Indicator%d=\"", j+1); + marc_cdata(mt, buf+i, 1, wr); + wrbuf_printf(wr, "\""); break; case YAZ_MARC_OAIMARC: - wrbuf_printf(wr, " i%d=\"%c\"", j+1, buf[i]); + wrbuf_printf(wr, " i%d=\"", j+1); + marc_cdata(mt, buf+i, 1, wr); + wrbuf_printf(wr, "\""); break; case YAZ_MARC_MARCXML: - wrbuf_printf(wr, " ind%d=\"%c\"", j+1, buf[i]); + wrbuf_printf(wr, " ind%d=\"", j+1); + marc_cdata(mt, buf+i, 1, wr); + wrbuf_printf(wr, "\""); } } } @@ -334,26 +359,26 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr) break; case YAZ_MARC_LINE: wrbuf_puts (wr, " $"); - for (j = 1; j"); break; case YAZ_MARC_OAIMARC: wrbuf_puts (wr, " "); break; case YAZ_MARC_MARCXML: wrbuf_puts (wr, " "); break; }