svcadm(8)을 검색하려면 섹션에서 8 을 선택하고, 맨 페이지 이름에 svcadm을 입력하고 검색을 누른다.
fmemopen(3c)
fmemopen(3C) Standard C Library Functions fmemopen(3C)
NAME
fmemopen - open a memory buffer stream
SYNOPSIS
#include <stdio.h>
FILE *fmemopen(void *buf, size_t size, const char *mode);
DESCRIPTION
The fmemopen() function associates the buffer given by the buf and size
arguments with a stream. The buf argument must either be a null pointer
or must point to a buffer that is at least size bytes long.
The argument mode points to a string beginning with one of the follow‐
ing sequences:
r or rb Open the stream for reading.
w or wb Open the stream for writing.
a or ab Append; open the stream for writing at the first
null byte.
r+ or rb+ or r+b Open the stream for update (reading and writing).
w+ or wb+ or w+b Open the stream for update (reading and writing).
Truncate the buffer contents.
a+ or ab+ or a+b Append; open the stream for update (reading and
writing); the initial position is at the first null
byte.
The character b has no effect.
If a null pointer is specified as the buf argument, fmemopen() allo‐
cates size bytes of memory as if by a call to malloc(). This buffer is
automatically freed when the stream is closed.
The stream maintains a current position in the buffer. This position is
initially set to either the beginning of the buffer (for r and w modes)
or to the first null byte in the buffer (for a modes). If no null byte
is found in append mode, the initial position is set to one byte after
the end of the buffer.
If buf is a null pointer, the initial position is always set to the be‐
ginning of the buffer.
The stream also maintains the size of the current buffer contents. For
modes r and r+ the size is set to the value given by the size argument.
For modes w and w+ the initial size is zero and for modes a and a+ the
initial size is either the position of the first null byte in the
buffer or the value of the size argument if no null byte is found.
A read operation on the stream cannot advance the current buffer posi‐
tion beyond the current buffer size. Reaching the buffer size in a read
operation counts as "end-of-file". Null bytes in the buffer have no
special meaning for reads. The read operation starts at the current
buffer position of the stream.
A write operation starts either at the current position of the stream
(if mode has not specified 'a' as the first character) or at the cur‐
rent size of the stream (if mode had 'a' as the first character). If
the current position at the end of the write is larger than the current
buffer size, the current buffer size is set to the current position. A
write operation on the stream cannot advance the current buffer size
beyond the size given in the size argument.
When a stream open for writing is flushed or closed, a null byte is
written at the current position or at the end of the buffer, depending
on the size of the contents. If a stream open for update is flushed or
closed and the last write has advanced the current buffer size, a null
byte is written at the end of the buffer if it fits.
An attempt to seek a memory buffer stream to a negative position or to
a position larger than the buffer size given if the size argument
fails.
RETURN VALUES
Upon successful completion, fmemopen() returns a pointer to the object
controlling the stream. Otherwise, a null pointer is returned and errno
is set to indicate the error.
ERRORS
The fmemopen() function will fail if:
EINVAL The size argument specifies a buffer size of zero.
EINVAL The value of the mode argument is not valid.
ENOMEM Insufficient storage space is available.
USAGE
The mode of a stream opened by fmemopen() can be changed by a call to
freopen(NULL, mode, stream).
ATTRIBUTES
See attributes(7) for descriptions of the following attributes:
tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
TRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelMT-Safe _ Stan‐
dardSee standards(7).
SEE ALSO
fopen(3C), freopen(3C), malloc(3C), open_memstream(3C), attributes(7),
standards(7)
Oracle Solaris 11.4 04 Oct 2013 fmemopen(3C)