mirror of
https://git.proxmox.com/git/efi-boot-shim
synced 2025-06-11 21:48:58 +00:00
Cryptlib: implement strcmp() and strcasecmp()
strcmp() and strcasecmp() are widely used in openssl. Implement those two functions to eliminate the gcc warnings and the potential crash. Signed-off-by: Gary Lin <glin@suse.com>
This commit is contained in:
parent
ae75df6232
commit
9bc647e2b2
@ -374,7 +374,6 @@ extern FILE *stdout;
|
||||
#define strncpy(strDest,strSource,count) AsciiStrnCpy(strDest,strSource,(UINTN)count)
|
||||
#define strcat(strDest,strSource) AsciiStrCat(strDest,strSource)
|
||||
#define strchr(str,ch) (char *)(ScanMem8((CHAR8 *)str,AsciiStrSize((CHAR8 *)str),ch))
|
||||
#define strcmp(string1,string2) strcmpa((CHAR8 *)string1,(CHAR8 *)string2)
|
||||
#define strncmp(string1,string2,count) (int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))
|
||||
#define localtime(timer) NULL
|
||||
#define assert(expression)
|
||||
|
@ -93,3 +93,33 @@ AsciiStrDecimalToUintn(const char *String)
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
int
|
||||
strcmp (const char *str1, const char *str2)
|
||||
{
|
||||
return strcmpa((CHAR8 *)str1,(CHAR8 *)str2);
|
||||
}
|
||||
|
||||
inline static char
|
||||
toupper (char c)
|
||||
{
|
||||
return ((c >= 'a' && c <= 'z') ? c - ('a' - 'A') : c);
|
||||
}
|
||||
|
||||
/* Based on AsciiStriCmp() in edk2 MdePkg/Library/BaseLib/String.c */
|
||||
int
|
||||
strcasecmp (const char *str1, const char *str2)
|
||||
{
|
||||
char c1, c2;
|
||||
|
||||
c1 = toupper (*str1);
|
||||
c2 = toupper (*str2);
|
||||
while ((*str1 != '\0') && (c1 == c2)) {
|
||||
str1++;
|
||||
str2++;
|
||||
c1 = toupper (*str1);
|
||||
c2 = toupper (*str2);
|
||||
}
|
||||
|
||||
return c1 - c2;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user