Annotation of src/usr.bin/asa/asa.c, Revision 1.2
1.2 ! deraadt 1: /* $OpenBSD: asa.c,v 1.10 1995/04/21 03:01:41 cgd Exp $ */
1.1 deraadt 2: /* $NetBSD: asa.c,v 1.10 1995/04/21 03:01:41 cgd Exp $ */
3:
4: /*
5: * Copyright (c) 1993,94 Winning Strategies, Inc.
6: * All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
16: * 3. All advertising materials mentioning features or use of this software
17: * must display the following acknowledgement:
18: * This product includes software developed by Winning Strategies, Inc.
19: * 4. The name of the author may not be used to endorse or promote products
20: * derived from this software without specific prior written permission
21: *
22: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32: */
33:
34: #ifndef lint
1.2 ! deraadt 35: static char rcsid[] = "$OpenBSD: asa.c,v 1.10 1995/04/21 03:01:41 cgd Exp $";
1.1 deraadt 36: #endif
37:
38: #include <stdio.h>
39: #include <stdlib.h>
40: #include <err.h>
41:
42: static void asa();
43:
44: int
45: main (argc, argv)
46: int argc;
47: char **argv;
48: {
49: FILE *fp;
50:
51: /* skip progname */
52: argv++;
53:
54: fp = stdin;
55: do {
56: if (*argv) {
57: if (!(fp = fopen(*argv, "r"))) {
58: warn ("%s", *argv);
59: continue;
60: }
61: }
62: asa (fp);
63: if (fp != stdin)
64: (void)fclose(fp);
65: } while (*argv++);
66:
67: exit (0);
68: }
69:
70: static void
71: asa(f)
72: FILE *f;
73: {
74: char *buf;
75: size_t len;
76:
77: if ((buf = fgetln (f, &len)) != NULL) {
78: buf[len - 1] = '\0';
79: /* special case the first line */
80: switch (buf[0]) {
81: case '0':
82: putchar ('\n');
83: break;
84: case '1':
85: putchar ('\f');
86: break;
87: }
88:
89: if (buf[0] && buf[1]) {
90: fputs (&buf[1], stdout);
91: }
92:
93: while ((buf = fgetln(f, &len)) != NULL) {
94: buf[len - 1] = '\0';
95: switch (buf[0]) {
96: default:
97: case ' ':
98: putchar ('\n');
99: break;
100: case '0':
101: putchar ('\n');
102: putchar ('\n');
103: break;
104: case '1':
105: putchar ('\f');
106: break;
107: case '+':
108: putchar ('\r');
109: break;
110: }
111:
112: if (buf[0] && buf[1]) {
113: fputs (&buf[1], stdout);
114: }
115: }
116:
117: putchar ('\n');
118: }
119: }