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 
9 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
10 FILE_SECBOOT ( PERMITTED );
11 
12 #include <stddef.h>
13 #include <stdint.h>
14 #include <stdarg.h>
15 
16 extern int efi_vsnprintf ( wchar_t *wbuf, size_t wsize, const char *fmt,
17  va_list args );
18 extern int efi_snprintf ( wchar_t *wbuf, size_t wsize, const char *fmt, ... );
19 extern int efi_vssnprintf ( wchar_t *wbuf, ssize_t swsize, const char *fmt,
20  va_list args );
21 extern int efi_ssnprintf ( wchar_t *wbuf, ssize_t swsize,
22  const char *fmt, ... );
23 extern int efi_vasprintf ( wchar_t **strp, const char *fmt, va_list args );
24 extern 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  */
34 static 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 */
int efi_vasprintf(wchar_t **strp, const char *fmt, va_list args)
Write a formatted string to newly allocated memory.
Definition: efi_strings.c:165
int efi_snprintf(wchar_t *wbuf, size_t wsize, const char *fmt,...)
Write a formatted string to a buffer.
Definition: efi_strings.c:107
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
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_asprintf(wchar_t **strp, const char *fmt,...)
Write a formatted string to newly allocated memory.
Definition: efi_strings.c:189
int efi_ssnprintf(wchar_t *wbuf, ssize_t swsize, const char *fmt,...)
Version of efi_vsnprintf() that accepts a signed buffer size.
Definition: efi_strings.c:146
FILE_SECBOOT(PERMITTED)
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.
Definition: efi_strings.c:126
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
__builtin_va_list va_list
Definition: stdarg.h:7
int ssize_t const char * fmt
Definition: vsprintf.h:73
signed long ssize_t
Definition: stdint.h:7