2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)filewrite.c 1.14 04/08/08 Copyright 1986, 1995-2003 J. Schilling */
15 * Copyright (c) 1986, 1995-2003 J. Schilling
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License version 2
20 * as published by the Free Software Foundation.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License along with
28 * this program; see the file COPYING. If not, write to the Free Software
29 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 static char _writeerr[] = "file_write_err";
39 filewrite(f, vbuf, len)
48 down2(f, _IOWRT, _IORW);
50 if (f->_flag & _IONBF) {
51 cnt = write(fileno(f), buf, len);
54 if (!(my_flag(f) & _IONORAISE))
55 raisecond(_writeerr, 0L);
62 if (usg_flsbuf((unsigned char) *buf++, f) == EOF)
68 if ((n = f->_cnt >= len ? len : f->_cnt) > 0) {
69 f->_ptr = (unsigned char *)movebytes(buf, f->_ptr, n);
78 if (!(my_flag(f) & _IONORAISE))
79 raisecond(_writeerr, 0L);
86 filewrite(f, vbuf, len)
94 down2(f, _IOWRT, _IORW);
96 if (my_flag(f) & _IOUNBUF)
97 return (write(fileno(f), buf, len));
98 cnt = fwrite(buf, 1, len, f);
102 if (!(my_flag(f) & _IONORAISE))
103 raisecond(_writeerr, 0L);
107 #endif /* HAVE_USG_STDIO */