xref: /csrg-svn/sys/i386/floppy/cat/cat.c (revision 63336)
149537Sbostic /*-
2*63336Sbostic  * Copyright (c) 1991, 1993
3*63336Sbostic  *	The Regents of the University of California.  All rights reserved.
449537Sbostic  *
549537Sbostic  * %sccs.include.redist.c%
649537Sbostic  *
7*63336Sbostic  *	@(#)cat.c	8.1 (Berkeley) 06/11/93
849537Sbostic  */
949537Sbostic 
1049537Sbostic int eval;
1149537Sbostic 
main(argc,argv)1249537Sbostic main(argc, argv)
1349537Sbostic 	int argc;
1449537Sbostic 	char **argv;
1549537Sbostic {
1649537Sbostic 	register int fd, nr;
1749537Sbostic 	char buf[2048];
1849537Sbostic 
1949537Sbostic 	if (*++argv && **argv == '-') {
2049537Sbostic 		err("no options available", 0);
2149537Sbostic 		_exit(1);
2249537Sbostic 	}
2349537Sbostic 	for (eval = 0; *argv; ++argv)
2449537Sbostic 		if ((fd = open(*argv, 0, 0)) < 0)
2549537Sbostic 			err(*argv, 1);
2649537Sbostic 		else {
2749537Sbostic 			while ((nr = read(fd, buf, sizeof(buf))) > 0)
2849537Sbostic 				if (write(1, buf, nr) != nr) {
2949537Sbostic 					err(*argv, 1);
3049537Sbostic 					break;
3149537Sbostic 				}
3249537Sbostic 			if (nr == -1)
3349537Sbostic 				err(*argv, 1);
3449537Sbostic 		}
3549537Sbostic 	_exit(eval);
3649537Sbostic }
3749537Sbostic 
3849537Sbostic #define	PROGNAME	"cat: "
3949537Sbostic #include "errfunction"
40