TianoCore EDK2 master
|
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
Go to the source code of this file.
Macros | |
#define | MAX_STRING_SIZE 0x10000000 |
#define | LLONG_MIN MIN_INT64 |
#define | LLONG_MAX MAX_INT64 |
#define | HUGE_VAL 0 |
#define | va_list VA_LIST |
#define | va_arg VA_ARG |
#define | va_start VA_START |
#define | va_end VA_END |
#define | INT_MAX MAX_INT32 /* Maximum (signed) int value */ |
#define | LONG_MAX 0X7FFFFFFFL /* max value for a long */ |
#define | LONG_MIN (-LONG_MAX-1) /* min value for a long */ |
#define | ULONG_MAX 0xFFFFFFFF /* Maximum unsigned long value */ |
#define | CHAR_BIT 8 /* Number of bits in a char */ |
#define | ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL |
#define | UCHAR_MAX 255 |
#define | true (1 == 1) |
#define | false (1 == 0) |
#define | strcmp AsciiStrCmp |
#define | memcpy(dest, source, count) CopyMem(dest,source,(UINTN)(count)) |
#define | memset(dest, ch, count) SetMem(dest,(UINTN)(count),(UINT8)(ch)) |
#define | memchr(buf, ch, count) ScanMem8(buf,(UINTN)(count),(UINT8)ch) |
#define | memcmp(buf1, buf2, count) (int)(CompareMem(buf1,buf2,(UINTN)(count))) |
#define | memmove(dest, source, count) CopyMem(dest,source,(UINTN)(count)) |
#define | strlen(str) (size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE)) |
#define | strcpy(strDest, strSource) AsciiStrCpyS(strDest,(strlen(strSource)+1),strSource) |
#define | strncpy(strDest, strSource, count) AsciiStrnCpyS(strDest,(UINTN)count,strSource,(UINTN)count) |
#define | strncpys(strDest, DestLen, strSource, count) AsciiStrnCpyS(strDest,DestLen,strSource,(UINTN)count) |
#define | strcat(strDest, strSource) AsciiStrCatS(strDest,(strlen(strSource)+strlen(strDest)+1),strSource) |
#define | strchr(str, ch) ScanMem8((VOID *)(str),AsciiStrSize(str),(UINT8)ch) |
#define | strcasecmp(str1, str2) (int)AsciiStriCmp(str1,str2) |
#define | strstr(s1, s2) AsciiStrStr(s1,s2) |
#define | snprintf(buf, len, ...) RedfishAsciiSPrint(buf,len,__VA_ARGS__) |
#define | vsnprintf(buf, len, format, marker) RedfishAsciiVSPrint((buf),(len),(format),(marker)) |
#define | assert(expression) ASSERT(expression) |
#define | offsetof(type, member) OFFSET_OF(type,member) |
#define | EOF (-1) |
#define | ERANGE 34 /* 34 Result too large */ |
Typedefs | |
typedef UINTN | size_t |
typedef INTN | ssize_t |
typedef INT32 | time_t |
typedef INT32 | int32_t |
typedef UINT32 | uint32_t |
typedef UINT16 | uint16_t |
typedef UINT8 | uint8_t |
typedef BOOLEAN | bool |
typedef VOID * | FILE |
Functions | |
UINTN EFIAPI | RedfishAsciiSPrint (OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString,...) |
UINTN EFIAPI | RedfishAsciiVSPrint (OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN VA_LIST Marker) |
void * | malloc (size_t) |
void * | realloc (void *, size_t) |
void * | calloc (size_t Num, size_t Size) |
void | free (void *) |
int | isdigit (int) |
int | isspace (int) |
int | tolower (int) |
int | isupper (int) |
int | isxdigit (int) |
int | isalnum (int) |
int | strncmp (const char *, const char *, size_t) |
int | strncasecmp (const char *, const char *, size_t) |
char * | strrchr (const char *, int) |
unsigned long | strtoul (const char *, char **, int) |
long | strtol (const char *, char **, int) |
char * | strerror (int) |
size_t | strspn (const char *, const char *) |
char * | strdup (const char *str) |
char * | strpbrk (const char *s1, const char *s2) |
unsigned long long | strtoull (const char *nptr, char **endptr, int base) |
long long | strtoll (const char *nptr, char **endptr, int base) |
double | strtod (const char *__restrict nptr, char **__restrict endptr) |
size_t | strcspn (const char *, const char *) |
int | printf (const char *,...) |
int | sscanf (const char *, const char *,...) |
FILE * | fopen (const char *, const char *) |
size_t | fread (void *, size_t, size_t, FILE *) |
size_t | fwrite (const void *, size_t, size_t, FILE *) |
int | fclose (FILE *) |
int | fprintf (FILE *, const char *,...) |
int | fgetc (FILE *_File) |
void | qsort (void *, size_t, size_t, int(*)(const void *, const void *)) |
char * | getenv (const char *) |
void | abort (void) |
int | toupper (int) |
int | Digit2Val (int) |
time_t | time (time_t *) |
Variables | |
int | errno |
FILE * | stderr |
Redfish CRT wrapper functions.
Copyright (c) 2019, Intel Corporation. All rights reserved.
(C) Copyright 2021 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file RedfishCrtLib.h.
#define assert | ( | expression | ) | ASSERT(expression) |
Definition at line 403 of file RedfishCrtLib.h.
#define CHAR_BIT 8 /* Number of bits in a char */ |
Definition at line 62 of file RedfishCrtLib.h.
#define EOF (-1) |
Definition at line 406 of file RedfishCrtLib.h.
#define ERANGE 34 /* 34 Result too large */ |
Definition at line 410 of file RedfishCrtLib.h.
#define false (1 == 0) |
Definition at line 82 of file RedfishCrtLib.h.
#define HUGE_VAL 0 |
Definition at line 28 of file RedfishCrtLib.h.
#define INT_MAX MAX_INT32 /* Maximum (signed) int value */ |
Definition at line 58 of file RedfishCrtLib.h.
#define LLONG_MAX MAX_INT64 |
Definition at line 25 of file RedfishCrtLib.h.
#define LLONG_MIN MIN_INT64 |
Definition at line 22 of file RedfishCrtLib.h.
#define LONG_MAX 0X7FFFFFFFL /* max value for a long */ |
Definition at line 59 of file RedfishCrtLib.h.
#define LONG_MIN (-LONG_MAX-1) /* min value for a long */ |
Definition at line 60 of file RedfishCrtLib.h.
#define MAX_STRING_SIZE 0x10000000 |
Definition at line 19 of file RedfishCrtLib.h.
Definition at line 390 of file RedfishCrtLib.h.
#define memcmp | ( | buf1, | |
buf2, | |||
count | |||
) | (int)(CompareMem(buf1,buf2,(UINTN)(count))) |
Definition at line 391 of file RedfishCrtLib.h.
Definition at line 388 of file RedfishCrtLib.h.
Definition at line 392 of file RedfishCrtLib.h.
Definition at line 389 of file RedfishCrtLib.h.
#define offsetof | ( | type, | |
member | |||
) | OFFSET_OF(type,member) |
Definition at line 404 of file RedfishCrtLib.h.
#define snprintf | ( | buf, | |
len, | |||
... | |||
) | RedfishAsciiSPrint(buf,len,__VA_ARGS__) |
Definition at line 401 of file RedfishCrtLib.h.
#define strcasecmp | ( | str1, | |
str2 | |||
) | (int)AsciiStriCmp(str1,str2) |
Definition at line 399 of file RedfishCrtLib.h.
#define strcat | ( | strDest, | |
strSource | |||
) | AsciiStrCatS(strDest,(strlen(strSource)+strlen(strDest)+1),strSource) |
Definition at line 397 of file RedfishCrtLib.h.
#define strchr | ( | str, | |
ch | |||
) | ScanMem8((VOID *)(str),AsciiStrSize(str),(UINT8)ch) |
Definition at line 398 of file RedfishCrtLib.h.
#define strcmp AsciiStrCmp |
Definition at line 387 of file RedfishCrtLib.h.
#define strcpy | ( | strDest, | |
strSource | |||
) | AsciiStrCpyS(strDest,(strlen(strSource)+1),strSource) |
Definition at line 394 of file RedfishCrtLib.h.
#define strlen | ( | str | ) | (size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE)) |
Definition at line 393 of file RedfishCrtLib.h.
#define strncpy | ( | strDest, | |
strSource, | |||
count | |||
) | AsciiStrnCpyS(strDest,(UINTN)count,strSource,(UINTN)count) |
Definition at line 395 of file RedfishCrtLib.h.
#define strncpys | ( | strDest, | |
DestLen, | |||
strSource, | |||
count | |||
) | AsciiStrnCpyS(strDest,DestLen,strSource,(UINTN)count) |
Definition at line 396 of file RedfishCrtLib.h.
#define strstr | ( | s1, | |
s2 | |||
) | AsciiStrStr(s1,s2) |
Definition at line 400 of file RedfishCrtLib.h.
#define true (1 == 1) |
Definition at line 81 of file RedfishCrtLib.h.
#define UCHAR_MAX 255 |
Definition at line 67 of file RedfishCrtLib.h.
#define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL |
Definition at line 65 of file RedfishCrtLib.h.
#define ULONG_MAX 0xFFFFFFFF /* Maximum unsigned long value */ |
Definition at line 61 of file RedfishCrtLib.h.
#define va_arg VA_ARG |
Definition at line 46 of file RedfishCrtLib.h.
#define va_end VA_END |
Definition at line 48 of file RedfishCrtLib.h.
#define va_list VA_LIST |
Definition at line 45 of file RedfishCrtLib.h.
#define va_start VA_START |
Definition at line 47 of file RedfishCrtLib.h.
#define vsnprintf | ( | buf, | |
len, | |||
format, | |||
marker | |||
) | RedfishAsciiVSPrint((buf),(len),(format),(marker)) |
Definition at line 402 of file RedfishCrtLib.h.
typedef BOOLEAN bool |
Definition at line 79 of file RedfishCrtLib.h.
typedef VOID* FILE |
Definition at line 88 of file RedfishCrtLib.h.
typedef INT32 int32_t |
Definition at line 75 of file RedfishCrtLib.h.
typedef UINTN size_t |
Definition at line 72 of file RedfishCrtLib.h.
typedef INTN ssize_t |
Definition at line 73 of file RedfishCrtLib.h.
typedef INT32 time_t |
Definition at line 74 of file RedfishCrtLib.h.
typedef UINT16 uint16_t |
Definition at line 77 of file RedfishCrtLib.h.
typedef UINT32 uint32_t |
Definition at line 76 of file RedfishCrtLib.h.
typedef UINT8 uint8_t |
Definition at line 78 of file RedfishCrtLib.h.
void abort | ( | void | ) |
Definition at line 555 of file CrtWrapper.c.
void * calloc | ( | size_t | Num, |
size_t | Size | ||
) |
Allocate and zero-initialize array.
Definition at line 663 of file RedfishCrtLib.c.
int Digit2Val | ( | int | c | ) |
Digit to a value.
Definition at line 156 of file RedfishCrtLib.c.
int fclose | ( | FILE * | stream | ) |
Close file, we don't support file operastion on edk2 JSON library.
Definition at line 565 of file CrtWrapper.c.
int fgetc | ( | FILE * | _File | ) |
Get character from stream, we don't support file operastion on edk2 JSON library.
Definition at line 798 of file RedfishCrtLib.c.
FILE * fopen | ( | const char * | filename, |
const char * | mode | ||
) |
Open stream file, we don't support file operastion on edk2 JSON library.
Definition at line 573 of file CrtWrapper.c.
int fprintf | ( | FILE * | stream, |
const char * | format, | ||
... | |||
) |
Write the formatted string to file, we don't support file operastion on edk2 JSON library.
Definition at line 875 of file RedfishCrtLib.c.
size_t fread | ( | void * | ptr, |
size_t | size, | ||
size_t | count, | ||
FILE * | stream | ||
) |
Read stream from file, we don't support file operastion on edk2 JSON library.
Definition at line 582 of file CrtWrapper.c.
void free | ( | void * | ptr | ) |
De-allocates or frees a memory block
Definition at line 107 of file BaseMemAllocation.c.
size_t fwrite | ( | const void * | ptr, |
size_t | size, | ||
size_t | count, | ||
FILE * | stream | ||
) |
Write stream from file, we don't support file operastion on edk2 JSON library.
Definition at line 513 of file CrtWrapper.c.
char * getenv | ( | const char * | varname | ) |
Definition at line 480 of file CrtWrapper.c.
int isalnum | ( | int | c | ) |
Determine if a particular character is an alphanumeric character
Definition at line 370 of file CrtWrapper.c.
int isdigit | ( | int | c | ) |
Definition at line 332 of file CrtWrapper.c.
int isspace | ( | int | c | ) |
Determine if a particular character is a space character
Definition at line 358 of file CrtWrapper.c.
int isupper | ( | int | c | ) |
Definition at line 384 of file CrtWrapper.c.
int isxdigit | ( | int | c | ) |
Definition at line 344 of file CrtWrapper.c.
void * malloc | ( | size_t | size | ) |
int printf | ( | const char * | fmt, |
... | |||
) |
Definition at line 625 of file CrtWrapper.c.
void qsort | ( | void * | base, |
size_t | num, | ||
size_t | width, | ||
int(*)(const void *, const void *) | compare | ||
) |
Performs a quick sort
Definition at line 447 of file CrtWrapper.c.
void * realloc | ( | void * | ptr, |
size_t | size | ||
) |
Definition at line 64 of file BaseMemAllocation.c.
UINTN EFIAPI RedfishAsciiSPrint | ( | OUT CHAR8 * | StartOfBuffer, |
IN UINTN | BufferSize, | ||
IN CONST CHAR8 * | FormatString, | ||
... | |||
) |
This is the Redfish version of CRT snprintf function, this function replaces "%s" to "%a" before invoking AsciiSPrint(). That is becasue "%s" is unicode base on edk2 environment however "%s" is ascii code base on snprintf(). See definitions of AsciiSPrint() for the details.
StartOfBuffer | A pointer to the output buffer for the produced Null-terminated ASCII string. |
BufferSize | The size, in bytes, of the output buffer specified by StartOfBuffer. |
FormatString | A Null-terminated ASCII format string. |
... | Variable argument list whose contents are accessed based on the format string specified by FormatString. |
This is the Redfish version of CRT snprintf function, this function replaces "%s" to "%a" before invoking AsciiSPrint(). That is because "%s" is unicode base on edk2 environment however "%s" is ascii code base on snprintf(). See definitions of AsciiSPrint() for the details.
StartOfBuffer | A pointer to the output buffer for the produced Null-terminated ASCII string. |
BufferSize | The size, in bytes, of the output buffer specified by StartOfBuffer. |
FormatString | A Null-terminated ASCII format string. |
... | Variable argument list whose contents are accessed based on the format string specified by FormatString. |
Definition at line 1097 of file RedfishCrtLib.c.
UINTN EFIAPI RedfishAsciiVSPrint | ( | OUT CHAR8 * | StartOfBuffer, |
IN UINTN | BufferSize, | ||
IN CONST CHAR8 * | FormatString, | ||
IN VA_LIST | Marker | ||
) |
This is the Redfish version of CRT vsnprintf function, this function replaces "%s" to "%a" before invoking AsciiVSPrint(). That is because "%s" is unicode base on edk2 environment however "%s" is ascii code base on vsnprintf(). See definitions of AsciiVSPrint() for the details.
StartOfBuffer | A pointer to the output buffer for the produced Null-terminated ASCII string. |
BufferSize | The size, in bytes, of the output buffer specified by StartOfBuffer. |
FormatString | A Null-terminated ASCII format string. |
Marker | VA_LIST marker for the variable argument list. |
Definition at line 1053 of file RedfishCrtLib.c.
int sscanf | ( | const char * | buffer, |
const char * | format, | ||
... | |||
) |
Definition at line 180 of file CrtWrapper.c.
size_t strcspn | ( | const char * | s1, |
const char * | s2 | ||
) |
Definition at line 239 of file CrtWrapper.c.
char * strdup | ( | const char * | str | ) |
NetBSD Compatibility Function strdup creates a duplicate copy of a string.
Definition at line 110 of file RedfishCrtLib.c.
char * strerror | ( | int | errnum | ) |
The strerror function maps the number in errnum to a message string. Typically, the values for errnum come from errno, but strerror shall map any value of type int to a message.
The implementation shall behave as if no library function calls the strerror function.
Definition at line 195 of file CrtWrapper.c.
int strncasecmp | ( | const char * | s1, |
const char * | s2, | ||
size_t | n | ||
) |
Definition at line 149 of file CrtWrapper.c.
char * strpbrk | ( | const char * | s1, |
const char * | s2 | ||
) |
The strpbrk function locates the first occurrence in the string pointed to by s1 of any character from the string pointed to by s2.
Definition at line 617 of file RedfishCrtLib.c.
char * strrchr | ( | const char * | str, |
int | c | ||
) |
Definition at line 129 of file CrtWrapper.c.
size_t strspn | ( | const char * | s1, |
const char * | s2 | ||
) |
Definition at line 205 of file CrtWrapper.c.
double strtod | ( | const char *__restrict | nptr, |
char **__restrict | endptr | ||
) |
edk2 Jansson port does not support doubles, simply return integer part.
These conversion functions convert the initial portion of the string pointed to by nptr to double, float, and long double representation, respectively.
The strtod(), strtof(), and strtold() functions return the converted value, if any.
If endptr is not NULL, a pointer to the character after the last charac- ter used in the conversion is stored in the location referenced by endptr.
If no conversion is performed, zero is returned and the value of nptr is stored in the location referenced by endptr.
If the correct value would cause overflow, plus or minus HUGE_VAL, HUGE_VALF, or HUGE_VALL is returned (according to the sign and type of the return value), and ERANGE is stored in errno. If the correct value would cause underflow, zero is returned and ERANGE is stored in errno.
Definition at line 547 of file RedfishCrtLib.c.
long strtol | ( | const char * | nptr, |
char ** | endptr, | ||
int | base | ||
) |
The strtol, strtoll, strtoul, and strtoull functions convert the initial portion of the string pointed to by nptr to long int, long long int, unsigned long int, and unsigned long long int representation, respectively. First, they decompose the input string into three parts: an initial, possibly empty, sequence of white-space characters (as specified by the isspace function), a subject sequence resembling an integer represented in some radix determined by the value of base, and a final string of one or more unrecognized characters, including the terminating null character of the input string. Then, they attempt to convert the subject sequence to an integer, and return the result.
If the value of base is zero, the expected form of the subject sequence is that of an integer constant, optionally preceded by a plus or minus sign, but not including an integer suffix. If the value of base is between 2 and 36 (inclusive), the expected form of the subject sequence is a sequence of letters and digits representing an integer with the radix specified by base, optionally preceded by a plus or minus sign, but not including an integer suffix. The letters from a (or A) through z (or Z) are ascribed the values 10 through 35; only letters and digits whose ascribed values are less than that of base are permitted. If the value of base is 16, the characters 0x or 0X may optionally precede the sequence of letters and digits, following the sign if present.
The subject sequence is defined as the longest initial subsequence of the input string, starting with the first non-white-space character, that is of the expected form. The subject sequence contains no characters if the input string is empty or consists entirely of white space, or if the first non-white-space character is other than a sign or a permissible letter or digit.
If the subject sequence has the expected form and the value of base is zero, the sequence of characters starting with the first digit is interpreted as an integer constant. If the subject sequence has the expected form and the value of base is between 2 and 36, it is used as the base for conversion, ascribing to each letter its value as given above. If the subject sequence begins with a minus sign, the value resulting from the conversion is negated (in the return type). A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is not a null pointer.
In other than the "C" locale, additional locale-specific subject sequence forms may be accepted.
If the subject sequence is empty or does not have the expected form, no conversion is performed; the value of nptr is stored in the object pointed to by endptr, provided that endptr is not a null pointer.
Definition at line 400 of file CrtWrapper.c.
long long strtoll | ( | const char * | nptr, |
char ** | endptr, | ||
int | base | ||
) |
The strtoll function converts the initial portion of the string pointed to by nptr to long long int representation.
See the description for strtol for more information.
Definition at line 180 of file RedfishCrtLib.c.
unsigned long strtoul | ( | const char * | nptr, |
char ** | endptr, | ||
int | base | ||
) |
Definition at line 415 of file CrtWrapper.c.
unsigned long long strtoull | ( | const char * | nptr, |
char ** | endptr, | ||
int | base | ||
) |
The strtoull function converts the initial portion of the string pointed to by nptr to unsigned long long int representation.
See the description for strtol for more information.
Definition at line 440 of file RedfishCrtLib.c.
time_t time | ( | time_t * | timer | ) |
time function.
Get the system time as seconds elapsed since midnight, January 1, 1970.
Definition at line 27 of file ConstantTimeClock.c.
int tolower | ( | int | c | ) |
Definition at line 430 of file CrtWrapper.c.
|
extern |
Copyright (c) 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition at line 408 of file RedfishCrtLib.h.
|
extern |
Definition at line 14 of file CrtWrapper.c.