iPXE
vsprintf.h
Go to the documentation of this file.
1 #ifndef _IPXE_VSPRINTF_H
2 #define _IPXE_VSPRINTF_H
3 
4 /** @file
5  *
6  * printf() and friends
7  *
8  * Etherboot's printf() functions understand the following subset of
9  * the standard C printf()'s format specifiers:
10  *
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
27  *
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.
31  *
32  */
33 
34 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
35 
36 #include <stdint.h>
37 #include <stdarg.h>
38 #include <stdio.h>
39 
40 /**
41  * A printf context
42  *
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().
46  */
48  /**
49  * Character handler
50  *
51  * @v ctx Context
52  * @v c Character
53  *
54  * This method is called for each character written to the
55  * formatted string.
56  */
57  void ( * handler ) ( struct printf_context *ctx, unsigned int c );
58  /** Length of formatted string
59  *
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()).
63  */
64  size_t len;
65 };
66 
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, ... );
73 
74 #endif /* _IPXE_VSPRINTF_H */
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
void(* handler)(struct printf_context *ctx, unsigned int c)
Character handler.
Definition: vsprintf.h:57
size_t vcprintf(struct printf_context *ctx, const char *fmt, va_list args)
Write a formatted string to a printf context.
Definition: vsprintf.c:187
int vssnprintf(char *buf, ssize_t ssize, const char *fmt, va_list args)
Version of vsnprintf() that accepts a signed buffer size.
Definition: vsprintf.c:401
size_t len
Length of formatted string.
Definition: vsprintf.h:64
static __always_inline void off_t int c
Definition: efi_uaccess.h:87
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
int __attribute__((format(printf, 3, 4))) ssnprintf(char *buf
int ssnprintf(char *buf, ssize_t ssize, const char *fmt,...)
Version of vsnprintf() that accepts a signed buffer size.
Definition: vsprintf.c:420
A printf context.
Definition: vsprintf.h:47
int ssize_t ssize
Definition: vsprintf.h:72
__builtin_va_list va_list
Definition: stdarg.h:6
int ssize_t const char * fmt
Definition: vsprintf.h:72
signed long ssize_t
Definition: stdint.h:7
int const char * format
Definition: xfer.h:104
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)