icon Top 9 categories map      RocketAware > man pages >

funopen(3)

Tips: Browse or Search all pages for efficient awareness of more than 6000 of the most popular reusable and open source applications, functions, libraries, and FAQs.


The "RKT couplings" below include links to source code, updates, additional information, advice, FAQs, and overviews.


Home

Search all pages


Subjects

By activity
Professions, Sciences, Humanities, Business, ...

User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...

Text Strings
Conversions, tests, processing, manipulation,...

Math
Integer, Floating point, Matrix, Statistics, Boolean, ...

Processing
Algorithms, Memory, Process control, Debugging, ...

Stored Data
Data storage, Integrity, Encryption, Compression, ...

Communications
Networks, protocols, Interprocess, Remote, Client Server, ...

Hard World
Timing, Calendar and Clock, Audio, Video, Printer, Controls...

File System
Management, Filtering, File & Directory access, Viewers, ...

    

RocketLink!--> Man page versions: OpenBSD FreeBSD Others



FUNOPEN(3)                OpenBSD Programmer's Manual               FUNOPEN(3)

NAME
     funopen, fropen, fwopen - open a stream



SYNOPSIS
     #include <stdio.h>

     FILE *
     funopen(void *cookie, int (*readfn)(void *, char *, int),
             int (*writefn)(void *, const char *, int),
             fpos_t (*seekfn)(void *, fpos_t, int), int (*closefn)(void *));

     FILE *
     fropen(void *cookie, int (*readfn)(void *, char *, int));

     FILE *
     fwopen(void *cookie, int (*writefn)(void *, const char *, int));

DESCRIPTION
     The funopen() function associates a stream with up to four ``I/O
     functions''. Either readfn or writefn must be specified; the others can
     be given as an appropriately typed NULL pointer.  These I/O functions
     will be used to read, write, seek and close the new stream.

     In general, omitting a function means that any attempt to perform the as-
     sociated operation on the resulting stream will fail.  If the close func-
     tion is omitted, closing the stream will flush any buffered output and
     then succeed.

     The calling conventions of readfn, writefn, seekfn and closefn must match
     those, respectively, of read(2),  write(2),  lseek(2),  and close(2) with
     the exceptions that they are passed the cookie argument specified to
     funopen() in place of the traditional file descriptor argument and that
     the seek function takes an fpos_t argument and not an off_t argument.

     Read and write I/O functions are allowed to change the underlying buffer
     on fully buffered or line buffered streams by calling setvbuf(3).  They
     are also not required to completely fill or empty the buffer.  They are
     not, however, allowed to change streams from unbuffered to buffered or to
     change the state of the line buffering flag.  They must also be prepared
     to have read or write calls occur on buffers other than the one most re-
     cently specified.

     All user I/O functions can report an error by returning -1.  Additional-
     ly, all of the functions should set the external variable errno appropri-
     ately if an error occurs.

     An error on closefn() does not keep the stream open.

     As a convenience, the include file <stdio.h> defines the macros fropen()
     and fwopen() as calls to funopen() with only a read or write function
     specified.

RETURN VALUES
     Upon successful completion, funopen() returns a FILE pointer.  Otherwise,
     NULL is returned and the global variable errno is set to indicate the er-
     ror.

ERRORS
     [EINVAL]      The funopen() function was called without either a read or
                   write function.  The funopen() function may also fail and
                   set errno for any of the errors specified for the routine
                   malloc(3).

SEE ALSO
     fcntl(2),  open(2),  fclose(3),  fopen(3),  fseek(3),  setbuf(3)

HISTORY
     The funopen() functions first appeared in 4.4BSD.

BUGS
     The funopen() function may not be portable to systems other than BSD.

OpenBSD 2.6                      June 9, 1993                                2

Source: OpenBSD 2.6 man pages. Copyright: Portions are copyrighted by BERKELEY
SOFTWARE DESIGN, INC., The Regents of the University of California, Massachusetts
Institute of Technology, Free Software Foundation, FreeBSD Inc., and others.



(Corrections, notes, and links courtesy of RocketAware.com)


[Detailed Topics]
FreeBSD Sources for funopen(3) functions
OpenBSD sources for funopen(3)


[Overview Topics]

Up to: Stdio Stream file operations - Buffered access of files and devices. fopen, fputc, fgetc, et al.


RocketLink!--> Man page versions: OpenBSD FreeBSD Others






Rapid-Links: Search | About | Comments | Submit Path: RocketAware > man pages > funopen.3/
RocketAware.com is a service of Mib Software
Copyright 1999, Forrest J. Cavalier III. All Rights Reserved.
We welcome submissions and comments