1 .\" $NetBSD: fmemopen.3,v 1.7 2012/10/08 18:15:09 njoly Exp $
3 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Christos Zoulas.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
17 .\" 3. Neither the name of The NetBSD Foundation nor the names of its
18 .\" contributors may be used to endorse or promote products derived
19 .\" from this software without specific prior written permission.
21 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 .\" POSSIBILITY OF SUCH DAMAGE.
38 .Nd open a stream that points to the given buffer
44 .Fn fmemopen "void *restrict buffer" "size_t size" "const char *restrict mode"
49 associates a stream with the given
57 or must be of the given
67 will be dynamically allocated using
75 argument has the same meaning as in
78 The stream treats the buffer as it would treat a file tracking the current
79 position to perform I/O operations.
80 For example, in the beginning the stream points to the beginning of the buffer,
85 argument, and then it points to the first
91 was specified, then the stream will always point at the first byte of the
94 The stream also keeps track of the
100 is initialized depending on the mode:
114 argument if one is not found.
117 Read or write operations advance the buffer, but not to exceed the given
121 Trying to read beyond the
129 bytes are read normally.
130 Trying to write beyond the
136 When a stream open for writing is either flushed or closed, a
138 byte is written at the current position or at the end of the current
140 as kept internally, if there is room.
142 Upon successful completion,
149 is returned and the global variable
151 is set to indicate the error.
168 argument does not specify a
175 may also fail and set
177 for any of the errors
178 specified for the routine
193 functions first appeared in