iPXE
efi_strings.h
Go to the documentation of this file.
1#ifndef _IPXE_EFI_STRINGS_H
2#define _IPXE_EFI_STRINGS_H
3
4/** @file
5 *
6 * EFI strings
7 */
8
9FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
10FILE_SECBOOT ( PERMITTED );
11
12#include <stddef.h>
13#include <stdint.h>
14#include <stdarg.h>
15
16extern int efi_vsnprintf ( wchar_t *wbuf, size_t wsize, const char *fmt,
17 va_list args );
18extern int efi_snprintf ( wchar_t *wbuf, size_t wsize, const char *fmt, ... );
19extern int efi_vssnprintf ( wchar_t *wbuf, ssize_t swsize, const char *fmt,
20 va_list args );
21extern int efi_ssnprintf ( wchar_t *wbuf, ssize_t swsize,
22 const char *fmt, ... );
23extern int efi_vasprintf ( wchar_t **strp, const char *fmt, va_list args );
24extern int efi_asprintf ( wchar_t **strp, const char *fmt, ... );
25
26/**
27 * Write a formatted string to a wide-character buffer
28 *
29 * @v wbuf Buffer into which to write the string
30 * @v fmt Format string
31 * @v args Arguments corresponding to the format string
32 * @ret wlen Length of formatted string (in wide characters)
33 */
34static inline int efi_vsprintf ( wchar_t *buf, const char *fmt, va_list args ) {
35 return efi_vsnprintf ( buf, ~( ( size_t ) 0 ), fmt, args );
36}
37
38/**
39 * Write a formatted string to a buffer
40 *
41 * @v wbuf Buffer into which to write the string
42 * @v fmt Format string
43 * @v ... Arguments corresponding to the format string
44 * @ret wlen Length of formatted string (in wide characters)
45 */
46#define efi_sprintf( buf, fmt, ... ) \
47 efi_snprintf ( (buf), ~( ( size_t ) 0 ), (fmt), ## __VA_ARGS__ )
48
49#endif /* _IPXE_EFI_STRINGS_H */
signed long ssize_t
Definition stdint.h:7
int efi_ssnprintf(wchar_t *wbuf, ssize_t swsize, const char *fmt,...)
Version of efi_vsnprintf() that accepts a signed buffer size.
int efi_vsnprintf(wchar_t *wbuf, size_t wsize, const char *fmt, va_list args)
Write a formatted string to a wide-character buffer.
Definition efi_strings.c:75
int efi_snprintf(wchar_t *wbuf, size_t wsize, const char *fmt,...)
Write a formatted string to a buffer.
int efi_vasprintf(wchar_t **strp, const char *fmt, va_list args)
Write a formatted string to newly allocated memory.
static int efi_vsprintf(wchar_t *buf, const char *fmt, va_list args)
Write a formatted string to a wide-character buffer.
Definition efi_strings.h:34
int efi_vssnprintf(wchar_t *wbuf, ssize_t swsize, const char *fmt, va_list args)
Version of efi_vsnprintf() that accepts a signed buffer size.
int efi_asprintf(wchar_t **strp, const char *fmt,...)
Write a formatted string to newly allocated memory.
#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
__builtin_va_list va_list
Definition stdarg.h:7
int ssize_t const char * fmt
Definition vsprintf.h:73