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 
11 #include <stddef.h>
12 #include <stdint.h>
13 #include <stdarg.h>
14 
15 extern int efi_vsnprintf ( wchar_t *wbuf, size_t wsize, const char *fmt,
16  va_list args );
17 extern int efi_snprintf ( wchar_t *wbuf, size_t wsize, const char *fmt, ... );
18 extern int efi_vssnprintf ( wchar_t *wbuf, ssize_t swsize, const char *fmt,
19  va_list args );
20 extern int efi_ssnprintf ( wchar_t *wbuf, ssize_t swsize,
21  const char *fmt, ... );
22 
23 /**
24  * Write a formatted string to a wide-character buffer
25  *
26  * @v wbuf Buffer into which to write the string
27  * @v fmt Format string
28  * @v args Arguments corresponding to the format string
29  * @ret wlen Length of formatted string (in wide characters)
30  */
31 static inline int efi_vsprintf ( wchar_t *buf, const char *fmt, va_list args ) {
32  return efi_vsnprintf ( buf, ~( ( size_t ) 0 ), fmt, args );
33 }
34 
35 /**
36  * Write a formatted string to a buffer
37  *
38  * @v wbuf Buffer into which to write the string
39  * @v fmt Format string
40  * @v ... Arguments corresponding to the format string
41  * @ret wlen Length of formatted string (in wide characters)
42  */
43 #define efi_sprintf( buf, fmt, ... ) \
44  efi_snprintf ( (buf), ~( ( size_t ) 0 ), (fmt), ## __VA_ARGS__ )
45 
46 #endif /* _IPXE_EFI_STRINGS_H */
int efi_snprintf(wchar_t *wbuf, size_t wsize, const char *fmt,...)
Write a formatted string to a buffer.
Definition: efi_strings.c:104
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:72
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:143
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:123
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:31
__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