Loading...
--- Libc/Libc-583/stdio/fopen.3
+++ Libc/Libc-262/stdio/fopen.3
@@ -34,14 +34,14 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)fopen.3 8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/stdio/fopen.3,v 1.18 2003/01/26 10:01:59 tjr 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
@@ -49,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
@@ -117,17 +107,6 @@
.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
\&|
@@ -158,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 ,
@@ -169,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.
@@ -179,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
@@ -241,8 +187,7 @@
.It Bq Er EINVAL
The
.Fa mode
-argument
-to
+provided to
.Fn fopen ,
.Fn fdopen ,
or
@@ -290,7 +235,6 @@
.Sh SEE ALSO
.Xr open 2 ,
.Xr fclose 3 ,
-.Xr fileno 3 ,
.Xr fseek 3 ,
.Xr funopen 3
.Sh STANDARDS