2 * Iso2709 record management
4 * Europagate, 1994-1995.
6 * $Log: iso2709dump.c,v $
7 * Revision 1.7 1995/03/28 16:07:07 adam
8 * New function: iso2709_out. This function is the reverse of iso2709_cvt.
10 * Revision 1.6 1995/03/27 12:52:18 adam
11 * A little more verbose in marc dump.
13 * Revision 1.5 1995/02/22 21:32:36 adam
16 * Revision 1.3 1995/02/10 17:05:18 adam
17 * New function iso2709_display to display MARC records in a
18 * line-by-line format. The iso2709_cvt function no longer
19 * prints the record to stderr.
21 * Revision 1.2 1995/02/10 16:50:33 adam
22 * Indicator field moved to 'struct iso2709_dir' from 'struct
24 * Function iso2709_rm implemented - to delete a MARC record.
26 * Revision 1.1.1.1 1995/02/09 17:27:11 adam
27 * Initial version of email gateway under CVS control.
39 int main (int argc, char **argv)
46 char *output_file = NULL;
47 char *input_file = NULL;
62 fprintf (stderr, "iso2709dump [options] [file]\n");
63 fprintf (stderr, "If no file is specified stdin is used\n");
64 fprintf (stderr, "Options:\n");
65 fprintf (stderr, " -p no Starting position\n");
66 fprintf (stderr, " -l end Ending position\n");
67 fprintf (stderr, " -o file Raw MARC output file\n");
68 fprintf (stderr, " -v Verbose\n");
69 fprintf (stderr, " -q Quiet mode\n");
73 start_pos = atoi (argv[0]+2);
77 start_pos = atoi (*++argv);
81 fprintf (stderr, "%s: missing start pos\n", prog);
87 end_pos = atoi (argv[0]+2);
91 end_pos = atoi (*++argv);
95 fprintf (stderr, "%s: missing end pos\n", prog);
101 output_file = argv[0]+2;
105 output_file = *++argv;
109 fprintf (stderr, "%s: missing output file\n", prog);
120 fprintf (stderr, "%s: unknown option %s; use -h for help\n",
130 inf = fopen (input_file, "r");
133 fprintf (stderr, "%s: cannot open %s: %s\n",
134 prog, input_file, strerror (errno));
140 outf = fopen (output_file, "w");
143 fprintf (stderr, "%s: cannot open %s: %s\n",
144 prog, output_file, strerror (errno));
148 while ((buf = iso2709_read (inf)))
150 if (no >= start_pos && no <= end_pos)
155 rec = iso2709_cvt (buf);
157 printf ("------- %d --------\n", no);
161 printf ("Bad record\n");
162 fprintf (stderr, "%s: bad record at position %d\n", prog, no);
165 olen = iso2709_out (rec, &obuf, 0);
167 iso2709_display (rec, stdout);
168 if (outf && fwrite (obuf, 1, olen, outf) != olen)
170 fprintf (stderr, "%s: write fail of %s: %s\n",
171 prog, output_file, strerror (errno));