/* -*-c-*-
*
- * $Id: dstr.h,v 1.1 1998/06/17 23:44:42 mdw Exp $
+ * $Id: dstr.h,v 1.2 1998/12/15 23:53:23 mdw Exp $
*
* Handle dynamically growing strings
*
/*----- Revision history --------------------------------------------------*
*
* $Log: dstr.h,v $
- * Revision 1.1 1998/06/17 23:44:42 mdw
- * Initial revision
+ * Revision 1.2 1998/12/15 23:53:23 mdw
+ * New functions `dstr_putf' and `dstr_vputf' which do `printf'-style
+ * formatting in a safe way.
+ *
+ * Revision 1.1.1.1 1998/06/17 23:44:42 mdw
+ * Initial version of mLib
*
*/
/*----- Header files ------------------------------------------------------*/
+#include <stdarg.h>
#include <stdio.h>
/*----- Data structures ---------------------------------------------------*/
(d)->len += sz; \
} while (0)
+/* --- @dstr_vputf@ --- *
+ *
+ * Arguments: @dstr *d@ = pointer to a dynamic string block
+ * @const char *p@ = pointer to @printf@-style format string
+ * @va_list ap@ = argument handle
+ *
+ * Returns: ---
+ *
+ * Use: As for @dstr_putf@, but may be used as a back-end to user-
+ * supplied functions with @printf@-style interfaces.
+ */
+
+extern int dstr_vputf(dstr */*d*/, const char */*p*/, va_list /*ap*/);
+
+/* --- @dstr_putf@ --- *
+ *
+ * Arguments: @dstr *d@ = pointer to a dynamic string block
+ * @const char *p@ = pointer to @printf@-style format string
+ * @...@ = argument handle
+ *
+ * Returns: ---
+ *
+ * Use: Writes a piece of text to a dynamic string, doing @printf@-
+ * style substitutions as it goes. Intended to be robust if
+ * faced with malicious arguments, but not if the format string
+ * itself is malicious.
+ */
+
+extern int dstr_putf(dstr */*d*/, const char */*p*/, ...);
+
/* --- @dstr_putd@ --- *
*
* Arguments: @dstr *d@ = pointer to a dynamic string block