This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

rework of fmemopen


Hi all,

I liked the idea, but the various implementations of it and memstream seemed
like they almost got there, but not quite.  So, I grabbed one and tweaked it
a bit.  Here is the are the man pages:

fmemioctl(3)           Programmer's Manual           fmemioctl(3)

NAME
       fmemioctl - get information about a string stream

SYNOPSIS
       cc [...] -o outfile infile.c -lfmem [...]

       void fmemioctl(FILE* fptr, int req, void* ptr);

DESCRIPTION
       This  routine  surrepticiously slips in a special request.
       Currently,  the  only  special   request   supported   is,
       FMEM_IOCTL_BUFFER.   The  third argument is never optional
       and must be a pointer to where the buffer address is to be
       stored.  sizeof long must be sizeof char*.

       fptr   the string stream
       req    the requested data
       ptr    ptr to result area

ERRORS
       non-zero is returned and errno is set.

SEE ALSO
       The info documentation for the -lfmem library.
       fmemopen(3),


fmemopen(3)            Programmer's Manual            fmemopen(3)

NAME
       fmemopen - Open a stream to a string

SYNOPSIS
       cc [...] -o outfile infile.c -lfmem [...]

       FILE* fmemopen(void* buf, size_t len, char* mode);

DESCRIPTION
       If  buf  is NULL, then a buffer is allocated.  It is allo-
       cated to size len, unless that is zero.  If len  is  zero,
       then  pagesize()  is  used  and  the  buffer  is marked as
       "extensible".  Any  allocated  memory  is  free()-ed  when
       fclose(3C) is called.

       The mode string is interpreted as follows:

       If  the  first  letter  is an 'a', the string is opened in
       "append" mode.  Append  mode  is  always  extensible.   In
       binary  mode,  "appending"  will begin from the end of the
       initial buffer.  Otherwise, appending will  start  at  the
       first non-NUL character in the initial buffer.

       If  the  first  letter  is  a 'w', the string is opened in
       "write" mode.  Writing (and  any  reading)  start  at  the
       beginning  of  the  buffer.  If the buffer was supplied by
       the caller and it is allowed to be extended, then the ini-
       tial buffer may or may not be in use at any point in time,
       and the user is responsible for handling  the  disposition
       of the initial memory.

       If  the  first  letter  is  a 'r', the string is opened in
       "read" mode.

       Any other first letter will result in errno being  set  to
       EINVAL.

       If one of the following characters is '+', then the buffer
       is marked as extensible and both reading  and  writing  is
       enabled.

       If one of the following characters is 'b', then the I/O is
       marked as "binary" and a trailing NUL will not be inserted
       into the buffer.

       The letter 'x' is ignored.

       Any  other  letters  following  the inital 'a', 'w' or 'r'
       will cause an error.

       buf    buffer to use for i/o
       len    size of the buffer
       mode   mode string, a la fopen(3C)

RETURN VALUE
       a stdio FILE* pointer

ERRORS
       NULL is returned and errno is set

SEE ALSO
       The info documentation for the -lfmem library.
       fmemioctl(3)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]