Loading...
--- Libc/Libc-763.12/stdio/fopen.3
+++ Libc/Libc-262/stdio/fopen.3
@@ -13,6 +13,10 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
@@ -30,14 +34,14 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)fopen.3 8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/stdio/fopen.3,v 1.21 2009/09/09 19:38:19 ed Exp $
-.\"
-.Dd January 26, 2003
+.\" $FreeBSD: src/lib/libc/stdio/fopen.3,v 1.12 2001/10/01 16:08:59 ru Exp $
+.\"
+.Dd June 4, 1993
.Dt FOPEN 3
.Os
.Sh NAME
+.Nm fopen ,
.Nm fdopen ,
-.Nm fopen ,
.Nm freopen
.Nd stream open functions
.Sh LIBRARY
@@ -45,27 +49,17 @@
.Sh SYNOPSIS
.In stdio.h
.Ft FILE *
-.Fo fdopen
-.Fa "int fildes"
-.Fa "const char *mode"
-.Fc
+.Fn fopen "const char *path" "const char *mode"
.Ft FILE *
-.Fo fopen
-.Fa "const char *restrict filename"
-.Fa "const char *restrict mode"
-.Fc
+.Fn fdopen "int fildes" "const char *mode"
.Ft FILE *
-.Fo freopen
-.Fa "const char *restrict filename"
-.Fa "const char *restrict mode"
-.Fa "FILE *restrict stream"
-.Fc
+.Fn freopen "const char *path" "const char *mode" "FILE *stream"
.Sh DESCRIPTION
The
.Fn fopen
function
opens the file whose name is the string pointed to by
-.Fa filename
+.Fa path
and associates a stream with it.
.Pp
The argument
@@ -80,7 +74,7 @@
Open for reading and writing.
The stream is positioned at the beginning of the file.
.It Dq Li w
-Truncate to zero length or create text file for writing.
+Truncate file to zero length or create text file for writing.
The stream is positioned at the beginning of the file.
.It Dq Li w+
Open for reading and writing.
@@ -106,23 +100,12 @@
.Pp
The
.Fa mode
-string can also include the letter ``b'' either as last character or
+string can also include the letter ``b'' either as a third character or
as a character between the characters in any of the two-character strings
described above.
This is strictly for compatibility with
.St -isoC
and has no effect; the ``b'' is ignored.
-.Pp
-Finally, as an extension to the standards (and thus may not be portable),
-.Fa mode
-string may end with the letter ``x'', which insists on creating a new file
-when used with ``w'' or ``a''.
-If
-.Fa path
-exists, then an error is returned (this is the equivalent of specifying
-.Dv O_EXCL
-with
-.Xr open 2 ) .
.Pp
Any created files will have mode
.Pf \\*q Dv S_IRUSR
@@ -154,7 +137,8 @@
.Fn fdopen
function associates a stream with the existing file descriptor,
.Fa fildes .
-The mode
+The
+.Fa mode
of the stream must be compatible with the mode of the file descriptor.
When the stream is closed via
.Xr fclose 3 ,
@@ -165,7 +149,7 @@
.Fn freopen
function
opens the file whose name is the string pointed to by
-.Fa filename
+.Fa path
and associates the stream pointed to by
.Fa stream
with it.
@@ -175,53 +159,19 @@
argument is used just as in the
.Fn fopen
function.
-.Pp
-If the
-.Fa filename
-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
is to change the file associated with a
standard text stream
-.Dv ( stderr , stdin ,
+.Pf ( Em stderr ,
+.Em stdin ,
or
-.Dv stdout ) .
+.Em stdout ) .
.Sh RETURN VALUES
Upon successful completion
.Fn fopen ,
-.Fn fdopen ,
+.Fn fdopen
and
.Fn freopen
return a
@@ -237,8 +187,7 @@
.It Bq Er EINVAL
The
.Fa mode
-argument
-to
+provided to
.Fn fopen ,
.Fn fdopen ,
or
@@ -286,7 +235,6 @@
.Sh SEE ALSO
.Xr open 2 ,
.Xr fclose 3 ,
-.Xr fileno 3 ,
.Xr fseek 3 ,
.Xr funopen 3
.Sh STANDARDS