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
34FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
35FILE_SECBOOT ( PERMITTED );
36
37#include <stdint.h>
38#include <stdarg.h>
39#include <stdio.h>
40
41/**
42 * A printf context
43 *
44 * Contexts are used in order to be able to share code between
45 * vprintf() and vsnprintf(), without requiring the allocation of a
46 * buffer for vprintf().
47 */
49 /**
50 * Character handler
51 *
52 * @v ctx Context
53 * @v c Character
54 *
55 * This method is called for each character written to the
56 * formatted string.
57 */
58 void ( * handler ) ( struct printf_context *ctx, unsigned int c );
59 /** Length of formatted string
60 *
61 * When handler() is called, @len will be set to the number of
62 * characters written so far (i.e. zero for the first call to
63 * handler()).
64 */
65 size_t len;
66};
67
68extern size_t vcprintf ( struct printf_context *ctx, const char *fmt,
69 va_list args );
70extern int vssnprintf ( char *buf, ssize_t ssize, const char *fmt,
71 va_list args );
72extern int __attribute__ (( format ( printf, 3, 4 ) ))
73ssnprintf ( char *buf, ssize_t ssize, const char *fmt, ... );
74
75#endif /* _IPXE_VSPRINTF_H */
struct golan_eq_context ctx
Definition CIB_PRM.h:0
signed long ssize_t
Definition stdint.h:7
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
__builtin_va_list va_list
Definition stdarg.h:7
A printf context.
Definition vsprintf.h:48
size_t len
Length of formatted string.
Definition vsprintf.h:65
void(* handler)(struct printf_context *ctx, unsigned int c)
Character handler.
Definition vsprintf.h:58
int ssnprintf(char *buf, ssize_t ssize, const char *fmt,...)
Version of vsnprintf() that accepts a signed buffer size.
Definition vsprintf.c:421
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition vsprintf.c:465
int ssize_t ssize
Definition vsprintf.h:73
int ssize_t const char * fmt
Definition vsprintf.h:73
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:402
size_t vcprintf(struct printf_context *ctx, const char *fmt, va_list args)
Write a formatted string to a printf context.
Definition vsprintf.c:188
int const char * format
Definition xfer.h:105