2 * Copyright (c) 1995-2002, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: marcdump.c,v 1.14 2002-02-28 14:28:40 adam Exp $
17 #include <yaz/wrbuf.h>
18 #include <yaz/marcdisp.h>
19 #include <yaz/yaz-util.h>
20 #include <yaz/xmalloc.h>
21 #include <yaz/options.h>
30 int main (int argc, char **argv)
42 while ((r = options("vc:x", argv, argc, &arg)) != -2)
51 cfile = fopen (arg, "w");
57 inf = fopen (arg, "r");
61 fprintf (stderr, "%s: cannot open %s:%s\n",
62 prog, arg, strerror (errno));
66 fprintf (cfile, "char *marc_records[] = {\n");
69 WRBUF wr = wrbuf_alloc();
73 r = fread (buf, 1, 5, inf);
77 if (len < 25 || len > 100000)
80 r = fread (buf + 5, 1, len, inf);
83 r = yaz_marc_decode (buf, wr, verbose, -1, xml);
86 fwrite (wrbuf_buf(wr), wrbuf_len(wr), 1, stdout);
93 fprintf (cfile, "{\n");
94 for (i = 0; i < r; i++)
97 fprintf (cfile, " \"");
98 fprintf (cfile, "\\x%02X", p[i] & 255);
100 if (i < r - 1 && (i & 15) == 15)
101 fprintf (cfile, "\"\n");
104 fprintf (cfile, "\"\n}");
109 fprintf (cfile, "};\n");
115 fprintf (stderr, "Usage: %s [-c cfile] [-v] file...\n", prog);
123 fprintf (stderr, "Usage: %s [-v] file...\n", prog);