blob: f5e459f21993ef68c1520ed6310c15d3f635de8c [file] [log] [blame]
Lev Walkind9221842017-08-22 01:44:56 -07001#ifndef ASN1_BUFFER_H
2#define ASN1_BUFFER_H
3
Lev Walkine3204e72017-08-23 06:22:53 -07004#include <stdarg.h>
5
Lev Walkind9221842017-08-22 01:44:56 -07006/*
7 * Your typical dynamic character string buffer.
8 */
9typedef struct {
10 const char *buffer;
11 size_t length;
12 size_t size;
13} abuf;
14
15/*
16 * Create and destroy the buffer.
17 */
18abuf *abuf_new(void);
19void abuf_free(abuf *);
20
21/*
22 * Erase contents of the buffer (without destroying it).
23 */
24void abuf_clear(abuf *);
25
26/*
27 * Add characters to the buffer.
28 */
29void abuf_str(abuf *, const char *str);
30void abuf_buf(abuf *, const abuf *);
Lev Walkine3204e72017-08-23 06:22:53 -070031void abuf_add_bytes(abuf *, const char *, size_t);
32int abuf_printf(abuf *, const char *fmt, ...)
Lev Walkind9221842017-08-22 01:44:56 -070033 __attribute__((format(printf, 2, 3)));
Lev Walkine3204e72017-08-23 06:22:53 -070034int abuf_vprintf(abuf *, const char *fmt, va_list);
Lev Walkind9221842017-08-22 01:44:56 -070035
36#endif /* ASN1_BUFFER_H */