Commit | Line | Data |
---|---|---|
fe4a0cc6 KM |
1 | /* |
2 | * Copyright (c) 1986 Regents of the University of California. | |
78a3c717 KB |
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. | |
fe4a0cc6 KM |
11 | */ |
12 | ||
13 | #ifndef lint | |
14 | char copyright[] = | |
15 | "@(#) Copyright (c) 1986 Regents of the University of California.\n\ | |
16 | All rights reserved.\n"; | |
78a3c717 | 17 | #endif /* not lint */ |
fe4a0cc6 KM |
18 | |
19 | #ifndef lint | |
6a850152 | 20 | static char sccsid[] = "@(#)20b.c 5.3 (Berkeley) %G%"; |
78a3c717 | 21 | #endif /* not lint */ |
fe4a0cc6 | 22 | |
6a850152 KB |
23 | #include <stdio.h> |
24 | ||
25 | main(argc, argv) | |
26 | int argc; | |
27 | char **argv; | |
fe4a0cc6 | 28 | { |
6a850152 | 29 | register int bsize, cc, want; |
fe4a0cc6 | 30 | register char *base, *current; |
fe4a0cc6 KM |
31 | char *alloca(); |
32 | ||
6a850152 KB |
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;) { | |
fe4a0cc6 | 42 | current = base; |
6a850152 | 43 | for (want = bsize; want > 0 && cc > 0; want -= cc) { |
78a3c717 KB |
44 | if ((cc = read(0, current, want)) < 0) |
45 | return(-1); | |
fe4a0cc6 KM |
46 | current += cc; |
47 | } | |
6a850152 | 48 | want = bsize - want; |
78a3c717 KB |
49 | if (want && write(1, base, want) != want) |
50 | return(-1); | |
fe4a0cc6 KM |
51 | } |
52 | return(0); | |
53 | } |