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