X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fmarcdisp.c;h=f728d12a699ac2754929a71365ac07c661fc648e;hb=f722c8d9517ec491e2469cdc91a3751dd5e7a6df;hp=03bb37c1ff60b94d31124541135e7c737b4f794e;hpb=8e8cb340836e3ffd48d464755903f6795754a226;p=yaz-moved-to-github.git diff --git a/util/marcdisp.c b/util/marcdisp.c index 03bb37c..f728d12 100644 --- a/util/marcdisp.c +++ b/util/marcdisp.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2002, Index Data * See the file LICENSE for details. * - * $Id: marcdisp.c,v 1.17 2002-02-01 14:50:29 adam Exp $ + * $Id: marcdisp.c,v 1.18 2002-02-28 13:21:16 adam Exp $ */ #if HAVE_CONFIG_H @@ -16,8 +16,7 @@ #include #include -int marc_display_wrbuf (const char *buf, WRBUF wr, int debug, - int bsize) +int yaz_marc_decode (const char *buf, WRBUF wr, int debug, int bsize, int xml) { int entry_p; int record_length; @@ -94,10 +93,19 @@ int marc_display_wrbuf (const char *buf, WRBUF wr, int debug, memcpy (tag, buf+entry_p, 3); entry_p += 3; tag[3] = '\0'; - if (debug) - wrbuf_puts (wr, "Tag: "); - wrbuf_puts (wr, tag); - wrbuf_puts (wr, " "); + if (xml) + { + wrbuf_puts (wr, ""); + if (identifier_flag) + wrbuf_puts (wr, "\n"); + } + else + { + if (debug) + wrbuf_puts (wr, " Fields: "); + } while (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS && i < end_offset) { if (identifier_flag) { i++; - wrbuf_puts (wr, " $"); - for (j = 1; j"); + } + else + { + wrbuf_puts (wr, " $"); + for (j = 1; j\n"); } else { @@ -144,16 +182,25 @@ int marc_display_wrbuf (const char *buf, WRBUF wr, int debug, i++; } } - wrbuf_putc (wr, '\n'); + if (!xml) + wrbuf_putc (wr, '\n'); if (i < end_offset) - wrbuf_puts (wr, "-- separator but not at end of field\n"); + wrbuf_puts (wr, " \n"); if (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS) - wrbuf_puts (wr, "-- no separator at end of field\n"); + wrbuf_puts (wr, " \n"); + if (xml) + wrbuf_puts (wr, "\n"); } wrbuf_puts (wr, ""); return record_length; } +int marc_display_wrbuf (const char *buf, WRBUF wr, int debug, + int bsize) +{ + return yaz_marc_decode (buf, wr, debug, bsize, 0); +} + int marc_display_exl (const char *buf, FILE *outf, int debug, int length) { int record_length; @@ -168,7 +215,6 @@ int marc_display_exl (const char *buf, FILE *outf, int debug, int length) return record_length; } - int marc_display_ex (const char *buf, FILE *outf, int debug) { return marc_display_exl (buf, outf, debug, -1);