1
/* $NetBSD: ffilecopy.c,v 1.6 2003/04/03 17:14:24 christos Exp $ */
2
4
* Copyright (c) 1991 Carnegie Mellon University
3
5
* All Rights Reserved.
5
7
* Permission to use, copy, modify and distribute this software and its
6
8
* documentation is hereby granted, provided that both the copyright
7
9
* notice and this permission notice appear in all copies of the
51
#include "supextern.h"
50
int ffilecopy (here,there)
54
ffilecopy(FILE * here, FILE * there)
53
register int i, herefile, therefile;
56
int i, herefile, therefile;
55
58
herefile = fileno(here);
56
59
therefile = fileno(there);
58
if (fflush (there) == EOF) /* flush pending output */
61
if (fflush(there) == EOF) /* flush pending output */
63
if ((here->_r) > 0) { /* flush buffered input */
64
i = write (therefile, here->_p, here->_r);
65
if (i != here->_r) return (EOF);
64
#if defined(__386BSD__) || defined(__NetBSD__)
65
if ((here->_r) > 0) { /* flush buffered input */
66
i = write(therefile, here->_p, here->_r);
66
69
here->_p = here->_bf._base;
70
if ((here->_cnt) > 0) { /* flush buffered input */
71
i = write (therefile, here->_ptr, here->_cnt);
72
if (i != here->_cnt) return (EOF);
74
if ((here->_cnt) > 0) { /* flush buffered input */
75
i = write(therefile, here->_ptr, here->_cnt);
73
78
here->_ptr = here->_base;
79
i = filecopy (herefile, therefile); /* fast file copy */
80
if (i < 0) return (EOF);
84
(here->_flags) |= __SEOF; /* indicate EOF */
86
(here->_flag) |= _IOEOF; /* indicate EOF */
83
i = filecopy(herefile, therefile); /* fast file copy */
87
#if defined(__386BSD__) || defined(__NetBSD__)
88
(here->_flags) |= __SEOF; /* indicate EOF */
91
(here->_flag) |= _IOEOF; /* indicate EOF */
93
(void)fseeko(here, (off_t)0, SEEK_END); /* seek to end */