alsa.audio: limit the supported frequencies to common set
[AROS.git] / compiler / stdc / fgetc.c
blob5620eb8e210f0d790dcf25028e2708d3d4e3cae7
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function fgetc().
6 */
8 #include <dos/dos.h>
9 #include <proto/dos.h>
10 #include <errno.h>
12 #include "__stdio.h"
14 /*****************************************************************************
16 NAME */
17 #include <stdio.h>
19 int fgetc (
21 /* SYNOPSIS */
22 FILE * stream)
24 /* FUNCTION
25 Read one character from the stream. If there is no character
26 available or an error occurred, the function returns EOF.
28 INPUTS
29 stream - Read from this stream
31 RESULT
32 The character read or EOF on end of file or error.
33 If EOF is returned feof() and ferror() indicate if it was an
34 end-of-file situation or an error.
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
43 getc(), feof(), ferror(), fputc(), putc()
45 INTERNALS
47 ******************************************************************************/
49 LONG c, ioerr;
51 if (!(stream->flags & __STDCIO_STDIO_READ))
53 SetIoErr(ERROR_READ_PROTECTED);
54 errno = EACCES;
55 stream->flags |= __STDCIO_STDIO_ERROR;
56 return EOF;
59 if (stream->flags & __STDCIO_STDIO_FLUSHONREAD)
61 Flush(stream->fh);
62 stream->flags &= ~__STDCIO_STDIO_FLUSHONREAD;
65 c = FGetC (stream->fh);
66 if (c == EOF)
68 ioerr = IoErr ();
70 if (ioerr)
72 errno = __stdc_ioerr2errno (ioerr);
73 stream->flags |= __STDCIO_STDIO_ERROR;
75 else
76 stream->flags |= __STDCIO_STDIO_EOF;
79 return (int)c;
80 } /* fgetc */