compiler/clib: Rename IoErr2errno() to __arosc_ioerr2errno(); function is now defined...
[AROS.git] / compiler / clib / fgetc.c
bloba31b2cfac8140964b14e9b83043a7b036c80e77c
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C 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"
16 /*****************************************************************************
18 NAME */
19 #include <stdio.h>
21 int fgetc (
23 /* SYNOPSIS */
24 FILE * stream)
26 /* FUNCTION
27 Read one character from the stream. If there is no character
28 available or an error occurred, the function returns EOF.
30 INPUTS
31 stream - Read from this stream
33 RESULT
34 The character read or EOF on end of file or error.
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
43 getc(), fputc(), putc()
45 INTERNALS
47 ******************************************************************************/
49 int c;
50 fdesc *fdesc = __getfdesc(stream->fd);
52 if (!fdesc)
54 errno = EBADF;
55 stream->flags |= _STDIO_ERROR;
56 return EOF;
59 /* Note: changes here might require changes in vfscanf.c!! */
61 c = FGetC ((BPTR)(fdesc->fcb->fh));
62 if (c == EOF)
64 c = IoErr ();
66 if (c)
68 errno = __arosc_ioerr2errno (c);
70 stream->flags |= _STDIO_ERROR;
72 else
73 stream->flags |= _STDIO_EOF;
75 c = EOF;
78 return c;
79 } /* fgetc */