X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/e63124bc579bfd97cfe2f620ddd84df9f20477d8..c91413e6acbc8d157ff52ceb8cd78cee97403584:/utils/gprintf.h diff --git a/utils/gprintf.h b/utils/gprintf.h index 9e32338..0f06dd3 100644 --- a/utils/gprintf.h +++ b/utils/gprintf.h @@ -86,6 +86,33 @@ extern int PRINTF_LIKE(3, 4) gprintf(const struct gprintf_ops */*ops*/, void */*out*/, const char */*p*/, ...); +/* --- @gprintf_memputf@ --- * + * + * Arguments: @char **buf_inout@ = address of output buffer pointer + * @size_t *sz_inout@ = address of buffer size + * @size_t maxsz@ = buffer size needed for this operation + * @const char *p@ = pointer to format string + * @va_list *ap@ = captured format-arguments tail + * + * Returns: The formatted length. + * + * Use: Generic utility for mostly implementing the @nputf@ output + * function, if you don't have a better option. + * + * On entry, @*buf_inout@ should be null or a buffer pointer, + * with @*sz_inout@ either zero or the buffer's size, + * respectively. On exit, @*buf_input@ and @*sz_inout@ will be + * updated, if necessary, to describe a sufficiently large + * buffer, and the formatted string will have been written to + * the buffer. + * + * When the buffer is no longer required, free it using @xfree@. + */ + +extern size_t gprintf_memputf(char **/*buf_inout*/, size_t */*sz_inout*/, + size_t /*maxsz*/, + const char */*p*/, va_list /*ap*/); + /*----- That's all, folks -------------------------------------------------*/ #ifdef __cplusplus