From 84a493b88d88268dd0387d7d281a1c40fcc98680 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 22 May 2006 15:41:01 +0000 Subject: Allow vcprintf() to be called by external code such as the curses library. Also trim another eight bytes from vsprintf.o. :) --- src/include/vsprintf.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/include') diff --git a/src/include/vsprintf.h b/src/include/vsprintf.h index 99d6683e1..d5018d7cc 100644 --- a/src/include/vsprintf.h +++ b/src/include/vsprintf.h @@ -35,6 +35,35 @@ #define PRINTF_NO_LENGTH ( ( size_t ) -1 ) +/** + * A printf context + * + * Contexts are used in order to be able to share code between + * vprintf() and vsnprintf(), without requiring the allocation of a + * buffer for vprintf(). + */ +struct printf_context { + /** + * Character handler + * + * @v ctx Context + * @v c Character + * + * This method is called for each character written to the + * formatted string. + */ + void ( * handler ) ( struct printf_context *ctx, unsigned int c ); + /** Length of formatted string + * + * When handler() is called, @len will be set to the number of + * characters written so far (i.e. zero for the first call to + * handler()). + */ + size_t len; +}; + +extern size_t vcprintf ( struct printf_context *ctx, const char *fmt, + va_list args ); extern int vsnprintf ( char *buf, size_t size, const char *fmt, va_list args ); extern int vprintf ( const char *fmt, va_list args ); -- cgit v1.2.3-55-g7522