home *** CD-ROM | disk | FTP | other *** search
- /*
- (C) 1995-96 AROS - The Amiga Replacement OS
- $Id: fgetc.c,v 1.6 1997/01/17 16:24:19 digulla Exp $
-
- Desc: ANSI C function fgetc()
- Lang: english
- */
- #include <errno.h>
- #include <dos/dos.h>
- #include <dos/dosextens.h>
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include "__errno.h"
-
- /*****************************************************************************
-
- NAME */
- #include <stdio.h>
-
- int fgetc (
-
- /* SYNOPSIS */
- FILE * stream)
-
- /* FUNCTION
- Read one character from the stream. If there is no character
- available or an error occurred, the function returns EOF.
-
- INPUTS
- stream - Read from this stream
-
- RESULT
- The character read or EOF on end of file or error.
-
- NOTES
-
- EXAMPLE
-
- BUGS
-
- SEE ALSO
- getc(), fputc(), putc()
-
- INTERNALS
-
- HISTORY
- 10.12.1996 digulla created
-
- ******************************************************************************/
- {
- int c;
-
- switch ((IPTR)stream)
- {
- case 1: /* Stdin */
- return FGetC (Input());
-
- case 2: /* Stdout */
- case 3: /* Stderr */
- errno = EINVAL;
- return EOF;
-
- default:
- c = FGetC ((BPTR)stream->fh);
- break;
- }
-
- if (c == EOF)
- {
- errno = IoErr2errno (IoErr ());
-
- if (errno)
- stream->flags |= _STDIO_FILEFLAG_ERROR;
- else
- stream->flags |= _STDIO_FILEFLAG_EOF;
- }
-
- return c;
- } /* fgetc */
-
-