2 #define ZPM_BUFFER_H_ 1
9 * 0x1 secure: zero memory when used
10 * 0x2 fixed: buffer doesn't belong to you, and size says how big it is
21 struct zpm_buffer_reader {
26 uint32_t zpm_buffer_next3(struct zpm_buffer_reader *rb);
27 uint16_t zpm_buffer_next2(struct zpm_buffer_reader *rb);
28 uint8_t zpm_buffer_next(struct zpm_buffer_reader *rb);
29 void zpm_buffer_nextn(struct zpm_buffer_reader *rb, unsigned char *b, size_t n);
31 void zpm_buffer_init(struct zpm_buffer *b);
33 /* makes sure there's at least need bytes free */
34 void zpm_buffer_expand(struct zpm_buffer *b, size_t need);
35 void zpm_buffer_free(struct zpm_buffer *b);
36 void zpm_buffer_set(struct zpm_buffer *buffer, int ch);
37 void zpm_buffer_compact(struct zpm_buffer *b);
38 void zpm_buffer_append(struct zpm_buffer *b, const unsigned char *bytes, size_t n);
39 void zpm_buffer_appendf(struct zpm_buffer *b, const char *fmt, ...);
40 void zpm_buffer_appendvf(struct zpm_buffer *b, const char *fmt, va_list ap);
41 void zpm_buffer_append_str(struct zpm_buffer *b, const char *s);
42 void zpm_buffer_append16(struct zpm_buffer *b, uint16_t n);
43 void zpm_buffer_append24(struct zpm_buffer *b, uint32_t n);
44 void zpm_buffer_append_byte(struct zpm_buffer *b, uint8_t n);
45 void zpm_buffer_shift(struct zpm_buffer *b, size_t n);
46 void zpm_buffer_write16(struct zpm_buffer *b, uint16_t n, size_t at);
47 void zpm_buffer_writebe(struct zpm_buffer *b, int bytes, size_t at, uint64_t val);
48 uint64_t zpm_buffer_readbe(struct zpm_buffer *b, int bytes, size_t at);
50 /* make room at the beginning */
51 void zpm_buffer_unshift(struct zpm_buffer *b, size_t n);