Added Hebrew keymap.
[AROS.git] / compiler / stdc / fwrite.c
blobd9c3007c797669ffdc13a0d764481933e220ba19
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function fwrite().
6 */
7 #include <proto/dos.h>
8 #include <errno.h>
10 #include "__stdio.h"
12 /*****************************************************************************
14 NAME */
15 #include <stdio.h>
17 size_t fwrite (
19 /* SYNOPSIS */
20 const void * restrict buf,
21 size_t size,
22 size_t nblocks,
23 FILE * restrict stream)
25 /* FUNCTION
26 Write an amount of bytes to a stream.
28 INPUTS
29 buf - The buffer to write to the stream
30 size - Size of one block to write
31 nblocks - The number of blocks to write
32 stream - Write to this stream
34 RESULT
35 The number of blocks written. If no error occurred, this is
36 nblocks. Otherwise examine errno for the reason of the error.
38 SEE ALSO
39 fopen(), fwrite()
41 ******************************************************************************/
43 LONG cnt;
45 if (size == 0 || nblocks == 0)
46 return 0;
48 if (!(stream->flags & __STDCIO_STDIO_WRITE))
50 SetIoErr(ERROR_WRITE_PROTECTED);
51 errno = EACCES;
52 stream->flags |= __STDCIO_STDIO_ERROR;
53 return 0;
56 if ((stream->flags & __STDCIO_STDIO_APPEND))
57 Seek(stream->fh, 0, OFFSET_END);
59 cnt = FWrite (stream->fh, (CONST APTR)buf, size, nblocks);
61 if (cnt == -1)
63 errno = __stdc_ioerr2errno (IoErr ());
64 stream->flags |= __STDCIO_STDIO_ERROR;
66 cnt = 0;
69 return (size_t)cnt;
70 } /* fwrite */