fmemopen man page on Minix

Man page or keyword search:  
man Server   6208 pages
apropos Keyword Search (all sections)
Output format
Minix logo
[printable version]

FMEMOPEN(3)		 BSD Library Functions Manual		   FMEMOPEN(3)

NAME
     fmemopen — open a stream that points to the given buffer

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <stdio.h>

     FILE *
     fmemopen(void *restrict buffer, size_t size, const char *restrict mode);

DESCRIPTION
     The fmemopen() function associates a stream with the given buffer and
     size.  The buffer can be either NULL, or must be of the given size.  If
     the buffer is NULL, a buffer of the given size will be dynamically allo‐
     cated using malloc(3) and freed when fclose(3) is called.

     The mode argument has the same meaning as in fopen(3).

     The stream treats the buffer as it would treat a file tracking the cur‐
     rent position to perform I/O operations.  For example, in the beginning
     the stream points to the beginning of the buffer, unless a was specified
     in the mode argument, and then it points to the first NUL byte.  If a
     NULL buffer was specified, then the stream will always point at the first
     byte of the buffer.

     The stream also keeps track of the size of the buffer.  The size is ini‐
     tialized depending on the mode:

     r/r+  Set to the size argument.

     w/w+  Set to 0.

     a/a+  Set to the first NUL byte, or the size argument if one is not
	   found.

     Read or write operations advance the buffer, but not to exceed the given
     size of the buffer.  Trying to read beyond the size of the buffer results
     in EOF returned.  NUL bytes are read normally.  Trying to write beyond
     the size of the buffer has no effect.

     When a stream open for writing is either flushed or closed, a NUL byte is
     written at the current position or at the end of the current size as kept
     internally, if there is room.

RETURN VALUES
     Upon successful completion, fmemopen() returns a FILE pointer.  Other‐
     wise, NULL is returned and the global variable errno is set to indicate
     the error.

ERRORS
     [EINVAL]		The size was 0; or the mode argument is invalid; or
			the buffer argument is NULL and the mode argument does
			not specify a +.

     The fmemopen() function may also fail and set errno for any of the errors
     specified for the routine malloc(3).

SEE ALSO
     fclose(3), fflush(3), fopen(3), malloc(3)

STANDARDS
     The fmemopen() function conforms to IEEE Std 1003.1-2008 (“POSIX.1”).

HISTORY
     The fmemopen() functions first appeared in NetBSD 6.0.

BSD			       October 15, 2011				   BSD
[top]

List of man pages available for Minix

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net