Lev Walkin | d922184 | 2017-08-22 01:44:56 -0700 | [diff] [blame] | 1 | #ifndef ASN1_BUFFER_H |
| 2 | #define ASN1_BUFFER_H |
| 3 | |
| 4 | /* |
| 5 | * Your typical dynamic character string buffer. |
| 6 | */ |
| 7 | typedef struct { |
| 8 | const char *buffer; |
| 9 | size_t length; |
| 10 | size_t size; |
| 11 | } abuf; |
| 12 | |
| 13 | /* |
| 14 | * Create and destroy the buffer. |
| 15 | */ |
| 16 | abuf *abuf_new(void); |
| 17 | void abuf_free(abuf *); |
| 18 | |
| 19 | /* |
| 20 | * Erase contents of the buffer (without destroying it). |
| 21 | */ |
| 22 | void abuf_clear(abuf *); |
| 23 | |
| 24 | /* |
| 25 | * Add characters to the buffer. |
| 26 | */ |
| 27 | void abuf_str(abuf *, const char *str); |
| 28 | void abuf_buf(abuf *, const abuf *); |
| 29 | void abuf_printf(abuf *, const char *fmt, ...) |
| 30 | __attribute__((format(printf, 2, 3))); |
| 31 | |
| 32 | #endif /* ASN1_BUFFER_H */ |