]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/BaseCryptLib/SysCall/UnitTestHostCrtWrapper.c
CryptoPkg: BaseCryptLib: Add unit tests (Host and Shell based)
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / SysCall / UnitTestHostCrtWrapper.c
1 /** @file
2 C Run-Time Libraries (CRT) Wrapper Implementation for OpenSSL-based
3 Cryptographic Library.
4
5 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
6 Copyright (c) Microsoft Corporation
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #include <stdio.h>
12
13 #include <Base.h>
14 #include <Library/DebugLib.h>
15
16 /* Convert character to lowercase */
17 int tolower (int c)
18 {
19 if (('A' <= (c)) && ((c) <= 'Z')) {
20 return (c - ('A' - 'a'));
21 }
22 return (c);
23 }
24
25 /* Compare first n bytes of string s1 with string s2, ignoring case */
26 int strncasecmp (const char *s1, const char *s2, size_t n)
27 {
28 int Val;
29
30 ASSERT(s1 != NULL);
31 ASSERT(s2 != NULL);
32
33 if (n != 0) {
34 do {
35 Val = tolower(*s1) - tolower(*s2);
36 if (Val != 0) {
37 return Val;
38 }
39 ++s1;
40 ++s2;
41 if (*s1 == '\0') {
42 break;
43 }
44 } while (--n != 0);
45 }
46 return 0;
47 }
48
49 /* Read formatted data from a string */
50 int sscanf (const char *buffer, const char *format, ...)
51 {
52 //
53 // Null sscanf() function implementation to satisfy the linker, since
54 // no direct functionality logic dependency in present UEFI cases.
55 //
56 return 0;
57 }
58
59 //
60 // -- Dummy OpenSSL Support Routines --
61 //
62
63 int BIO_printf (void *bio, const char *format, ...)
64 {
65 return 0;
66 }
67
68 int BIO_snprintf(char *buf, size_t n, const char *format, ...)
69 {
70 return 0;
71 }
72
73 uid_t getuid (void)
74 {
75 return 0;
76 }
77
78 uid_t geteuid (void)
79 {
80 return 0;
81 }
82
83 gid_t getgid (void)
84 {
85 return 0;
86 }
87
88 gid_t getegid (void)
89 {
90 return 0;
91 }
92
93 int errno = 0;