Update contrib.
3 * Portions Copyright (c) 1990-2005 Nokia Corporation and/or its subsidiary(-ies).
8 * Copyright (c) 1990 The Regents of the University of California.
11 * Redistribution and use in source and binary forms are permitted
12 * provided that the above copyright notice and this paragraph are
13 * duplicated in all such forms and that any documentation,
14 * advertising materials, and other materials related to such
15 * distribution and use acknowledge that the software was developed
16 * by the University of California, Berkeley. The name of the
17 * University may not be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26 <<fwrite>>---write array elements
33 size_t fwrite(const void *<[buf]>, size_t <[size]>,
34 size_t <[count]>, FILE *<[fp]>);
38 size_t fwrite(<[buf]>, <[size]>, <[count]>, <[fp]>)
45 <<fwrite>> attempts to copy, starting from the memory location
46 <[buf]>, <[count]> elements (each of size <[size]>) into the file or
47 stream identified by <[fp]>. <<fwrite>> may copy fewer elements than
48 <[count]> if an error intervenes.
50 <<fwrite>> also advances the file position indicator (if any) for
51 <[fp]> by the number of @emph{characters} actually written.
54 If <<fwrite>> succeeds in writing all the elements you specify, the
55 result is the same as the argument <[count]>. In any event, the
56 result is the number of complete elements that <<fwrite>> copied to
60 ANSI C requires <<fwrite>>.
62 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
63 <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
72 * Write `count' objects (each size `size') from memory to the given file.
73 * Return the number of whole objects written.
77 fwrite (const void *buf, size_t size, size_t count, FILE * fp)
84 uio.uio_resid = iov.iov_len = n = count * size;
89 * The usual case is success (__sfvwrite returns 0);
90 * skip the divide if this happens, since divides are
91 * generally slow and since this occurs whenever size==0.
94 if (__sfvwrite (fp, &uio) == 0)
96 return (n - uio.uio_resid) / size;