1 /* 2 * Copyright (c) 1986 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 */ 12 13 #ifndef lint 14 char copyright[] = 15 "@(#) Copyright (c) 1986 Regents of the University of California.\n\ 16 All rights reserved.\n"; 17 #endif /* not lint */ 18 19 #ifndef lint 20 static char sccsid[] = "@(#)20b.c 5.3 (Berkeley) 02/09/88"; 21 #endif /* not lint */ 22 23 #include <stdio.h> 24 25 main(argc, argv) 26 int argc; 27 char **argv; 28 { 29 register int bsize, cc, want; 30 register char *base, *current; 31 char *alloca(); 32 33 if (argc > 1) { 34 bsize = atoi(argv[1]); 35 if (bsize <= 0) { 36 fputs("20b: bad block size.\n", stderr); 37 exit(-1); 38 } 39 } 40 base = alloca(bsize); 41 for (cc = bsize; cc > 0;) { 42 current = base; 43 for (want = bsize; want > 0 && cc > 0; want -= cc) { 44 if ((cc = read(0, current, want)) < 0) 45 return(-1); 46 current += cc; 47 } 48 want = bsize - want; 49 if (want && write(1, base, want) != want) 50 return(-1); 51 } 52 return(0); 53 } 54