X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmarcdisp.c;h=2e3f96a333dfabc6b32867543c47e81932d59732;hb=05c274ef315384faafcc5900c17468f0ea2474e6;hp=1266d250baace991d7c9eb38e3fd7d535d146d18;hpb=a19316337aa3e23b74dac29e5dcad06493ecf083;p=yaz-moved-to-github.git diff --git a/src/marcdisp.c b/src/marcdisp.c index 1266d25..2e3f96a 100644 --- a/src/marcdisp.c +++ b/src/marcdisp.c @@ -1,8 +1,13 @@ /* - * Copyright (c) 1995-2003, Index Data + * Copyright (c) 1995-2004, Index Data * See the file LICENSE for details. * - * $Id: marcdisp.c,v 1.3 2003-12-17 12:28:07 adam Exp $ + * $Id: marcdisp.c,v 1.8 2004-10-15 00:19:00 adam Exp $ + */ + +/** + * \file marcdisp.c + * \brief Implements MARC display - and conversion utilities */ #if HAVE_CONFIG_H @@ -43,56 +48,12 @@ 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) - { wrbuf_iconv_write(wr, mt->iconv_cd, buf, len); - } else - { - int j = 0; - for (i = 0; i j) - wrbuf_iconv_write(wr, mt->iconv_cd, buf+j, i-j); - wrbuf_puts(wr, "<"); - j=i+1; - break; - case '>': - if (i > j) - wrbuf_iconv_write(wr, mt->iconv_cd, buf+j, i-j); - wrbuf_puts(wr, ">"); - j=i+1; - break; - case '&': - if (i > j) - wrbuf_iconv_write(wr, mt->iconv_cd, buf+j, i-j); - wrbuf_puts(wr, "&"); - j=i+1; - break; - case '"': - if (i > j) - wrbuf_iconv_write(wr, mt->iconv_cd, buf+j, i-j); - wrbuf_puts(wr, """); - j=i+1; - break; - case '\'': - if (i > j) - wrbuf_iconv_write(wr, mt->iconv_cd, buf+j, i-j); - wrbuf_puts(wr, "'"); - j=i+1; - break; - } - } - if (i > j) - wrbuf_iconv_write(wr, mt->iconv_cd, buf+j, i-j); - } + wrbuf_iconv_write_cdata(wr, mt->iconv_cd, buf, len); } int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr) @@ -177,7 +138,15 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr) wrbuf_printf( wr, "\n" - " %.24s\n", buf); + " "); +#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; } } @@ -307,19 +276,25 @@ 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, ""); break; case YAZ_MARC_OAIMARC: wrbuf_puts (wr, " "); break; case YAZ_MARC_MARCXML: wrbuf_puts (wr, " "); break; }