ucx/buffer.h

Wed, 10 Oct 2012 09:54:57 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 10 Oct 2012 09:54:57 +0200
changeset 60
abae4669fba7
parent 58
ucx/memstream.h@733f22fca61a
child 61
fb07a0ab9a17
permissions
-rw-r--r--

renamed UcxMemstream to UcxBuffer

     1 #ifndef BUFFER_H
     2 #define	BUFFER_H
     4 #include <stdio.h>
     6 #ifdef	__cplusplus
     7 extern "C" {
     8 #endif
    11 /* the user shall not modify values */
    12 typedef struct UcxBuffer UcxBuffer;
    14 UcxBuffer *ucx_buffer_new(void *space, size_t length);
    15 void ucx_buffer_free(UcxBuffer* buffer);
    17 /*
    18  * Moves the position of the buffer to a new position relative to whence.
    19  *
    20  * SEEK_SET marks the start of the buffer
    21  * SEEK_CUR marks the current position
    22  * SEEK_END marks the first 0-byte in the buffer
    23  *
    24  * ucx_memseek returns 0 on success and -1 if the new position is beyond the
    25  * bounds of the allocated buffer. In that case the position of the buffer
    26  * remains unchanged.
    27  *
    28  */
    29 int ucx_buffer_seek(UcxBuffer *buffer, off_t offset, int whence);
    30 size_t ucx_buffer_tell(UcxBuffer *buffer);
    32 /*
    33  * returns non-zero, iff the current buffer position has exceeded the last
    34  * available byte of the underlying buffer
    35  *
    36  */
    37 int ucx_buffer_eof(UcxBuffer *buffer);
    39 size_t ucx_bufio(void *d, size_t s, size_t n, UcxBuffer* b, _Bool read);
    40 #define ucx_buffer_write(data, itemsize, nitems, buffer) \
    41     ucx_bufio(data, itemsize, nitems, buffer, 0)
    42 #define ucx_buffer_read(data, itemsize, nitems, buffer) \
    43         ucx_bufio(data, itemsize, nitems, buffer, 1)
    44 int ucx_buffer_putc(UcxBuffer *b, int c);
    45 int ucx_buffer_getc(UcxBuffer *b);
    47 #ifdef	__cplusplus
    48 }
    49 #endif
    51 #endif	/* BUFFER_H */

mercurial