#include <Library/SortLib.h>\r
#include <Library/UefiRuntimeServicesTableLib.h>\r
\r
-int errno = 0;\r
-char errnum_message [] = "We don't support to map errnum to the error message on edk2 Redfish\n";\r
+int errno = 0;\r
+char errnum_message[] = "We don't support to map errnum to the error message on edk2 Redfish\n";\r
\r
// This is required to keep VC++ happy if you use floating-point\r
-int _fltused = 1;\r
+int _fltused = 1;\r
\r
/**\r
Determine if a particular character is an alphanumeric character\r
@return Returns 1 if c is an alphanumeric character, otherwise returns 0.\r
**/\r
-int isalnum (int c)\r
+int\r
+isalnum (\r
+ int c\r
+ )\r
{\r
//\r
// <alnum> ::= [0-9] | [a-z] | [A-Z]\r
\r
@return Returns 1 if c is an digital character, otherwise returns 0.\r
**/\r
-int isdchar (int c)\r
+int\r
+isdchar (\r
+ int c\r
+ )\r
{\r
//\r
// [0-9] | [e +-.]\r
\r
@return Returns 1 if c is a space character\r
**/\r
-int isspace (int c)\r
+int\r
+isspace (\r
+ int c\r
+ )\r
{\r
//\r
// <space> ::= [ ]\r
/**\r
Allocates memory blocks\r
*/\r
-void *malloc (size_t size)\r
+void *\r
+malloc (\r
+ size_t size\r
+ )\r
{\r
- return AllocatePool ((UINTN) size);\r
+ return AllocatePool ((UINTN)size);\r
}\r
\r
/**\r
De-allocates or frees a memory block\r
*/\r
-void free (void *ptr)\r
+void\r
+free (\r
+ void *ptr\r
+ )\r
{\r
//\r
// In Standard C, free() handles a null pointer argument transparently. This\r
\r
@return Returns the pointer to duplicated string.\r
**/\r
-char * strdup(const char *str)\r
+char *\r
+strdup (\r
+ const char *str\r
+ )\r
{\r
- size_t len;\r
- char *copy;\r
+ size_t len;\r
+ char *copy;\r
\r
- len = strlen(str) + 1;\r
- if ((copy = malloc(len)) == NULL)\r
+ len = strlen (str) + 1;\r
+ if ((copy = malloc (len)) == NULL) {\r
return (NULL);\r
- memcpy(copy, str, len);\r
+ }\r
+\r
+ memcpy (copy, str, len);\r
return (copy);\r
}\r
\r
returned unchanged.\r
**/\r
int\r
-toupper(\r
- IN int c\r
+toupper (\r
+ IN int c\r
)\r
{\r
- if ( (c >= 'a') && (c <= 'z') ) {\r
+ if ((c >= 'a') && (c <= 'z')) {\r
c = c - ('a' - 'A');\r
}\r
+\r
return c;\r
}\r
\r
@return Returns the value of digit.\r
**/\r
int\r
-Digit2Val( int c)\r
+Digit2Val (\r
+ int c\r
+ )\r
{\r
- if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) { /* If c is one of [A-Za-z]... */\r
- c = toupper(c) - 7; // Adjust so 'A' is ('9' + 1)\r
+ if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) {\r
+ /* If c is one of [A-Za-z]... */\r
+ c = toupper (c) - 7; // Adjust so 'A' is ('9' + 1)\r
}\r
+\r
return c - '0'; // Value returned is between 0 and 35, inclusive.\r
}\r
\r
-\r
/** The strtoll function converts the initial portion of the string pointed to\r
by nptr to long long int representation.\r
\r
and the value of the macro ERANGE is stored in errno.\r
**/\r
long long\r
-strtoll(const char * nptr, char ** endptr, int base)\r
+strtoll (\r
+ const char *nptr,\r
+ char **endptr,\r
+ int base\r
+ )\r
{\r
- const char *pEnd;\r
+ const char *pEnd;\r
long long Result = 0;\r
long long Previous;\r
int temp;\r
\r
pEnd = nptr;\r
\r
- if((base < 0) || (base == 1) || (base > 36)) {\r
- if(endptr != NULL) {\r
- *endptr = NULL;\r
+ if ((base < 0) || (base == 1) || (base > 36)) {\r
+ if (endptr != NULL) {\r
+ *endptr = NULL;\r
}\r
+\r
return 0;\r
}\r
+\r
// Skip leading spaces.\r
- while(isspace(*nptr)) ++nptr;\r
+ while (isspace (*nptr)) {\r
+ ++nptr;\r
+ }\r
\r
// Process Subject sequence: optional sign followed by digits.\r
- if(*nptr == '+') {\r
+ if (*nptr == '+') {\r
Negative = FALSE;\r
++nptr;\r
- }\r
- else if(*nptr == '-') {\r
+ } else if (*nptr == '-') {\r
Negative = TRUE;\r
++nptr;\r
}\r
\r
- if(*nptr == '0') { /* Might be Octal or Hex */\r
- if(toupper(nptr[1]) == 'X') { /* Looks like Hex */\r
- if((base == 0) || (base == 16)) {\r
+ if (*nptr == '0') {\r
+ /* Might be Octal or Hex */\r
+ if (toupper (nptr[1]) == 'X') {\r
+ /* Looks like Hex */\r
+ if ((base == 0) || (base == 16)) {\r
nptr += 2; /* Skip the "0X" */\r
- base = 16; /* In case base was 0 */\r
+ base = 16; /* In case base was 0 */\r
}\r
- }\r
- else { /* Looks like Octal */\r
- if((base == 0) || (base == 8)) {\r
+ } else {\r
+ /* Looks like Octal */\r
+ if ((base == 0) || (base == 8)) {\r
++nptr; /* Skip the leading "0" */\r
base = 8; /* In case base was 0 */\r
}\r
}\r
}\r
- if(base == 0) { /* If still zero then must be decimal */\r
+\r
+ if (base == 0) {\r
+ /* If still zero then must be decimal */\r
base = 10;\r
}\r
- if(*nptr == '0') {\r
- for( ; *nptr == '0'; ++nptr); /* Skip any remaining leading zeros */\r
+\r
+ if (*nptr == '0') {\r
+ for ( ; *nptr == '0'; ++nptr) {\r
+ /* Skip any remaining leading zeros */\r
+ }\r
+\r
pEnd = nptr;\r
}\r
\r
- while( isalnum(*nptr) && ((temp = Digit2Val(*nptr)) < base)) {\r
+ while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {\r
Previous = Result;\r
- Result = MultS64x64 (Result, base) + (long long int)temp;\r
- if( Result <= Previous) { // Detect Overflow\r
- if(Negative) {\r
+ Result = MultS64x64 (Result, base) + (long long int)temp;\r
+ if ( Result <= Previous) {\r
+ // Detect Overflow\r
+ if (Negative) {\r
Result = LLONG_MIN;\r
- }\r
- else {\r
+ } else {\r
Result = LLONG_MAX;\r
}\r
+\r
Negative = FALSE;\r
- errno = ERANGE;\r
+ errno = ERANGE;\r
break;\r
}\r
+\r
pEnd = ++nptr;\r
}\r
- if(Negative) {\r
+\r
+ if (Negative) {\r
Result = -Result;\r
}\r
\r
// Save pointer to final sequence\r
- if(endptr != NULL) {\r
+ if (endptr != NULL) {\r
*endptr = (char *)pEnd;\r
}\r
+\r
return Result;\r
}\r
\r
is stored in errno.\r
**/\r
long\r
-strtol(const char * nptr, char ** endptr, int base)\r
+strtol (\r
+ const char *nptr,\r
+ char **endptr,\r
+ int base\r
+ )\r
{\r
- const char *pEnd;\r
+ const char *pEnd;\r
long Result = 0;\r
long Previous;\r
int temp;\r
\r
pEnd = nptr;\r
\r
- if((base < 0) || (base == 1) || (base > 36)) {\r
- if(endptr != NULL) {\r
- *endptr = NULL;\r
+ if ((base < 0) || (base == 1) || (base > 36)) {\r
+ if (endptr != NULL) {\r
+ *endptr = NULL;\r
}\r
+\r
return 0;\r
}\r
+\r
// Skip leading spaces.\r
- while(isspace(*nptr)) ++nptr;\r
+ while (isspace (*nptr)) {\r
+ ++nptr;\r
+ }\r
\r
// Process Subject sequence: optional sign followed by digits.\r
- if(*nptr == '+') {\r
+ if (*nptr == '+') {\r
Negative = FALSE;\r
++nptr;\r
- }\r
- else if(*nptr == '-') {\r
+ } else if (*nptr == '-') {\r
Negative = TRUE;\r
++nptr;\r
}\r
\r
- if(*nptr == '0') { /* Might be Octal or Hex */\r
- if(toupper(nptr[1]) == 'X') { /* Looks like Hex */\r
- if((base == 0) || (base == 16)) {\r
+ if (*nptr == '0') {\r
+ /* Might be Octal or Hex */\r
+ if (toupper (nptr[1]) == 'X') {\r
+ /* Looks like Hex */\r
+ if ((base == 0) || (base == 16)) {\r
nptr += 2; /* Skip the "0X" */\r
- base = 16; /* In case base was 0 */\r
+ base = 16; /* In case base was 0 */\r
}\r
- }\r
- else { /* Looks like Octal */\r
- if((base == 0) || (base == 8)) {\r
+ } else {\r
+ /* Looks like Octal */\r
+ if ((base == 0) || (base == 8)) {\r
++nptr; /* Skip the leading "0" */\r
base = 8; /* In case base was 0 */\r
}\r
}\r
}\r
- if(base == 0) { /* If still zero then must be decimal */\r
+\r
+ if (base == 0) {\r
+ /* If still zero then must be decimal */\r
base = 10;\r
}\r
- if(*nptr == '0') {\r
- for( ; *nptr == '0'; ++nptr); /* Skip any remaining leading zeros */\r
+\r
+ if (*nptr == '0') {\r
+ for ( ; *nptr == '0'; ++nptr) {\r
+ /* Skip any remaining leading zeros */\r
+ }\r
+\r
pEnd = nptr;\r
}\r
\r
- while( isalnum(*nptr) && ((temp = Digit2Val(*nptr)) < base)) {\r
+ while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {\r
Previous = Result;\r
- Result = (Result * base) + (long int)temp;\r
- if( Result <= Previous) { // Detect Overflow\r
- if(Negative) {\r
+ Result = (Result * base) + (long int)temp;\r
+ if ( Result <= Previous) {\r
+ // Detect Overflow\r
+ if (Negative) {\r
Result = LONG_MIN;\r
- }\r
- else {\r
+ } else {\r
Result = LONG_MAX;\r
}\r
+\r
Negative = FALSE;\r
- errno = ERANGE;\r
+ errno = ERANGE;\r
break;\r
}\r
+\r
pEnd = ++nptr;\r
}\r
- if(Negative) {\r
+\r
+ if (Negative) {\r
Result = -Result;\r
}\r
\r
// Save pointer to final sequence\r
- if(endptr != NULL) {\r
+ if (endptr != NULL) {\r
*endptr = (char *)pEnd;\r
}\r
+\r
return Result;\r
}\r
\r
returned and the value of the macro ERANGE is stored in errno.\r
**/\r
unsigned long long\r
-strtoull(const char * nptr, char ** endptr, int base)\r
+strtoull (\r
+ const char *nptr,\r
+ char **endptr,\r
+ int base\r
+ )\r
{\r
- const char *pEnd;\r
- unsigned long long Result = 0;\r
- unsigned long long Previous;\r
- int temp;\r
+ const char *pEnd;\r
+ unsigned long long Result = 0;\r
+ unsigned long long Previous;\r
+ int temp;\r
\r
pEnd = nptr;\r
\r
- if((base < 0) || (base == 1) || (base > 36)) {\r
- if(endptr != NULL) {\r
- *endptr = NULL;\r
+ if ((base < 0) || (base == 1) || (base > 36)) {\r
+ if (endptr != NULL) {\r
+ *endptr = NULL;\r
}\r
+\r
return 0;\r
}\r
+\r
// Skip leading spaces.\r
- while(isspace(*nptr)) ++nptr;\r
+ while (isspace (*nptr)) {\r
+ ++nptr;\r
+ }\r
\r
// Process Subject sequence: optional + sign followed by digits.\r
- if(*nptr == '+') {\r
+ if (*nptr == '+') {\r
++nptr;\r
}\r
\r
- if(*nptr == '0') { /* Might be Octal or Hex */\r
- if(toupper(nptr[1]) == 'X') { /* Looks like Hex */\r
- if((base == 0) || (base == 16)) {\r
+ if (*nptr == '0') {\r
+ /* Might be Octal or Hex */\r
+ if (toupper (nptr[1]) == 'X') {\r
+ /* Looks like Hex */\r
+ if ((base == 0) || (base == 16)) {\r
nptr += 2; /* Skip the "0X" */\r
- base = 16; /* In case base was 0 */\r
+ base = 16; /* In case base was 0 */\r
}\r
- }\r
- else { /* Looks like Octal */\r
- if((base == 0) || (base == 8)) {\r
+ } else {\r
+ /* Looks like Octal */\r
+ if ((base == 0) || (base == 8)) {\r
++nptr; /* Skip the leading "0" */\r
base = 8; /* In case base was 0 */\r
}\r
}\r
}\r
- if(base == 0) { /* If still zero then must be decimal */\r
+\r
+ if (base == 0) {\r
+ /* If still zero then must be decimal */\r
base = 10;\r
}\r
- if(*nptr == '0') {\r
- for( ; *nptr == '0'; ++nptr); /* Skip any remaining leading zeros */\r
+\r
+ if (*nptr == '0') {\r
+ for ( ; *nptr == '0'; ++nptr) {\r
+ /* Skip any remaining leading zeros */\r
+ }\r
+\r
pEnd = nptr;\r
}\r
\r
- while( isalnum(*nptr) && ((temp = Digit2Val(*nptr)) < base)) {\r
+ while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {\r
Previous = Result;\r
- Result = DivU64x32 (Result, base) + (unsigned long long)temp;\r
- if( Result < Previous) { // If we overflowed\r
+ Result = DivU64x32 (Result, base) + (unsigned long long)temp;\r
+ if ( Result < Previous) {\r
+ // If we overflowed\r
Result = ULLONG_MAX;\r
- errno = ERANGE;\r
+ errno = ERANGE;\r
break;\r
}\r
+\r
pEnd = ++nptr;\r
}\r
\r
// Save pointer to final sequence\r
- if(endptr != NULL) {\r
+ if (endptr != NULL) {\r
*endptr = (char *)pEnd;\r
}\r
+\r
return Result;\r
}\r
\r
@return Return 0.\r
**/\r
double\r
-strtod (const char * __restrict nptr, char ** __restrict endptr) {\r
-\r
- DEBUG((DEBUG_INFO, "We don't supprot double type on edk2 yet!"));\r
- ASSERT(FALSE);\r
- return (double)0;\r
+strtod (\r
+ const char *__restrict nptr,\r
+ char **__restrict endptr\r
+ )\r
+{\r
+ DEBUG ((DEBUG_INFO, "We don't supprot double type on edk2 yet!"));\r
+ ASSERT (FALSE);\r
+ return (double)0;\r
}\r
\r
static UINT8 BitMask[] = {\r
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80\r
- };\r
+};\r
\r
#define WHICH8(c) ((unsigned char)(c) >> 3)\r
#define WHICH_BIT(c) (BitMask[((c) & 0x7)])\r
-#define BITMAP64 ((UINT64 *)bitmap)\r
+#define BITMAP64 ((UINT64 *)bitmap)\r
\r
static\r
void\r
-BuildBitmap(unsigned char * bitmap, const char *s2, int n)\r
+BuildBitmap (\r
+ unsigned char *bitmap,\r
+ const char *s2,\r
+ int n\r
+ )\r
{\r
- unsigned char bit;\r
- int index;\r
+ unsigned char bit;\r
+ int index;\r
\r
// Initialize bitmap. Bit 0 is always 1 which corresponds to '\0'\r
for (BITMAP64[0] = index = 1; index < n; index++) {\r
}\r
\r
// Set bits in bitmap corresponding to the characters in s2\r
- for (; *s2 != '\0'; s2++) {\r
- index = WHICH8(*s2);\r
- bit = WHICH_BIT(*s2);\r
+ for ( ; *s2 != '\0'; s2++) {\r
+ index = WHICH8 (*s2);\r
+ bit = WHICH_BIT (*s2);\r
bitmap[index] = bitmap[index] | bit;\r
}\r
}\r
null pointer if no character from s2 occurs in s1.\r
**/\r
char *\r
-strpbrk(const char *s1, const char *s2)\r
+strpbrk (\r
+ const char *s1,\r
+ const char *s2\r
+ )\r
{\r
- UINT8 bitmap[ (((UCHAR_MAX + 1) / CHAR_BIT) + (CHAR_BIT - 1)) & ~7U];\r
- UINT8 bit;\r
- int index;\r
+ UINT8 bitmap[(((UCHAR_MAX + 1) / CHAR_BIT) + (CHAR_BIT - 1)) & ~7U];\r
+ UINT8 bit;\r
+ int index;\r
\r
- BuildBitmap( bitmap, s2, sizeof(bitmap) / sizeof(UINT64));\r
+ BuildBitmap (bitmap, s2, sizeof (bitmap) / sizeof (UINT64));\r
\r
- for( ; *s1 != '\0'; ++s1) {\r
- index = WHICH8(*s1);\r
- bit = WHICH_BIT(*s1);\r
- if( (bitmap[index] & bit) != 0) {\r
+ for ( ; *s1 != '\0'; ++s1) {\r
+ index = WHICH8 (*s1);\r
+ bit = WHICH_BIT (*s1);\r
+ if ((bitmap[index] & bit) != 0) {\r
return (char *)s1;\r
}\r
}\r
+\r
return NULL;\r
}\r
\r
a subsequent call to the strerror function.\r
**/\r
char *\r
-strerror(int errnum)\r
+strerror (\r
+ int errnum\r
+ )\r
{\r
return errnum_message;\r
}\r
Allocate and zero-initialize array.\r
**/\r
void *\r
-calloc(size_t Num, size_t Size)\r
+calloc (\r
+ size_t Num,\r
+ size_t Size\r
+ )\r
{\r
- void *RetVal;\r
- size_t NumSize;\r
+ void *RetVal;\r
+ size_t NumSize;\r
\r
NumSize = Num * Size;\r
RetVal = NULL;\r
if (NumSize != 0) {\r
- RetVal = malloc(NumSize);\r
- if( RetVal != NULL) {\r
- (VOID)ZeroMem( RetVal, NumSize);\r
- }\r
+ RetVal = malloc (NumSize);\r
+ if ( RetVal != NULL) {\r
+ (VOID)ZeroMem (RetVal, NumSize);\r
+ }\r
}\r
- DEBUG((DEBUG_POOL, "0x%p = calloc(%d, %d)\n", RetVal, Num, Size));\r
+\r
+ DEBUG ((DEBUG_POOL, "0x%p = calloc(%d, %d)\n", RetVal, Num, Size));\r
\r
return RetVal;\r
}\r
// month number used as the index (1 -> 12) for regular and leap years.\r
// The value at index 13 is for the whole year.\r
//\r
-UINTN CumulativeDays[2][14] = {\r
+UINTN CumulativeDays[2][14] = {\r
{\r
0,\r
0,\r
}\r
};\r
\r
-#define IsLeap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))\r
-#define SECSPERMIN (60)\r
-#define SECSPERHOUR (60 * 60)\r
-#define SECSPERDAY (24 * SECSPERHOUR)\r
+#define IsLeap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))\r
+#define SECSPERMIN (60)\r
+#define SECSPERHOUR (60 * 60)\r
+#define SECSPERDAY (24 * SECSPERHOUR)\r
\r
/**\r
Get the system time as seconds elapsed since midnight, January 1, 1970.\r
**/\r
-time_t time (time_t *timer)\r
+time_t\r
+time (\r
+ time_t *timer\r
+ )\r
{\r
EFI_TIME Time;\r
time_t CalTime;\r
// UTime should now be set to 00:00:00 on Jan 1 of the current year.\r
//\r
for (Year = 1970, CalTime = 0; Year != Time.Year; Year++) {\r
- CalTime = CalTime + (time_t)(CumulativeDays[IsLeap(Year)][13] * SECSPERDAY);\r
+ CalTime = CalTime + (time_t)(CumulativeDays[IsLeap (Year)][13] * SECSPERDAY);\r
}\r
\r
//\r
//\r
CalTime = CalTime +\r
(time_t)((Time.TimeZone != EFI_UNSPECIFIED_TIMEZONE) ? (Time.TimeZone * 60) : 0) +\r
- (time_t)(CumulativeDays[IsLeap(Time.Year)][Time.Month] * SECSPERDAY) +\r
+ (time_t)(CumulativeDays[IsLeap (Time.Year)][Time.Month] * SECSPERDAY) +\r
(time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) +\r
(time_t)(Time.Hour * SECSPERHOUR) +\r
(time_t)(Time.Minute * 60) +\r
/**\r
Performs a quick sort\r
**/\r
-void qsort (void *base, size_t num, size_t width, int (*compare)(const void *, const void *))\r
+void\r
+qsort (\r
+ void *base,\r
+ size_t num,\r
+ size_t width,\r
+ int ( *compare )(const void *, const void *)\r
+ )\r
{\r
-\r
ASSERT (base != NULL);\r
ASSERT (compare != NULL);\r
\r
@return Returns the character currently pointed by the internal file position indicator of the specified stream\r
\r
**/\r
-int fgetc(FILE * _File){\r
- return EOF;\r
+int\r
+fgetc (\r
+ FILE *_File\r
+ )\r
+{\r
+ return EOF;\r
}\r
+\r
/**\r
Open stream file, we don't support file operastion on edk2 JSON library.\r
\r
@return 0 Unsupported\r
\r
**/\r
-FILE *fopen (const char *filename, const char *mode) {\r
+FILE *\r
+fopen (\r
+ const char *filename,\r
+ const char *mode\r
+ )\r
+{\r
return NULL;\r
}\r
+\r
/**\r
Read stream from file, we don't support file operastion on edk2 JSON library.\r
\r
@return 0 Unsupported\r
\r
**/\r
-size_t fread (void * ptr, size_t size, size_t count, FILE * stream) {\r
+size_t\r
+fread (\r
+ void *ptr,\r
+ size_t size,\r
+ size_t count,\r
+ FILE *stream\r
+ )\r
+{\r
return 0;\r
}\r
+\r
/**\r
Write stream from file, we don't support file operastion on edk2 JSON library.\r
\r
@return 0 Unsupported\r
\r
**/\r
-size_t fwrite (const void * ptr, size_t size, size_t count, FILE * stream) {\r
+size_t\r
+fwrite (\r
+ const void *ptr,\r
+ size_t size,\r
+ size_t count,\r
+ FILE *stream\r
+ )\r
+{\r
return 0;\r
}\r
+\r
/**\r
Close file, we don't support file operastion on edk2 JSON library.\r
\r
@return 0 Unsupported\r
\r
**/\r
-int fclose (FILE * stream) {\r
+int\r
+fclose (\r
+ FILE *stream\r
+ )\r
+{\r
return EOF;\r
}\r
+\r
/**\r
Write the formatted string to file, we don't support file operastion on edk2 JSON library.\r
\r
@return 0 Unsupported\r
\r
**/\r
-int fprintf (FILE * stream, const char * format, ...) {\r
+int\r
+fprintf (\r
+ FILE *stream,\r
+ const char *format,\r
+ ...\r
+ )\r
+{\r
return -1;\r
}\r
+\r
/**\r
This function check if this is the formating string specifier.\r
\r
**/\r
BOOLEAN\r
CheckFormatingString (\r
- IN CONST CHAR8 *FormatString,\r
- IN OUT UINTN *CurrentPosition,\r
- IN UINTN StrLength\r
+ IN CONST CHAR8 *FormatString,\r
+ IN OUT UINTN *CurrentPosition,\r
+ IN UINTN StrLength\r
)\r
{\r
- CHAR8 FormatStringParamater;\r
+ CHAR8 FormatStringParamater;\r
\r
while (*(FormatString + *CurrentPosition) != 's') {\r
//\r
(FormatStringParamater != '*') &&\r
(FormatStringParamater != '.') &&\r
!(((UINTN)FormatStringParamater >= (UINTN)'0') && ((UINTN)FormatStringParamater <= (UINTN)'9'))\r
- ) {\r
+ )\r
+ {\r
return FALSE;\r
}\r
+\r
(*CurrentPosition)++;\r
if (*CurrentPosition >= StrLength) {\r
return FALSE;\r
}\r
- };\r
+ }\r
+\r
return TRUE;\r
}\r
\r
**/\r
CHAR8 *\r
ReplaceUnicodeToAsciiStrFormat (\r
- IN CONST CHAR8 *FormatString\r
-)\r
+ IN CONST CHAR8 *FormatString\r
+ )\r
{\r
- UINTN FormatStrSize;\r
- UINTN FormatStrIndex;\r
- UINTN FormatStrSpecifier;\r
- BOOLEAN PercentageMark;\r
- CHAR8 *TempFormatBuffer;\r
- BOOLEAN IsFormatString;\r
+ UINTN FormatStrSize;\r
+ UINTN FormatStrIndex;\r
+ UINTN FormatStrSpecifier;\r
+ BOOLEAN PercentageMark;\r
+ CHAR8 *TempFormatBuffer;\r
+ BOOLEAN IsFormatString;\r
\r
//\r
// Error checking.\r
if (FormatString == NULL) {\r
return NULL;\r
}\r
- FormatStrSize = AsciiStrSize(FormatString);\r
+\r
+ FormatStrSize = AsciiStrSize (FormatString);\r
if (FormatStrSize == 0) {\r
return NULL;\r
}\r
- TempFormatBuffer = AllocatePool(FormatStrSize); // Allocate memory for the\r
- // new string.\r
- if (TempFormatBuffer== NULL) {\r
+\r
+ TempFormatBuffer = AllocatePool (FormatStrSize); // Allocate memory for the\r
+ // new string.\r
+ if (TempFormatBuffer == NULL) {\r
return NULL;\r
}\r
+\r
//\r
// Clone *FormatString but replace "%s" wih "%a".\r
// "%%" is not considered as the format tag.\r
// Previous character is "%".\r
//\r
PercentageMark = FALSE;\r
- if (*(FormatString + FormatStrIndex) != '%') { // Check if this is double "%".\r
+ if (*(FormatString + FormatStrIndex) != '%') {\r
+ // Check if this is double "%".\r
FormatStrSpecifier = FormatStrIndex;\r
//\r
// Check if this is the formating string specifier.\r
//\r
IsFormatString = CheckFormatingString (FormatString, &FormatStrSpecifier, FormatStrSize);\r
if ((FormatStrSpecifier - FormatStrIndex) != 0) {\r
- CopyMem((VOID *)(TempFormatBuffer + FormatStrIndex),\r
- (VOID *)(FormatString + FormatStrIndex),\r
- FormatStrSpecifier - FormatStrIndex\r
- );\r
+ CopyMem (\r
+ (VOID *)(TempFormatBuffer + FormatStrIndex),\r
+ (VOID *)(FormatString + FormatStrIndex),\r
+ FormatStrSpecifier - FormatStrIndex\r
+ );\r
}\r
+\r
FormatStrIndex = FormatStrSpecifier;\r
if (IsFormatString == TRUE) {\r
//\r
// format on edk2 environment.\r
//\r
*(TempFormatBuffer + FormatStrSpecifier) = 'a';\r
- FormatStrIndex ++;\r
+ FormatStrIndex++;\r
}\r
+\r
continue;\r
}\r
+\r
goto ContinueCheck;\r
}\r
+\r
if (*(FormatString + FormatStrIndex) == '%') {\r
//\r
// This character is "%", set the flag.\r
//\r
PercentageMark = TRUE;\r
}\r
+\r
ContinueCheck:\r
//\r
// Clone character to the new string and advance FormatStrIndex\r
//\r
*(TempFormatBuffer + FormatStrIndex) = *(FormatString + FormatStrIndex);\r
FormatStrIndex++;\r
- };\r
+ }\r
+\r
return TempFormatBuffer;\r
}\r
\r
UINTN\r
EFIAPI\r
RedfishAsciiVSPrint (\r
- OUT CHAR8 *StartOfBuffer,\r
- IN UINTN BufferSize,\r
- IN CONST CHAR8 *FormatString,\r
- IN VA_LIST Marker\r
+ OUT CHAR8 *StartOfBuffer,\r
+ IN UINTN BufferSize,\r
+ IN CONST CHAR8 *FormatString,\r
+ IN VA_LIST Marker\r
)\r
{\r
- CHAR8 *TempFormatBuffer;\r
- UINTN LenStrProduced;\r
+ CHAR8 *TempFormatBuffer;\r
+ UINTN LenStrProduced;\r
\r
//\r
// Looking for "%s" in the format string and replace it\r
if (TempFormatBuffer == NULL) {\r
return 0;\r
}\r
+\r
LenStrProduced = AsciiVSPrint (StartOfBuffer, BufferSize, (CONST CHAR8 *)TempFormatBuffer, Marker);\r
FreePool (TempFormatBuffer);\r
return LenStrProduced;\r
...\r
)\r
{\r
- VA_LIST Marker;\r
- UINTN LenStrProduced;\r
+ VA_LIST Marker;\r
+ UINTN LenStrProduced;\r
\r
- VA_START(Marker, FormatString);\r
+ VA_START (Marker, FormatString);\r
LenStrProduced = RedfishAsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
return LenStrProduced;\r
}\r
-\r