ucx/buffer.h

changeset 62
6814aea8462d
parent 61
fb07a0ab9a17
child 63
1d3500806565
equal deleted inserted replaced
61:fb07a0ab9a17 62:6814aea8462d
1 #ifndef BUFFER_H 1 #ifndef BUFFER_H
2 #define BUFFER_H 2 #define BUFFER_H
3 3
4 #include <sys/types.h>
4 #include <stdio.h> 5 #include <stdio.h>
5 6
6 #ifdef __cplusplus 7 #ifdef __cplusplus
7 extern "C" { 8 extern "C" {
8 #endif 9 #endif
16 /* if space is NULL, new space is allocated and the autofree flag is enforced */ 17 /* if space is NULL, new space is allocated and the autofree flag is enforced */
17 UcxBuffer *ucx_buffer_new(void *space, size_t length, int flags); 18 UcxBuffer *ucx_buffer_new(void *space, size_t length, int flags);
18 void ucx_buffer_free(UcxBuffer* buffer); 19 void ucx_buffer_free(UcxBuffer* buffer);
19 20
20 /* 21 /*
22 * the autofree flag is enforced for the new buffer
23 * if length is zero, the whole remaining buffer shall be extracted
24 * the position of the new buffer is set to zero
25 */
26 UcxBuffer *ucx_buffer_extract(UcxBuffer *src,
27 size_t start, size_t length, int flags);
28 #define ucx_buffer_clone(src,flags) \
29 ucx_buffer_extract(src, 0, 0, flags)
30
31 /*
21 * Moves the position of the buffer to a new position relative to whence. 32 * Moves the position of the buffer to a new position relative to whence.
22 * 33 *
23 * SEEK_SET marks the start of the buffer 34 * SEEK_SET marks the start of the buffer
24 * SEEK_CUR marks the current position 35 * SEEK_CUR marks the current position
25 * SEEK_END marks the first 0-byte in the buffer 36 * SEEK_END marks the first 0-byte in the buffer
29 * remains unchanged. 40 * remains unchanged.
30 * 41 *
31 */ 42 */
32 int ucx_buffer_seek(UcxBuffer *buffer, off_t offset, int whence); 43 int ucx_buffer_seek(UcxBuffer *buffer, off_t offset, int whence);
33 size_t ucx_buffer_tell(UcxBuffer *buffer); 44 size_t ucx_buffer_tell(UcxBuffer *buffer);
45 size_t ucx_buffer_size(UcxBuffer *buffer);
46 /* returns non-zero, if at least the specified flags are set */
47 int ucx_buffer_testflags(UcxBuffer *buffer, int flags);
34 48
35 /* 49 /*
36 * returns non-zero, iff the current buffer position has exceeded the last 50 * returns non-zero, iff the current buffer position has exceeded the last
37 * available byte of the underlying buffer 51 * available byte of the underlying buffer
38 * 52 *

mercurial