aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/stdio/fopen.3
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2003-01-26 10:01:59 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2003-01-26 10:01:59 +0000
commitc297498757458a638238901cdc42d6a6ed7c01e8 (patch)
tree563ae2b8d00db2609264cbf43f9b0dd609f80880 /lib/libc/stdio/fopen.3
parentbbe7088205d86eca234660e9aa0361a7ef1ec080 (diff)
downloadsrc-c297498757458a638238901cdc42d6a6ed7c01e8.tar.gz
src-c297498757458a638238901cdc42d6a6ed7c01e8.zip
Initial implementation of the C99 feature whereby calling freopen() with
a NULL filename argument allows a stream's mode to be changed. At the moment it just recycles the old file descriptor instead of storing the filename somewhere and using that to reopen the file, as the standard seems to require. Strictly conforming C99 applications probably can't tell the difference but POSIX ones can. PR: 46791
Notes
Notes: svn path=/head/; revision=109871
Diffstat (limited to 'lib/libc/stdio/fopen.3')
-rw-r--r--lib/libc/stdio/fopen.337
1 files changed, 36 insertions, 1 deletions
diff --git a/lib/libc/stdio/fopen.3 b/lib/libc/stdio/fopen.3
index eb393763281b..1508e5953e22 100644
--- a/lib/libc/stdio/fopen.3
+++ b/lib/libc/stdio/fopen.3
@@ -36,7 +36,7 @@
.\" @(#)fopen.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 4, 1993
+.Dd January 26, 2003
.Dt FOPEN 3
.Os
.Sh NAME
@@ -158,6 +158,41 @@ The
argument is used just as in the
.Fn fopen
function.
+.Pp
+If the
+.Fa path
+argument is
+.Dv NULL ,
+.Fn freopen
+attempts to re-open the file associated with
+.Fa stream
+with a new mode.
+The new mode must be compatible with the mode that the stream was originally
+opened with:
+.Bl -bullet -offset indent
+.It
+Streams originally opened with mode
+.Dq Li r
+can only be reopened with that same mode.
+.It
+Streams originally opened with mode
+.Dq Li a
+can be reopened with the same mode, or mode
+.Dq Li w .
+.It
+Streams originally opened with mode
+.Dq Li w
+can be reopened with the same mode, or mode
+.Dq Li a .
+.It
+Streams originally opened with mode
+.Dq Li r+ ,
+.Dq Li w+ ,
+or
+.Dq Li a+
+can be reopened with any mode.
+.El
+.Pp
The primary use of the
.Fn freopen
function