Update contrib.
3 * Portions Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
9 <<fclose>>---close a file
16 int fclose(FILE *<[fp]>);
24 If the file or stream identified by <[fp]> is open, <<fclose>> closes
25 it, after first ensuring that any pending data is written (by calling
29 <<fclose>> returns <<0>> if successful (including when <[fp]> is
30 <<NULL>> or not an open file); otherwise, it returns <<EOF>>.
33 <<fclose>> is required by ANSI C.
35 Required OS subroutines: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>,
36 <<read>>, <<sbrk>>, <<write>>.
40 * Copyright (c) 1990 The Regents of the University of California.
41 * All rights reserved.
43 * Redistribution and use in source and binary forms are permitted
44 * provided that the above copyright notice and this paragraph are
45 * duplicated in all such forms and that any documentation,
46 * advertising materials, and other materials related to such
47 * distribution and use acknowledge that the software was developed
48 * by the University of California, Berkeley. The name of the
49 * University may not be used to endorse or promote products derived
50 * from this software without specific prior written permission.
51 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
52 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
53 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
66 Close the file associated with the specified stream
67 after flushing all buffers associated with it.
68 @return If the stream is successfully closed 0 is returned.
69 If any error EOF is returned.
70 @param fp Pointer to FILE structure specifying the stream to be closed.
72 EXPORT_C int fclose (FILE * fp)
77 return (0); /* on NULL */
81 if (fp->_flags == 0) /* not open! */
83 r = fp->_flags & __SWR ? fflush (fp) : 0;
84 if (fp->_close != NULL && (*fp->_close) (fp->_cookie) < 0)
86 if (fp->_flags & __SMBF)
87 _free_r (fp->_data, (char *) fp->_bf._base);
92 fp->_flags = 0; /* release this FILE for reuse */