home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / compiler / clib / fgetc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-17  |  1.3 KB  |  81 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: fgetc.c,v 1.6 1997/01/17 16:24:19 digulla Exp $
  4.  
  5.     Desc: ANSI C function fgetc()
  6.     Lang: english
  7. */
  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 "__errno.h"
  14.  
  15. /*****************************************************************************
  16.  
  17.     NAME */
  18. #include <stdio.h>
  19.  
  20.     int fgetc (
  21.  
  22. /*  SYNOPSIS */
  23.     FILE * stream)
  24.  
  25. /*  FUNCTION
  26.     Read one character from the stream. If there is no character
  27.     available or an error occurred, the function returns EOF.
  28.  
  29.     INPUTS
  30.     stream - Read from this stream
  31.  
  32.     RESULT
  33.     The character read or EOF on end of file or error.
  34.  
  35.     NOTES
  36.  
  37.     EXAMPLE
  38.  
  39.     BUGS
  40.  
  41.     SEE ALSO
  42.     getc(), fputc(), putc()
  43.  
  44.     INTERNALS
  45.  
  46.     HISTORY
  47.     10.12.1996 digulla created
  48.  
  49. ******************************************************************************/
  50. {
  51.     int c;
  52.  
  53.     switch ((IPTR)stream)
  54.     {
  55.     case 1: /* Stdin */
  56.     return FGetC (Input());
  57.  
  58.     case 2: /* Stdout */
  59.     case 3: /* Stderr */
  60.     errno = EINVAL;
  61.     return EOF;
  62.  
  63.     default:
  64.     c = FGetC ((BPTR)stream->fh);
  65.     break;
  66.     }
  67.  
  68.     if (c == EOF)
  69.     {
  70.     errno = IoErr2errno (IoErr ());
  71.  
  72.     if (errno)
  73.         stream->flags |= _STDIO_FILEFLAG_ERROR;
  74.     else
  75.         stream->flags |= _STDIO_FILEFLAG_EOF;
  76.     }
  77.  
  78.     return c;
  79. } /* fgetc */
  80.  
  81.