aboutsummaryrefslogtreecommitdiff
path: root/stdio
diff options
context:
space:
mode:
Diffstat (limited to 'stdio')
-rw-r--r--stdio/Makefile8
-rw-r--r--stdio/fclose.c22
-rw-r--r--stdio/fcloseall.c37
-rw-r--r--stdio/stdio.h8
4 files changed, 54 insertions, 21 deletions
diff --git a/stdio/Makefile b/stdio/Makefile
index 9c69e52335..cabb4aa9da 100644
--- a/stdio/Makefile
+++ b/stdio/Makefile
@@ -12,9 +12,9 @@
# Library General Public License for more details.
# You should have received a copy of the GNU Library General Public
-# License along with the GNU C Library; see the file COPYING.LIB. If
-# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-# Cambridge, MA 02139, USA.
+# License along with the GNU C Library; see the file COPYING.LIB. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
#
# Specific makefile for stdio.
@@ -34,7 +34,7 @@ routines := \
fputc putc putchar \
fgets gets fputs puts \
getdelim \
- fclose fflush \
+ fclose fcloseall fflush \
vdprintf vsnprintf vsprintf vasprintf vsscanf vscanf \
memstream obstream linewrap \
internals sysd-stdio pipestream stdio_init libc_fatal
diff --git a/stdio/fclose.c b/stdio/fclose.c
index b8abe65655..4fda20b4ac 100644
--- a/stdio/fclose.c
+++ b/stdio/fclose.c
@@ -26,21 +26,11 @@
/* Close a stream. */
int
fclose (stream)
- register FILE *stream;
+ FILE *stream;
{
int status;
- if (stream == NULL)
- {
- /* Close all streams. */
- register FILE *f;
- for (f = __stdio_head; f != NULL; f = f->__next)
- if (__validfp(f))
- (void) fclose(f);
- return 0;
- }
-
- if (!__validfp(stream))
+ if (!__validfp (stream))
{
__set_errno (EINVAL);
return EOF;
@@ -53,18 +43,18 @@ fclose (stream)
/* Free the buffer's storage. */
if (stream->__buffer != NULL && !stream->__userbuf)
- free(stream->__buffer);
+ free (stream->__buffer);
/* Close the system file descriptor. */
if (stream->__io_funcs.__close != NULL)
- status = (*stream->__io_funcs.__close)(stream->__cookie);
+ status = (*stream->__io_funcs.__close) (stream->__cookie);
else if (!stream->__seen && stream->__cookie != NULL)
- status = __stdio_close(stream->__cookie);
+ status = __stdio_close (stream->__cookie);
else
status = 0;
/* Nuke the stream, making it available for re-use. */
- __invalidate(stream);
+ __invalidate (stream);
return status < 0 ? EOF : 0;
}
diff --git a/stdio/fcloseall.c b/stdio/fcloseall.c
new file mode 100644
index 0000000000..e7c632d24a
--- /dev/null
+++ b/stdio/fcloseall.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+
+/* Close a stream. */
+int
+__fcloseall ()
+{
+ /* Close all streams. */
+ register FILE *f;
+ for (f = __stdio_head; f != NULL; f = f->__next)
+ if (__validfp(f))
+ (void) fclose(f);
+ return 0;
+}
+weak_alias (__fcloseall, fcloseall)
diff --git a/stdio/stdio.h b/stdio/stdio.h
index 8e913ccbd9..bd2ffa8eb5 100644
--- a/stdio/stdio.h
+++ b/stdio/stdio.h
@@ -324,11 +324,17 @@ extern char *tempnam __P ((__const char *__dir, __const char *__pfx));
extern int __flshfp __P ((FILE *__stream, int __c));
-/* Close STREAM, or all streams if STREAM is NULL. */
+/* Close STREAM. */
extern int fclose __P ((FILE *__stream));
/* Flush STREAM, or all streams if STREAM is NULL. */
extern int fflush __P ((FILE *__stream));
+#ifdef __USE_GNU
+/* Close all streams. */
+extern int __fcloseall __P ((void));
+extern int fcloseall __P ((void));
+#endif
+
/* Open a file and create a new stream for it. */
extern FILE *fopen __P ((__const char *__filename, __const char *__modes));