2 * Copyright (c) 1995-2000, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.12 2000-10-02 11:07:45 adam
8 * Added peer_name member for bend_init handler. Changed the YAZ
9 * client so that tcp: can be avoided in target spec.
11 * Revision 1.11 2000/07/04 08:53:22 adam
14 * Revision 1.10 2000/02/29 13:44:55 adam
15 * Check for config.h (currently not generated).
17 * Revision 1.9 1999/11/30 13:47:12 adam
18 * Improved installation. Moved header files to include/yaz.
20 * Revision 1.8 1999/05/26 07:49:35 adam
23 * Revision 1.7 1998/02/11 11:53:36 adam
24 * Changed code so that it compiles as C++.
26 * Revision 1.6 1997/12/12 06:32:33 adam
27 * Added include of string.h.
29 * Revision 1.5 1997/09/24 13:29:40 adam
30 * Added verbose option -v to marcdump utility.
32 * Revision 1.4 1995/11/01 13:55:05 quinn
35 * Revision 1.3 1995/05/16 08:51:12 quinn
36 * License, documentation, and memory fixes
38 * Revision 1.2 1995/05/15 11:56:56 quinn
39 * Debuggng & adjustments.
41 * Revision 1.1 1995/04/10 10:28:47 quinn
42 * Added copy of CCL and MARC display
54 #include <yaz/marcdisp.h>
55 #include <yaz/xmalloc.h>
56 #include <yaz/options.h>
65 int main (int argc, char **argv)
78 while ((ret = options("vc:", argv, argc, &arg)) != -2)
86 cfile = fopen (arg, "w");
89 inf = fopen (arg, "r");
92 fprintf (stderr, "%s: cannot open %s:%s\n",
93 prog, arg, strerror (errno));
96 if (fseek (inf, 0L, SEEK_END))
98 fprintf (stderr, "%s: cannot seek in %s:%s\n",
99 prog, arg, strerror (errno));
102 file_size = ftell (inf);
103 if (fseek (inf, 0L, SEEK_SET))
105 fprintf (stderr, "%s: cannot seek in %s:%s\n",
106 prog, arg, strerror (errno));
109 buf = (char *)xmalloc (file_size);
112 fprintf (stderr, "%s: cannot xmalloc: %s\n",
113 prog, strerror (errno));
116 if ((long) fread (buf, 1, file_size, inf) != file_size)
118 fprintf (stderr, "%s: cannot read %s: %s\n",
119 prog, arg, strerror (errno));
124 fprintf (cfile, "char *marc_records[] = {\n");
126 for (p = buf; (ret = marc_display_ex (p, stdout, verbose)) > 0;)
132 fprintf (cfile, ",");
133 fprintf (cfile, "{\n");
134 for (i = 0; i<ret; i++)
137 fprintf (cfile, " \"");
138 fprintf (cfile, "\\x%02X", p[i] & 255);
140 if (i < ret - 1 && (i & 15) == 15)
141 fprintf (cfile, "\"\n");
144 fprintf (cfile, "\"\n}");
151 fprintf (cfile, "};\n");
160 fprintf (stderr, "Usage: %s [-c cfile] [-v] file...\n", prog);
168 fprintf (stderr, "Usage: %s [-v] file...\n", prog);