diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/vsprintf.h | 29 |
1 files changed, 29 insertions, 0 deletions
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 ); |
