ucx/memstream.h

changeset 58
733f22fca61a
parent 57
e18157c52985
equal deleted inserted replaced
57:e18157c52985 58:733f22fca61a
35 * returns non-zero, iff the current stream position has exceeded the last 35 * returns non-zero, iff the current stream position has exceeded the last
36 * available byte of the underlying buffer 36 * available byte of the underlying buffer
37 * 37 *
38 */ 38 */
39 int ucx_memeof(UcxMemstream *stream); 39 int ucx_memeof(UcxMemstream *stream);
40 /*
41 * returns non-zero, iff the current stream position has exceeded the length
42 * of the underlying buffer
43 *
44 * in contrast to ucx_memeof this function will return zero, if the current
45 * position exactly matches the buffer length
46 *
47 * this function should be called after any ucx_memprintf/ucx_memscanf call
48 */
49 int ucx_memoverflow(UcxMemstream *stream);
50 40
51 /* memwrite, memread, memputc and memreadc shall not generate overflows */ 41 /* memwrite, memread, memputc and memreadc shall not generate overflows */
52 size_t ucx_memio(void *d, size_t s, size_t n, UcxMemstream* m, _Bool read); 42 size_t ucx_memio(void *d, size_t s, size_t n, UcxMemstream* m, _Bool read);
53 #define ucx_memwrite(data, itemsize, nitems, memstream) \ 43 #define ucx_memwrite(data, itemsize, nitems, memstream) \
54 ucx_memio(data, itemsize, nitems, memstream, 0) 44 ucx_memio(data, itemsize, nitems, memstream, 0)
55 #define ucx_memread(data, itemsize, nitems, memstream) \ 45 #define ucx_memread(data, itemsize, nitems, memstream) \
56 ucx_memio(data, itemsize, nitems, memstream, 1) 46 ucx_memio(data, itemsize, nitems, memstream, 1)
57 int ucx_memputc(UcxMemstream *stream, int c); 47 int ucx_memputc(UcxMemstream *stream, int c);
58 int ucx_memgetc(UcxMemstream *stream); 48 int ucx_memgetc(UcxMemstream *stream);
59 49
60 /* printf / scanf may generate overflows */
61 int ucx_memprintf(UcxMemstream *stream, const char* format, ...);
62 int ucx_memscanf(UcxMemstream *stream, const char* format, ...);
63
64 #ifdef __cplusplus 50 #ifdef __cplusplus
65 } 51 }
66 #endif 52 #endif
67 53
68 #endif /* MEMSTREAM_H */ 54 #endif /* MEMSTREAM_H */

mercurial