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

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: fclose.c,v 1.1 1997/01/17 16:23:06 digulla Exp $
  4.  
  5.     Desc: ANSI C function fclose()
  6.     Lang: english
  7. */
  8. #include <proto/exec.h>
  9. #include <proto/dos.h>
  10. #include <errno.h>
  11. #include <stdlib.h>
  12. #include "__errno.h"
  13. #include "__stdio.h"
  14.  
  15.  
  16. /*****************************************************************************
  17.  
  18.     NAME */
  19. #include <stdio.h>
  20.  
  21.     int fclose (
  22.  
  23. /*  SYNOPSIS */
  24.     FILE * stream)
  25.  
  26. /*  FUNCTION
  27.     Closes a stream.
  28.  
  29.     INPUTS
  30.     stream - Stream to close.
  31.  
  32.     RESULT
  33.     Upon successful completion 0 is returned. Otherwise, EOF is
  34.     returned and the global variable errno is set to indicate the
  35.     error. In either case no further access to the stream is possible.
  36.  
  37.     NOTES
  38.  
  39.     EXAMPLE
  40.  
  41.     BUGS
  42.  
  43.     SEE ALSO
  44.     fopen(), open(), close()
  45.  
  46.     INTERNALS
  47.  
  48.     HISTORY
  49.     17.01.97 digulla created
  50.  
  51. ******************************************************************************/
  52. {
  53.     FILENODE * fn;
  54.     int err;
  55.  
  56.     fn = FILE2FILENODE (stream);
  57.  
  58.     Remove ((struct Node *)fn);
  59.  
  60.     err = Close (fn->File.fh);
  61.  
  62.     FreeMem (fn, sizeof (FILENODE));
  63.  
  64.     if (err == EOF)
  65.     {
  66.     errno = IoErr2errno (IoErr ());
  67.  
  68.     return EOF;
  69.     }
  70.  
  71.     return 0;
  72. } /* fclose */
  73.  
  74.