From 635dd986bff70edc8e8c39067bcc702e59215b56 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 18 Mar 2002 18:11:45 +0000 Subject: [PATCH] MARC to XML ala JZKit --- util/marcdisp.c | 38 +++++++++++++++++++++++++++++++------- util/marcdump.c | 13 +++++++++---- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/util/marcdisp.c b/util/marcdisp.c index f728d12..840c0b1 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.18 2002-02-28 13:21:16 adam Exp $ + * $Id: marcdisp.c,v 1.19 2002-03-18 18:11:45 adam Exp $ */ #if HAVE_CONFIG_H @@ -56,9 +56,28 @@ int yaz_marc_decode (const char *buf, WRBUF wr, int debug, int bsize, int xml) length_starting = atoi_n (buf+21, 1); length_implementation = atoi_n (buf+22, 1); + if (xml) + { + char str[40]; + int i; + wrbuf_puts (wr, "\n"); + } if (debug) { char str[40]; + + if (xml) + wrbuf_puts (wr, "\n"); } + for (entry_p = 24; buf[entry_p] != ISO2709_FS; ) { entry_p += 3+length_data_entry+length_starting; @@ -95,7 +117,7 @@ int yaz_marc_decode (const char *buf, WRBUF wr, int debug, int bsize, int xml) tag[3] = '\0'; if (xml) { - wrbuf_puts (wr, ""); @@ -174,7 +196,7 @@ int yaz_marc_decode (const char *buf, WRBUF wr, int debug, int bsize, int xml) i++; } if (xml) - wrbuf_puts (wr, "\n"); + wrbuf_puts (wr, "\n"); } else { @@ -191,6 +213,8 @@ int yaz_marc_decode (const char *buf, WRBUF wr, int debug, int bsize, int xml) if (xml) wrbuf_puts (wr, "\n"); } + if (xml) + wrbuf_puts (wr, "\n"); wrbuf_puts (wr, ""); return record_length; } diff --git a/util/marcdump.c b/util/marcdump.c index 772cc29..43ce28f 100644 --- a/util/marcdump.c +++ b/util/marcdump.c @@ -3,7 +3,7 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: marcdump.c,v 1.14 2002-02-28 14:28:40 adam Exp $ + * $Id: marcdump.c,v 1.15 2002-03-18 18:11:45 adam Exp $ */ #if HAVE_CONFIG_H @@ -26,7 +26,12 @@ #ifndef SEEK_END #define SEEK_END 2 #endif - + +static void usage(const char *prog) +{ + fprintf (stderr, "Usage: %s [-c cfile] [-x] [-v] file...\n", prog); +} + int main (int argc, char **argv) { int r; @@ -112,7 +117,7 @@ int main (int argc, char **argv) verbose++; break; default: - fprintf (stderr, "Usage: %s [-c cfile] [-v] file...\n", prog); + usage(prog); exit (1); } } @@ -120,7 +125,7 @@ int main (int argc, char **argv) fclose (cfile); if (!no) { - fprintf (stderr, "Usage: %s [-v] file...\n", prog); + usage(prog); exit (1); } exit (0); -- 1.7.10.4