iPXE
Defines | Functions
efi_strings.h File Reference

EFI strings. More...

#include <stddef.h>
#include <stdint.h>
#include <stdarg.h>

Go to the source code of this file.

Defines

#define efi_sprintf(buf, fmt,...)   efi_snprintf ( (buf), ~( ( size_t ) 0 ), (fmt), ## __VA_ARGS__ )
 Write a formatted string to a buffer.

Functions

 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.
int efi_snprintf (wchar_t *wbuf, size_t wsize, const char *fmt,...)
 Write a formatted string to a buffer.
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_ssnprintf (wchar_t *wbuf, ssize_t swsize, const char *fmt,...)
 Version of efi_vsnprintf() that accepts a signed buffer size.
static int efi_vsprintf (wchar_t *buf, const char *fmt, va_list args)
 Write a formatted string to a wide-character buffer.

Detailed Description

EFI strings.

Definition in file efi_strings.h.


Define Documentation

#define efi_sprintf (   buf,
  fmt,
  ... 
)    efi_snprintf ( (buf), ~( ( size_t ) 0 ), (fmt), ## __VA_ARGS__ )

Write a formatted string to a buffer.

Parameters:
wbufBuffer into which to write the string
fmtFormat string
...Arguments corresponding to the format string
Return values:
wlenLength of formatted string (in wide characters)

Definition at line 43 of file efi_strings.h.

Referenced by efi_block_boot_image().


Function Documentation

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.

Parameters:
wbufBuffer into which to write the string
wsizeSize of buffer (in wide characters)
fmtFormat string
argsArguments corresponding to the format string
Return values:
wlenLength of formatted string (in wide characters)

If the buffer is too small to contain the string, the returned length is the length that would have been written had enough space been available.

Definition at line 72 of file efi_strings.c.

References efi_sputc_context::buf, efi_sputc_context::ctx, efi_printf_sputc(), printf_context::handler, efi_sputc_context::max_wlen, and vcprintf().

Referenced by efi_ifr_string(), efi_snprintf(), efi_vsprintf(), and efi_vssnprintf().

                                   {
        struct efi_sputc_context sctx;
        size_t wlen;
        size_t wend;

        /* Hand off to vcprintf */
        sctx.ctx.handler = efi_printf_sputc;
        sctx.buf = wbuf;
        sctx.max_wlen = wsize;
        wlen = vcprintf ( &sctx.ctx, fmt, args );

        /* Add trailing NUL */
        if ( wsize ) {
                wend = wsize - 1;
                if ( wlen < wend )
                        wend = wlen;
                wbuf[wend] = '\0';
        }

        return wlen;
}
int efi_snprintf ( wchar_t wbuf,
size_t  wsize,
const char *  fmt,
  ... 
)

Write a formatted string to a buffer.

Parameters:
wbufBuffer into which to write the string
wsizeSize of buffer (in wide characters)
fmtFormat string
...Arguments corresponding to the format string
Return values:
wlenLength of formatted string (in wide characters)

Definition at line 104 of file efi_strings.c.

References efi_vsnprintf(), va_end, and va_start.

Referenced by efi_block_hook(), efi_file_varlen(), efi_image_cmdline(), efi_image_path(), efi_local_open_resolved(), efi_snp_hii_append(), and efi_snp_probe().

                                                                       {
        va_list args;
        int i;

        va_start ( args, fmt );
        i = efi_vsnprintf ( wbuf, wsize, fmt, args );
        va_end ( args );
        return i;
}
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.

Parameters:
wbufBuffer into which to write the string
swsizeSize of buffer (in wide characters)
fmtFormat string
argsArguments corresponding to the format string
Return values:
wlenLength of formatted string (in wide characters)

Definition at line 123 of file efi_strings.c.

References efi_vsnprintf().

Referenced by efi_ssnprintf().

                                    {

        /* Treat negative buffer size as zero buffer size */
        if ( swsize < 0 )
                swsize = 0;

        /* Hand off to vsnprintf */
        return efi_vsnprintf ( wbuf, swsize, fmt, args );
}
int efi_ssnprintf ( wchar_t wbuf,
ssize_t  swsize,
const char *  fmt,
  ... 
)

Version of efi_vsnprintf() that accepts a signed buffer size.

Parameters:
wbufBuffer into which to write the string
swsizeSize of buffer (in wide characters)
fmtFormat string
...Arguments corresponding to the format string
Return values:
wlenLength of formatted string (in wide characters)

Definition at line 143 of file efi_strings.c.

References efi_vssnprintf(), len, va_end, and va_start.

                                                                          {
        va_list args;
        int len;

        /* Hand off to vssnprintf */
        va_start ( args, fmt );
        len = efi_vssnprintf ( wbuf, swsize, fmt, args );
        va_end ( args );
        return len;
}
static int efi_vsprintf ( wchar_t buf,
const char *  fmt,
va_list  args 
) [inline, static]

Write a formatted string to a wide-character buffer.

Parameters:
wbufBuffer into which to write the string
fmtFormat string
argsArguments corresponding to the format string
Return values:
wlenLength of formatted string (in wide characters)

Definition at line 31 of file efi_strings.h.

References efi_vsnprintf().

                                                                               {
        return efi_vsnprintf ( buf, ~( ( size_t ) 0 ), fmt, args );
}