UEFIStarter
a simple UEFI framework
Macros | Functions
string.c File Reference

String functions missing from EDK. More...

#include <Library/UefiLib.h>
#include <Library/MemoryAllocationLib.h>
#include <UEFIStarter/core/memory.h>
#include <UEFIStarter/core/string.h>
#include <UEFIStarter/core/logger.h>

Macros

#define FTOWCS_MIN_VALUE   -1000000000.0
 the lowest value ftowcs() can parse
 
#define FTOWCS_MAX_VALUE   1000000000.0
 the highest value ftowcs() can parse
 

Functions

CHAR16 * ftowcs (double value)
 Converts a double value into a UTF-16 string with 3 decimals. More...
 
UINT64 atoui64 (char *str)
 Converts an ASCII integer string to UINT64. More...
 
BOOLEAN ctype_whitespace (char ch)
 Checks if an ASCII character is a whitespace. More...
 
CHAR16 * sprint_status (CHAR16 *function, EFI_STATUS code)
 Helper function to format an EFI function call result into a human-readable string. More...
 
void print_status (CHAR16 *function, EFI_STATUS code)
 Prints a nicely formatted EFI function call result. More...
 
CHAR16 *EFIAPI memsprintf (const CHAR16 *fmt,...)
 sprintf() replacement that tracks allocated pool memory for automatic cleanup. More...
 
UINTN split_string (CHAR16 ***list, CHAR16 *input, CHAR16 separator)
 Splits a string by a separator character into an array of strings. More...
 

Detailed Description

String functions missing from EDK.

Author
Richard Nusser
License
GPLv3 (see http://www.gnu.org/licenses/)
See also
https://github.com/rinusser/UEFIStarter

Function Documentation

◆ ftowcs()

CHAR16* ftowcs ( double  value)

Converts a double value into a UTF-16 string with 3 decimals.

Will only convert numbers between FTOWCS_MIN_VALUE and FTOWCS_MAX_VALUE.

Parameters
valuethe number to convert
Returns
the number as a UTF-16 string, or NULL on error
Todo:
make number of decimals configurable

◆ atoui64()

UINT64 atoui64 ( char *  str)

Converts an ASCII integer string to UINT64.

Parameters
strthe integer string to convert, as ASCII
Returns
the UINT64 integer, or -1 on error

◆ ctype_whitespace()

BOOLEAN ctype_whitespace ( char  ch)

Checks if an ASCII character is a whitespace.

Parameters
chthe ASCII character to check
Returns
whether it's a whitespace character

◆ sprint_status()

CHAR16* sprint_status ( CHAR16 *  function,
EFI_STATUS  code 
)

Helper function to format an EFI function call result into a human-readable string.

Parameters
functionthe function name, as UTF-16
codethe resulting EFI status code
Returns
the pretty-printed UTF-16 string

◆ print_status()

void print_status ( CHAR16 *  function,
EFI_STATUS  code 
)

Prints a nicely formatted EFI function call result.

Parameters
functionthe function name, as UTF-16
codethe resulting EFI status code
Todo:
check if this function is still required

◆ memsprintf()

CHAR16* EFIAPI memsprintf ( const CHAR16 *  fmt,
  ... 
)

sprintf() replacement that tracks allocated pool memory for automatic cleanup.

This function uses the same format codes as Print().

Parameters
fmtthe format string, as UTF-16
...any additional parameters matching the format string placeholders
Returns
a pointer to the formatted UTF-16 string

◆ split_string()

UINTN split_string ( CHAR16 ***  list,
CHAR16 *  input,
CHAR16  separator 
)

Splits a string by a separator character into an array of strings.

Parameters
listthe address where to write the resulting array of strings to
inputthe text to split
separatorthe character to split the text by
Returns
the number of array entries