Allow vcprintf() to be called by external code such as the curses library.

Also trim another eight bytes from vsprintf.o.  :)
This commit is contained in:
Michael Brown
2006-05-22 15:41:01 +00:00
parent f778500739
commit 84a493b88d
2 changed files with 67 additions and 38 deletions

View File

@@ -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 );