Rename gpxe to .
[grub-extras.git] / src / include / gpxe / vsprintf.h
blobee860a52c8e6139c4c009076f5f0b807dd3f2c6b
1 #ifndef _GPXE_VSPRINTF_H
2 #define _GPXE_VSPRINTF_H
4 /** @file
6 * printf() and friends
8 * Etherboot's printf() functions understand the following subset of
9 * the standard C printf()'s format specifiers:
11 * - Flag characters
12 * - '#' - Alternate form (i.e. "0x" prefix)
13 * - '0' - Zero-pad
14 * - Field widths
15 * - Length modifiers
16 * - 'hh' - Signed / unsigned char
17 * - 'h' - Signed / unsigned short
18 * - 'l' - Signed / unsigned long
19 * - 'll' - Signed / unsigned long long
20 * - 'z' - Signed / unsigned size_t
21 * - Conversion specifiers
22 * - 'd' - Signed decimal
23 * - 'x','X' - Unsigned hexadecimal
24 * - 'c' - Character
25 * - 's' - String
26 * - 'p' - Pointer
28 * Hexadecimal numbers are always zero-padded to the specified field
29 * width (if any); decimal numbers are always space-padded. Decimal
30 * long longs are not supported.
34 FILE_LICENCE ( GPL2_OR_LATER );
36 #include <stdint.h>
37 #include <stdarg.h>
38 #include <stdio.h>
40 /**
41 * A printf context
43 * Contexts are used in order to be able to share code between
44 * vprintf() and vsnprintf(), without requiring the allocation of a
45 * buffer for vprintf().
47 struct printf_context {
48 /**
49 * Character handler
51 * @v ctx Context
52 * @v c Character
54 * This method is called for each character written to the
55 * formatted string.
57 void ( * handler ) ( struct printf_context *ctx, unsigned int c );
58 /** Length of formatted string
60 * When handler() is called, @len will be set to the number of
61 * characters written so far (i.e. zero for the first call to
62 * handler()).
64 size_t len;
67 extern size_t vcprintf ( struct printf_context *ctx, const char *fmt,
68 va_list args );
69 extern int vssnprintf ( char *buf, ssize_t ssize, const char *fmt,
70 va_list args );
71 extern int __attribute__ (( format ( printf, 3, 4 ) ))
72 ssnprintf ( char *buf, ssize_t ssize, const char *fmt, ... );
74 #endif /* _GPXE_VSPRINTF_H */