ucx/memstream.h

changeset 60
abae4669fba7
parent 59
c80c910fe191
child 61
fb07a0ab9a17
     1.1 --- a/ucx/memstream.h	Wed Oct 10 09:34:13 2012 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,55 +0,0 @@
     1.4 -#ifndef MEMSTREAM_H
     1.5 -#define	MEMSTREAM_H
     1.6 -
     1.7 -#include <stdio.h>
     1.8 -
     1.9 -/* as fmemopen is a C extension we provide our cross plattform stuff here */
    1.10 -
    1.11 -#ifdef	__cplusplus
    1.12 -extern "C" {
    1.13 -#endif
    1.14 -
    1.15 -
    1.16 -/* as FILE is opaque, we don't do evil hacks but provide an alternative */
    1.17 -typedef struct UcxMemstream UcxMemstream;
    1.18 -
    1.19 -UcxMemstream *ucx_memopen(void *space, size_t length);
    1.20 -void ucx_memclose(UcxMemstream* stream);
    1.21 -
    1.22 -/*
    1.23 - * Moves the position of the stream to a new position relative to whence.
    1.24 - *
    1.25 - * SEEK_SET marks the start of the buffer
    1.26 - * SEEK_CUR marks the current position
    1.27 - * SEEK_END marks the first 0-byte in the buffer
    1.28 - *
    1.29 - * ucx_memseek returns 0 on success and -1 if the new position is beyond the
    1.30 - * bounds of the allocated buffer. In that case the position of the stream
    1.31 - * remains unchanged.
    1.32 - *
    1.33 - */
    1.34 -int ucx_memseek(UcxMemstream *stream, off_t offset, int whence);
    1.35 -size_t ucx_memtell(UcxMemstream *stream);
    1.36 -
    1.37 -/*
    1.38 - * returns non-zero, iff the current stream position has exceeded the last
    1.39 - * available byte of the underlying buffer
    1.40 - *
    1.41 - */
    1.42 -int ucx_memeof(UcxMemstream *stream);
    1.43 -
    1.44 -/* memwrite, memread, memputc and memreadc shall not generate overflows */
    1.45 -size_t ucx_memio(void *d, size_t s, size_t n, UcxMemstream* m, _Bool read);
    1.46 -#define ucx_memwrite(data, itemsize, nitems, memstream) \
    1.47 -    ucx_memio(data, itemsize, nitems, memstream, 0)
    1.48 -#define ucx_memread(data, itemsize, nitems, memstream) \
    1.49 -        ucx_memio(data, itemsize, nitems, memstream, 1)
    1.50 -int ucx_memputc(UcxMemstream *stream, int c);
    1.51 -int ucx_memgetc(UcxMemstream *stream);
    1.52 -
    1.53 -#ifdef	__cplusplus
    1.54 -}
    1.55 -#endif
    1.56 -
    1.57 -#endif	/* MEMSTREAM_H */
    1.58 -

mercurial