#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
+\r
+// This is required to keep VC++ happy if you use floating-point\r
+int _fltused = 1;\r
\r
/**\r
Determine if a particular character is an alphanumeric character\r
return (double)0;\r
}\r
\r
+static UINT8 BitMask[] = {\r
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80\r
+ };\r
+\r
+#define WHICH8(c) ((unsigned char)(c) >> 3)\r
+#define WHICH_BIT(c) (BitMask[((c) & 0x7)])\r
+#define BITMAP64 ((UINT64 *)bitmap)\r
+\r
+static\r
+void\r
+BuildBitmap(unsigned char * bitmap, const char *s2, int n)\r
+{\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
+ BITMAP64[index] = 0;\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
+ bitmap[index] = bitmap[index] | bit;\r
+ }\r
+}\r
+\r
+/** The strpbrk function locates the first occurrence in the string pointed to\r
+ by s1 of any character from the string pointed to by s2.\r
+\r
+ @return The strpbrk function returns a pointer to the character, or a\r
+ null pointer if no character from s2 occurs in s1.\r
+**/\r
+char *\r
+strpbrk(const char *s1, const char *s2)\r
+{\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
+\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
+ return NULL;\r
+}\r
+\r
+/** The strerror function maps the number in errnum to a message string.\r
+ Typically, the values for errnum come from errno, but strerror shall map\r
+ any value of type int to a message.\r
+\r
+ The implementation shall behave as if no library function calls the\r
+ strerror function.\r
+\r
+ @return The strerror function returns a pointer to the string, the\r
+ contents of which are locale specific. The array pointed to\r
+ shall not be modified by the program, but may be overwritten by\r
+ a subsequent call to the strerror function.\r
+**/\r
+char *\r
+strerror(int errnum)\r
+{\r
+ return errnum_message;\r
+}\r
+\r
/**\r
Allocate and zero-initialize array.\r
**/\r
\r
**/\r
int fgetc(FILE * _File){\r
- return 0;\r
+ return EOF;\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
+ return NULL;\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
+ return 0;\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
+ return 0;\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
+ return EOF;\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
+ return -1;\r
}\r
/**\r
This function check if this is the formating string specifier.\r