X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/9085749a5c2916629dd3c04adf57e4b5e8f3ec8e..00c7638bc6791b810069381b8aaebfeac67cdfee:/dstr.h diff --git a/dstr.h b/dstr.h index b7240fe..73b1ceb 100644 --- a/dstr.h +++ b/dstr.h @@ -1,6 +1,6 @@ /* -*-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 * @@ -29,8 +29,12 @@ /*----- 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 * */ @@ -53,6 +57,7 @@ /*----- Header files ------------------------------------------------------*/ +#include #include /*----- Data structures ---------------------------------------------------*/ @@ -170,6 +175,36 @@ extern void dstr_puts(dstr */*d*/, const char */*s*/); (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