TianoCore EDK2 master
|
#include <Uefi.h>
#include <Library/RedfishCrtLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/SortLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
Go to the source code of this file.
Macros | |
#define | WHICH8(c) ((unsigned char)(c) >> 3) |
#define | WHICH_BIT(c) (BitMask[((c) & 0x7)]) |
#define | BITMAP64 ((UINT64 *)bitmap) |
#define | IsLeap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) |
#define | SECSPERMIN (60) |
#define | SECSPERHOUR (60 * 60) |
#define | SECSPERDAY (24 * SECSPERHOUR) |
Functions | |
int | isalnum (int c) |
int | isdchar (int c) |
int | isspace (int c) |
void * | malloc (size_t size) |
void | free (void *ptr) |
char * | strdup (const char *str) |
int | toupper (IN int c) |
int | Digit2Val (int c) |
long long | strtoll (const char *nptr, char **endptr, int base) |
long | strtol (const char *nptr, char **endptr, int base) |
unsigned long long | strtoull (const char *nptr, char **endptr, int base) |
double | strtod (const char *__restrict nptr, char **__restrict endptr) |
char * | strpbrk (const char *s1, const char *s2) |
char * | strerror (int errnum) |
void * | calloc (size_t Num, size_t Size) |
time_t | time (time_t *timer) |
void | qsort (void *base, size_t num, size_t width, int(*compare)(const void *, const void *)) |
int | fgetc (FILE *_File) |
FILE * | fopen (const char *filename, const char *mode) |
size_t | fread (void *ptr, size_t size, size_t count, FILE *stream) |
size_t | fwrite (const void *ptr, size_t size, size_t count, FILE *stream) |
int | fclose (FILE *stream) |
int | fprintf (FILE *stream, const char *format,...) |
BOOLEAN | CheckFormatingString (IN CONST CHAR8 *FormatString, IN OUT UINTN *CurrentPosition, IN UINTN StrLength) |
CHAR8 * | ReplaceUnicodeToAsciiStrFormat (IN CONST CHAR8 *FormatString) |
UINTN EFIAPI | RedfishAsciiVSPrint (OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN VA_LIST Marker) |
UINTN EFIAPI | RedfishAsciiSPrint (OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString,...) |
Variables | |
int | errno = 0 |
char | errnum_message [] = "We don't support to map errnum to the error message on edk2 Redfish\n" |
int | _fltused = 1 |
UINTN | CumulativeDays [2][14] |
CRT wrapper functions for system call,the string operation functions are remodeled after edk2-libc.
Copyright (c) 2019, Intel Corporation. All rights reserved.
(C) Copyright 2020 Hewlett Packard Enterprise Development LP
Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file RedfishCrtLib.c.
#define BITMAP64 ((UINT64 *)bitmap) |
Definition at line 584 of file RedfishCrtLib.c.
#define IsLeap | ( | y | ) | (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) |
Definition at line 725 of file RedfishCrtLib.c.
#define SECSPERDAY (24 * SECSPERHOUR) |
Definition at line 728 of file RedfishCrtLib.c.
#define SECSPERHOUR (60 * 60) |
Definition at line 727 of file RedfishCrtLib.c.
#define SECSPERMIN (60) |
Definition at line 726 of file RedfishCrtLib.c.
#define WHICH8 | ( | c | ) | ((unsigned char)(c) >> 3) |
Definition at line 582 of file RedfishCrtLib.c.
#define WHICH_BIT | ( | c | ) | (BitMask[((c) & 0x7)]) |
Definition at line 583 of file RedfishCrtLib.c.
void * calloc | ( | size_t | Num, |
size_t | Size | ||
) |
Allocate and zero-initialize array.
Definition at line 663 of file RedfishCrtLib.c.
BOOLEAN CheckFormatingString | ( | IN CONST CHAR8 * | FormatString, |
IN OUT UINTN * | CurrentPosition, | ||
IN UINTN | StrLength | ||
) |
This function check if this is the formating string specifier.
[in] | FormatString | A Null-terminated ASCII format string. |
[in,out] | CurrentPosition | The starting position at the given string to check for "[flags][width][.precision][length]s" string specifier. |
[in] | StrLength | Maximum string length. |
Definition at line 899 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 861 of file RedfishCrtLib.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 812 of file RedfishCrtLib.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 827 of file RedfishCrtLib.c.
void free | ( | void * | ptr | ) |
De-allocates or frees a memory block
Definition at line 91 of file RedfishCrtLib.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 844 of file RedfishCrtLib.c.
int isalnum | ( | int | c | ) |
Determine if a particular character is an alphanumeric character
Definition at line 29 of file RedfishCrtLib.c.
int isdchar | ( | int | c | ) |
Determine if a particular character is a digital character
Definition at line 47 of file RedfishCrtLib.c.
int isspace | ( | int | c | ) |
Determine if a particular character is a space character
Definition at line 66 of file RedfishCrtLib.c.
void * malloc | ( | size_t | size | ) |
Allocates memory blocks
Definition at line 80 of file RedfishCrtLib.c.
void qsort | ( | void * | base, |
size_t | num, | ||
size_t | width, | ||
int(*)(const void *, const void *) | compare | ||
) |
Performs a quick sort
Definition at line 777 of file RedfishCrtLib.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 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.
This function clones *FormatString however replaces "%s" with "%a" in the returned string.
[in] | A | Null-terminated ASCII format string. |
Definition at line 944 of file RedfishCrtLib.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 652 of file RedfishCrtLib.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.
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 332 of file RedfishCrtLib.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 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 | ) |
Get the system time as seconds elapsed since midnight, January 1, 1970.
Definition at line 734 of file RedfishCrtLib.c.
int toupper | ( | IN int | c | ) |
The toupper function converts a lowercase letter to a corresponding uppercase letter.
[in] | c | The character to be converted. |
Definition at line 139 of file RedfishCrtLib.c.
int _fltused = 1 |
Definition at line 22 of file RedfishCrtLib.c.
UINTN CumulativeDays[2][14] |
Definition at line 690 of file RedfishCrtLib.c.
int errno = 0 |
Copyright (c) 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition at line 18 of file RedfishCrtLib.c.
char errnum_message[] = "We don't support to map errnum to the error message on edk2 Redfish\n" |
Definition at line 19 of file RedfishCrtLib.c.