summaryrefslogtreecommitdiffstats
path: root/man3/fmemopen.3
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--man3/fmemopen.345
1 files changed, 22 insertions, 23 deletions
diff --git a/man3/fmemopen.3 b/man3/fmemopen.3
index 081a33f..93f3a12 100644
--- a/man3/fmemopen.3
+++ b/man3/fmemopen.3
@@ -3,7 +3,7 @@
.\"
.\" SPDX-License-Identifier: GPL-1.0-or-later
.\"
-.TH fmemopen 3 2023-07-20 "Linux man-pages 6.05.01"
+.TH fmemopen 3 2023-10-31 "Linux man-pages 6.7"
.SH NAME
fmemopen \- open memory as stream
.SH LIBRARY
@@ -12,16 +12,16 @@ Standard C library
.SH SYNOPSIS
.nf
.B #include <stdio.h>
-.PP
+.P
.BI "FILE *fmemopen(void " buf [. size "], size_t " size ", \
const char *" mode );
.fi
-.PP
+.P
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
-.PP
+.P
.BR fmemopen ():
.nf
Since glibc 2.10:
@@ -37,7 +37,7 @@ function opens a stream that permits the access specified by
The stream allows I/O to be performed on the string or memory buffer
pointed to by
.IR buf .
-.PP
+.P
The
.I mode
argument specifies the semantics of I/O on the stream,
@@ -64,7 +64,7 @@ The buffer contents are truncated
.I a+
Append; open the stream for reading and writing,
with the initial buffer position set to the first null byte.
-.PP
+.P
The stream maintains the notion of a current position,
the location where the next I/O operation will be performed.
The current position is implicitly updated by I/O operations.
@@ -77,7 +77,7 @@ the initial position is set to the start of the buffer.
In append mode, if no null byte is found within the buffer,
then the initial position is
.IR size+1 .
-.PP
+.P
If
.I buf
is specified as NULL, then
@@ -92,13 +92,13 @@ The buffer is automatically freed when the stream is closed.
Note that the caller has no way to obtain a pointer to the
temporary buffer allocated by this call (but see
.BR open_memstream (3)).
-.PP
+.P
If
.I buf
is not NULL, then it should point to a buffer of at least
.I size
bytes allocated by the caller.
-.PP
+.P
When a stream that has been opened for writing is flushed
.RB ( fflush (3))
or closed
@@ -110,7 +110,7 @@ buffer
.I size
counts that byte)
to allow for this.
-.PP
+.P
In a stream opened for reading,
null bytes (\[aq]\e0\[aq]) in the buffer do not cause read
operations to return an end-of-file indication.
@@ -118,11 +118,11 @@ A read from the buffer will indicate end-of-file
only when the current buffer position advances
.I size
bytes past the start of the buffer.
-.PP
+.P
Write operations take place either at the current position
(for modes other than append), or at the current size of the stream
(for append modes).
-.PP
+.P
Attempts to write more than
.I size
bytes to the buffer result in an error.
@@ -132,7 +132,7 @@ By default, such errors will be visible
buffer is flushed.
Disabling buffering with the following call
may be useful to detect errors at the time of an output operation:
-.PP
+.P
.in +4n
.EX
setbuf(stream, NULL);
@@ -161,13 +161,12 @@ T{
.BR fmemopen (),
T} Thread safety MT-Safe
.TE
-.sp 1
.SH STANDARDS
POSIX.1-2008.
.SH HISTORY
glibc 1.0.x.
POSIX.1-2008.
-.PP
+.P
POSIX.1-2008 specifies that \[aq]b\[aq] in
.I mode
shall be ignored.
@@ -175,7 +174,7 @@ However, Technical Corrigendum 1
.\" http://austingroupbugs.net/view.php?id=396
adjusts the standard to allow implementation-specific treatment for this case,
thus permitting the glibc treatment of \[aq]b\[aq].
-.PP
+.P
With glibc 2.22, binary mode (see below) was removed,
many longstanding bugs in the implementation of
.BR fmemopen ()
@@ -194,7 +193,7 @@ writes don't implicitly add a terminating null byte, and
is relative to the end of the buffer (i.e., the value specified by the
.I size
argument), rather than the current string length.
-.PP
+.P
An API bug afflicted the implementation of binary mode:
to specify binary mode, the \[aq]b\[aq] must be the
.I second
@@ -206,7 +205,7 @@ This is inconsistent with the treatment of
.I mode
by
.BR fopen (3).
-.PP
+.P
Binary mode was removed in glibc 2.22; a \[aq]b\[aq] specified in
.I mode
has no effect.
@@ -227,7 +226,7 @@ fails with the error
It would be more consistent if this case successfully created
a stream that then returned end-of-file on the first attempt at reading;
since glibc 2.22, the glibc implementation provides that behavior.
-.PP
+.P
Before glibc 2.22,
specifying append mode ("a" or "a+") for
.BR fmemopen ()
@@ -237,7 +236,7 @@ sets the initial buffer position to the first null byte, but
the end of the stream)
does not force subsequent writes to append at the end of the stream.
This bug is fixed in glibc 2.22.
-.PP
+.P
Before glibc 2.22, if the
.I mode
argument to
@@ -254,7 +253,7 @@ However, in this case the glibc
.BR fmemopen ()
sets the buffer position to \-1.
This bug is fixed in glibc 2.22.
-.PP
+.P
Before glibc 2.22,
.\" https://sourceware.org/bugzilla/show_bug.cgi?id=14292
when a call to
@@ -271,7 +270,7 @@ was
.I subtracted
from the end-of-stream position, instead of being added.
This bug is fixed in glibc 2.22.
-.PP
+.P
The glibc 2.9 addition of "binary" mode for
.BR fmemopen ()
.\" http://sourceware.org/bugzilla/show_bug.cgi?id=6544
@@ -289,7 +288,7 @@ The program scans its input string (taken from the program's
first command-line argument) reading integers,
and writes the squares of these integers to the output buffer.
An example of the output produced by this program is the following:
-.PP
+.P
.in +4n
.EX
.RB "$" " ./a.out \[aq]1 23 43\[aq]"