summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/fopen.3
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2003-01-26 10:01:59 +0000
committertjr <tjr@FreeBSD.org>2003-01-26 10:01:59 +0000
commit680c2aca55d1bb75a321735e31280c7281782f2c (patch)
tree563ae2b8d00db2609264cbf43f9b0dd609f80880 /lib/libc/stdio/fopen.3
parent2a088a14174963b45600a538364fa67d69858c11 (diff)
downloadFreeBSD-src-680c2aca55d1bb75a321735e31280c7281782f2c.zip
FreeBSD-src-680c2aca55d1bb75a321735e31280c7281782f2c.tar.gz
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
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 eb39376..1508e59 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
OpenPOWER on IntegriCloud