scripts/nightly: add configuration for i386 build on vault13
[AROS.git] / compiler / posixc / fgetc.c
blobf68cceb7572a73dd425887662ff8ae029946c511
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function fgetc().
6 */
8 #include <errno.h>
9 #include <dos/dos.h>
10 #include <dos/dosextens.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include "__fdesc.h"
14 #include "__stdio.h"
16 #define DEBUG 0
17 #include <aros/debug.h>
19 /*****************************************************************************
21 NAME */
22 #include <stdio.h>
24 int fgetc (
26 /* SYNOPSIS */
27 FILE * stream)
29 /* FUNCTION
30 Read one character from the stream. If there is no character
31 available or an error occurred, the function returns EOF.
33 INPUTS
34 stream - Read from this stream
36 RESULT
37 The character read or EOF on end of file or error.
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 getc(), fputc(), putc()
48 INTERNALS
50 ******************************************************************************/
52 int c;
53 fdesc *fdesc = __getfdesc(stream->fd);
55 if (!fdesc)
57 errno = EBADF;
58 stream->flags |= __POSIXC_STDIO_ERROR;
59 return EOF;
62 /* Note: changes here might require changes in vfscanf.c!! */
64 FLUSHONREADCHECK
66 c = FGetC (fdesc->fcb->handle);
67 if (c == EOF)
69 c = IoErr ();
71 if (c)
73 errno = __stdc_ioerr2errno (c);
75 stream->flags |= __POSIXC_STDIO_ERROR;
77 else
78 stream->flags |= __POSIXC_STDIO_EOF;
80 c = EOF;
83 return c;
84 } /* fgetc */