perl: fix -Wformat-security warning in ENDMESSAGE()
[nvi.git] / catalog / dump.c
blob36c4800ee6c270a77c0f08885e24b2a96d9a3104
1 /*-
2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
6 */
8 #ifndef lint
9 static char copyright[] =
10 "%Z% Copyright (c) 1992, 1993, 1994\n\
11 The Regents of the University of California. All rights reserved.\n";
12 #endif /* not lint */
14 #ifndef lint
15 static char sccsid[] = "$Id: dump.c,v 8.1 1994/08/31 13:27:37 bostic Exp $ (Berkeley) $Date: 1994/08/31 13:27:37 $";
16 #endif /* not lint */
18 #include <ctype.h>
19 #include <stdio.h>
21 static void
22 parse(fp)
23 FILE *fp;
25 int ch, s1, s2, s3;
27 #define TESTD(s) { \
28 if ((s = getc(fp)) == EOF) \
29 return; \
30 if (!isdigit(s)) \
31 continue; \
33 #define TESTP { \
34 if ((ch = getc(fp)) == EOF) \
35 return; \
36 if (ch != '|') \
37 continue; \
39 #define MOVEC(t) { \
40 do { \
41 if ((ch = getc(fp)) == EOF) \
42 return; \
43 } while (ch != (t)); \
45 for (;;) {
46 MOVEC('"');
47 TESTD(s1);
48 TESTD(s2);
49 TESTD(s3);
50 TESTP;
51 putchar('"');
52 putchar(s1);
53 putchar(s2);
54 putchar(s3);
55 putchar('|');
56 for (;;) { /* dump to end quote. */
57 if ((ch = getc(fp)) == EOF)
58 return;
59 putchar(ch);
60 if (ch == '"')
61 break;
62 if (ch == '\\') {
63 if ((ch = getc(fp)) == EOF)
64 return;
65 putchar(ch);
68 putchar('\n');
72 int
73 main(argc, argv)
74 int argc;
75 char *argv[];
77 FILE *fp;
79 for (; *argv != NULL; ++argv) {
80 if ((fp = fopen(*argv, "r")) == NULL) {
81 perror(*argv);
82 exit (1);
84 parse(fp);
85 (void)fclose(fp);
87 exit (0);