Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / nvi / catalog / dump.c
blobeb94c476ba22be8baef71abe000a527548e0d009
1 /* $NetBSD: dump.c,v 1.1.1.2 2008/05/18 14:29:33 aymeric Exp $ */
3 /*-
4 * Copyright (c) 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
7 * %sccs.include.redist.c%
8 */
10 #ifndef lint
11 static char copyright[] =
12 "%Z% Copyright (c) 1992, 1993, 1994\n\
13 The Regents of the University of California. All rights reserved.\n";
14 #endif /* not lint */
16 #ifndef lint
17 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";
18 #endif /* not lint */
20 #include <ctype.h>
21 #include <stdio.h>
22 #include <stdlib.h>
24 static void
25 parse(fp)
26 FILE *fp;
28 int ch, s1, s2, s3;
30 #define TESTD(s) { \
31 if ((s = getc(fp)) == EOF) \
32 return; \
33 if (!isdigit(s)) \
34 continue; \
36 #define TESTP { \
37 if ((ch = getc(fp)) == EOF) \
38 return; \
39 if (ch != '|') \
40 continue; \
42 #define MOVEC(t) { \
43 do { \
44 if ((ch = getc(fp)) == EOF) \
45 return; \
46 } while (ch != (t)); \
48 for (;;) {
49 MOVEC('"');
50 TESTD(s1);
51 TESTD(s2);
52 TESTD(s3);
53 TESTP;
54 putchar('"');
55 putchar(s1);
56 putchar(s2);
57 putchar(s3);
58 putchar('|');
59 for (;;) { /* dump to end quote. */
60 if ((ch = getc(fp)) == EOF)
61 return;
62 putchar(ch);
63 if (ch == '"')
64 break;
65 if (ch == '\\') {
66 if ((ch = getc(fp)) == EOF)
67 return;
68 putchar(ch);
71 putchar('\n');
75 int
76 main(argc, argv)
77 int argc;
78 char *argv[];
80 FILE *fp;
82 for (; *argv != NULL; ++argv) {
83 if ((fp = fopen(*argv, "r")) == NULL) {
84 perror(*argv);
85 exit (1);
87 parse(fp);
88 (void)fclose(fp);
90 exit (0);