xref: /csrg-svn/local/local.cmd/20b.c (revision 33478)
130246Smckusick /*
230246Smckusick  * Copyright (c) 1986 Regents of the University of California.
3*33478Sbostic  * All rights reserved.
4*33478Sbostic  *
5*33478Sbostic  * Redistribution and use in source and binary forms are permitted
6*33478Sbostic  * provided that this notice is preserved and that due credit is given
7*33478Sbostic  * to the University of California at Berkeley. The name of the University
8*33478Sbostic  * may not be used to endorse or promote products derived from this
9*33478Sbostic  * software without specific prior written permission. This software
10*33478Sbostic  * is provided ``as is'' without express or implied warranty.
1130246Smckusick  */
1230246Smckusick 
1330246Smckusick #ifndef lint
1430246Smckusick char copyright[] =
1530246Smckusick "@(#) Copyright (c) 1986 Regents of the University of California.\n\
1630246Smckusick  All rights reserved.\n";
17*33478Sbostic #endif /* not lint */
1830246Smckusick 
1930246Smckusick #ifndef lint
20*33478Sbostic static char sccsid[] = "@(#)20b.c	5.2 (Berkeley) 02/08/88";
21*33478Sbostic #endif /* not lint */
2230246Smckusick 
23*33478Sbostic #define BSIZE	(20 * 512)
2430246Smckusick main()
2530246Smckusick {
2630246Smckusick 	register char *base, *current;
2730246Smckusick 	register int cc, want;
2830246Smckusick 	char *alloca();
2930246Smckusick 
30*33478Sbostic 	base = alloca(BSIZE);
31*33478Sbostic 	for (cc = BSIZE; cc > 0;) {
3230246Smckusick 		current = base;
33*33478Sbostic 		for (want = BSIZE; want > 0 && cc > 0; want -= cc) {
34*33478Sbostic 			if ((cc = read(0, current, want)) < 0)
35*33478Sbostic 				return(-1);
3630246Smckusick 			current += cc;
3730246Smckusick 		}
38*33478Sbostic 		want = BSIZE - want;
39*33478Sbostic 		if (want && write(1, base, want) != want)
40*33478Sbostic 			return(-1);
4130246Smckusick 	}
4230246Smckusick 	return(0);
4330246Smckusick }
44