#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#ifndef MLIB_ALLOC_H
# include "alloc.h"
# include "arena.h"
#endif
+#ifndef MLIB_MACROS_H
+# include "macros.h"
+#endif
+
/*----- Data structures ---------------------------------------------------*/
typedef struct dstr {
#define DSTR_INIT { 0, 0, 0, &arena_stdlib } /* How to initialize one */
+extern const struct gprintf_ops dstr_printops;
+
/*----- Functions provided ------------------------------------------------*/
/* --- @dstr_create@ --- *
/* --- @dstr_putc@ --- *
*
* Arguments: @dstr *d@ = pointer to a dynamic string block
- * @char ch@ = character to append
+ * @int ch@ = character to append
*
* Returns: ---
*
* Use: Appends a character to a string.
*/
-extern void dstr_putc(dstr */*d*/, char /*ch*/);
+extern void dstr_putc(dstr */*d*/, int /*ch*/);
#define DPUTC(d, ch) do { \
dstr *_d = (d); \
DENSURE(_d, 1); \
- _d->buf[_d->len++] = (ch); \
+ *((unsigned char *)_d->buf + _d->len++) = (ch); \
} while (0)
/* --- @dstr_putz@ --- *
* itself is malicious.
*/
-extern int dstr_putf(dstr */*d*/, const char */*p*/, ...);
+extern PRINTF_LIKE(2, 3) int dstr_putf(dstr */*d*/, const char */*p*/, ...);
/* --- @dstr_putd@ --- *
*