133641Sbostic /* 233641Sbostic * Copyright (c) 1988 Regents of the University of California. 333641Sbostic * All rights reserved. 433641Sbostic * 533641Sbostic * Redistribution and use in source and binary forms are permitted 6*34871Sbostic * provided that the above copyright notice and this paragraph are 7*34871Sbostic * duplicated in all such forms and that any documentation, 8*34871Sbostic * advertising materials, and other materials related to such 9*34871Sbostic * distribution and use acknowledge that the software was developed 10*34871Sbostic * by the University of California, Berkeley. The name of the 11*34871Sbostic * University may not be used to endorse or promote products derived 12*34871Sbostic * from this software without specific prior written permission. 13*34871Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14*34871Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15*34871Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1633641Sbostic * 17*34871Sbostic * @(#)docopy.c 7.2 (Berkeley) 06/29/88 1833641Sbostic */ 19*34871Sbostic 2033641Sbostic #define SIZE 10240 2133641Sbostic 2233641Sbostic docopy(from, to, nrecs) 2333641Sbostic register int from, to, nrecs; 2433641Sbostic { 2533641Sbostic register int record, rcc, wcc; 2633641Sbostic char buf[SIZE]; 2733641Sbostic 2833641Sbostic for (record = 0;;) { 2933641Sbostic if (!(rcc = read(from, buffer, SIZE))) 3033641Sbostic break; 3133641Sbostic if (rcc < 0) { 3233641Sbostic printf("Record %d: read error, errno=%d\n", 3333641Sbostic record, errno); 3433641Sbostic break; 3533641Sbostic } 3633641Sbostic if (rcc < SIZE) 3733641Sbostic printf("Record %d: read short; expected %d, got %d\n", 3833641Sbostic record, SIZE, rcc); 3933641Sbostic #ifdef vax 4033641Sbostic /* For bug in ht driver. */ 4133641Sbostic if (rcc > SIZE) 4233641Sbostic rcc = SIZE; 4333641Sbostic #endif 4433641Sbostic if ((wcc = write(to, buffer, rcc)) < 0) { 4533641Sbostic printf("Record %d: write error: errno=%d\n", 4633641Sbostic record, errno); 4733641Sbostic break; 4833641Sbostic } 4933641Sbostic if (wcc < rcc) { 5033641Sbostic printf("Record %d: write short; expected %d, got %d\n", 5133641Sbostic record, rcc, wcc); 5233641Sbostic break; 5333641Sbostic } 5433641Sbostic if (nrecs > 0 && ++record == nrecs) 5533641Sbostic break; 5633641Sbostic } 5733641Sbostic printf("copy completed: %d records copied\n", record); 5833641Sbostic } 59