Commit | Line | Data |
---|---|---|
777c02a3 KB |
1 | /* |
2 | * Copyright (c) 1988 Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
9c50374f KB |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
777c02a3 | 16 | * |
9c50374f | 17 | * @(#)docopy.c 7.2 (Berkeley) %G% |
777c02a3 | 18 | */ |
9c50374f | 19 | |
777c02a3 KB |
20 | #define SIZE 10240 |
21 | ||
22 | docopy(from, to, nrecs) | |
23 | register int from, to, nrecs; | |
24 | { | |
25 | register int record, rcc, wcc; | |
26 | char buf[SIZE]; | |
27 | ||
28 | for (record = 0;;) { | |
29 | if (!(rcc = read(from, buffer, SIZE))) | |
30 | break; | |
31 | if (rcc < 0) { | |
32 | printf("Record %d: read error, errno=%d\n", | |
33 | record, errno); | |
34 | break; | |
35 | } | |
36 | if (rcc < SIZE) | |
37 | printf("Record %d: read short; expected %d, got %d\n", | |
38 | record, SIZE, rcc); | |
39 | #ifdef vax | |
40 | /* For bug in ht driver. */ | |
41 | if (rcc > SIZE) | |
42 | rcc = SIZE; | |
43 | #endif | |
44 | if ((wcc = write(to, buffer, rcc)) < 0) { | |
45 | printf("Record %d: write error: errno=%d\n", | |
46 | record, errno); | |
47 | break; | |
48 | } | |
49 | if (wcc < rcc) { | |
50 | printf("Record %d: write short; expected %d, got %d\n", | |
51 | record, rcc, wcc); | |
52 | break; | |
53 | } | |
54 | if (nrecs > 0 && ++record == nrecs) | |
55 | break; | |
56 | } | |
57 | printf("copy completed: %d records copied\n", record); | |
58 | } |