]> git.proxmox.com Git - mirror_edk2.git/blame - CryptoPkg/Include/OpenSslSupport.h
NetworkPkg: remove redundant words in function comment.
[mirror_edk2.git] / CryptoPkg / Include / OpenSslSupport.h
CommitLineData
97f98500
HT
1/** @file\r
2 Root include file to support building OpenSSL Crypto Library.\r
3\r
1463ce18 4Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
97f98500
HT
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef __OPEN_SSL_SUPPORT_H__\r
16#define __OPEN_SSL_SUPPORT_H__\r
17\r
18#include <Base.h>\r
19#include <Library/BaseLib.h>\r
20#include <Library/BaseMemoryLib.h>\r
21#include <Library/MemoryAllocationLib.h>\r
22#include <Library/DebugLib.h>\r
23\r
24//\r
25// File operations are not required for building Open SSL, \r
26// so FILE is mapped to VOID * to pass build\r
27//\r
28typedef VOID *FILE;\r
29\r
30//\r
31// Map all va_xxxx elements to VA_xxx defined in MdePkg/Include/Base.h\r
32//\r
8e01b449 33#if !defined(__CC_ARM) // if va_list is not already defined\r
97f98500
HT
34#define va_list VA_LIST\r
35#define va_arg VA_ARG\r
36#define va_start VA_START\r
37#define va_end VA_END\r
8e01b449 38#else // __CC_ARM\r
39#define va_start(Marker, Parameter) __va_start(Marker, Parameter)\r
40#define va_arg(Marker, TYPE) __va_arg(Marker, TYPE)\r
41#define va_end(Marker) ((void)0)\r
42#endif\r
43\r
97f98500
HT
44//\r
45// #defines from EFI Application Toolkit required to buiild Open SSL\r
46//\r
47#define ENOMEM 12 /* Cannot allocate memory */\r
48#define EINVAL 22 /* Invalid argument */\r
49#define BUFSIZ 1024 /* size of buffer used by setbuf */\r
50#define INT_MAX 2147483647 /* max value for an int */\r
51#define INT_MIN (-2147483647-1) /* min value for an int */\r
52#define LONG_MAX 2147483647L /* max value for a long */\r
53#define LONG_MIN (-2147483647-1) /* min value for a long */\r
54#define ULONG_MAX 0xffffffff /* max value for an unsigned long */\r
55#define LOG_DAEMON (3<<3) /* system daemons */\r
56#define LOG_EMERG 0 /* system is unusable */\r
57#define LOG_ALERT 1 /* action must be taken immediately */\r
58#define LOG_CRIT 2 /* critical conditions */\r
59#define LOG_ERR 3 /* error conditions */\r
60#define LOG_WARNING 4 /* warning conditions */\r
61#define LOG_NOTICE 5 /* normal but significant condition */\r
62#define LOG_INFO 6 /* informational */\r
63#define LOG_DEBUG 7 /* debug-level messages */\r
64#define LOG_PID 0x01 /* log the pid with each message */\r
65#define LOG_CONS 0x02 /* log on the console if errors in sending */\r
66\r
67//\r
68// Macros from EFI Application Toolkit required to buiild Open SSL\r
69//\r
70/* The offsetof() macro calculates the offset of a structure member\r
71 in its structure. Unfortunately this cannot be written down\r
72 portably, hence it is provided by a Standard C header file.\r
73 For pre-Standard C compilers, here is a version that usually works\r
74 (but watch out!): */\r
afc18ead 75#define offsetof(type, member) OFFSET_OF (type, member)\r
97f98500
HT
76\r
77//\r
78// Basic types from EFI Application Toolkit required to buiild Open SSL\r
79//\r
80typedef UINTN size_t;\r
81typedef INTN ssize_t;\r
82typedef INT64 off_t;\r
83typedef UINT16 mode_t;\r
84typedef long time_t;\r
85typedef unsigned long clock_t;\r
86typedef UINT32 uid_t;\r
87typedef UINT32 gid_t;\r
88typedef UINT32 ino_t;\r
89typedef UINT32 dev_t;\r
90typedef UINT16 nlink_t;\r
91typedef int pid_t;\r
92typedef void *DIR;\r
93typedef void __sighandler_t (int);\r
94\r
95//\r
96// Structures from EFI Application Toolkit required to buiild Open SSL\r
97//\r
98struct tm {\r
99 int tm_sec; /* seconds after the minute [0-60] */\r
100 int tm_min; /* minutes after the hour [0-59] */\r
101 int tm_hour; /* hours since midnight [0-23] */\r
102 int tm_mday; /* day of the month [1-31] */\r
103 int tm_mon; /* months since January [0-11] */\r
104 int tm_year; /* years since 1900 */\r
105 int tm_wday; /* days since Sunday [0-6] */\r
106 int tm_yday; /* days since January 1 [0-365] */\r
107 int tm_isdst; /* Daylight Savings Time flag */\r
108 long tm_gmtoff; /* offset from CUT in seconds */\r
109 char *tm_zone; /* timezone abbreviation */\r
110};\r
111\r
1463ce18
QL
112struct timeval {\r
113 long tv_sec; /* time value, in seconds */\r
114 long tv_usec; /* time value, in microseconds */\r
115} timeval;\r
116\r
97f98500
HT
117struct dirent {\r
118 UINT32 d_fileno; /* file number of entry */\r
119 UINT16 d_reclen; /* length of this record */\r
120 UINT8 d_type; /* file type, see below */\r
121 UINT8 d_namlen; /* length of string in d_name */\r
122 char d_name[255 + 1]; /* name must be no longer than this */\r
123};\r
124\r
125struct stat {\r
126 dev_t st_dev; /* inode's device */\r
127 ino_t st_ino; /* inode's number */\r
128 mode_t st_mode; /* inode protection mode */\r
129 nlink_t st_nlink; /* number of hard links */\r
130 uid_t st_uid; /* user ID of the file's owner */\r
131 gid_t st_gid; /* group ID of the file's group */\r
132 dev_t st_rdev; /* device type */\r
133 time_t st_atime; /* time of last access */\r
134 long st_atimensec; /* nsec of last access */\r
135 time_t st_mtime; /* time of last data modification */\r
136 long st_mtimensec; /* nsec of last data modification */\r
137 time_t st_ctime; /* time of last file status change */\r
138 long st_ctimensec; /* nsec of last file status change */\r
139 off_t st_size; /* file size, in bytes */\r
140 INT64 st_blocks; /* blocks allocated for file */\r
141 UINT32 st_blksize; /* optimal blocksize for I/O */\r
142 UINT32 st_flags; /* user defined flags for file */\r
143 UINT32 st_gen; /* file generation number */\r
144 INT32 st_lspare;\r
145 INT64 st_qspare[2];\r
146};\r
147\r
148//\r
149// Externs from EFI Application Toolkit required to buiild Open SSL\r
150//\r
151extern int errno;\r
152\r
153//\r
154// Function prototypes from EFI Application Toolkit required to buiild Open SSL\r
155//\r
156void *malloc (size_t);\r
157void *realloc (void *, size_t);\r
158void free (void *);\r
159int isdigit (int);\r
160int isspace (int);\r
161int tolower (int);\r
162int isupper (int);\r
163int isxdigit (int);\r
164int isalnum (int);\r
165void *memcpy (void *, const void *, size_t);\r
166void *memset (void *, int, size_t);\r
167void *memchr (const void *, int, size_t);\r
168int memcmp (const void *, const void *, size_t);\r
169void *memmove (void *, const void *, size_t);\r
170int strcmp (const char *, const char *);\r
171int strncmp (const char *, const char *, size_t);\r
172char *strcpy (char *, const char *);\r
173char *strncpy (char *, const char *, size_t);\r
174size_t strlen (const char *);\r
175char *strcat (char *, const char *);\r
176char *strchr (const char *, int);\r
177int strcasecmp (const char *, const char *);\r
178int strncasecmp (const char *, const char *, size_t);\r
179char *strncpy (char *, const char *, size_t);\r
180int strncmp (const char *, const char *, size_t);\r
181char *strrchr (const char *, int);\r
182unsigned long strtoul (const char *, char **, int);\r
183long strtol (const char *, char **, int);\r
184int printf (const char *, ...);\r
185int sscanf (const char *, const char *, ...);\r
186int open (const char *, int, ...);\r
187int chmod (const char *, mode_t);\r
188int stat (const char *, struct stat *);\r
189off_t lseek (int, off_t, int);\r
190ssize_t read (int, void *, size_t);\r
191ssize_t write (int, const void *, size_t);\r
192int close (int);\r
193FILE *fopen (const char *, const char *);\r
194size_t fread (void *, size_t, size_t, FILE *);\r
195size_t fwrite (const void *, size_t, size_t, FILE *);\r
196char *fgets (char *, int, FILE *);\r
197int fputs (const char *, FILE *);\r
198int fprintf (FILE *, const char *, ...);\r
199int vfprintf (FILE *, const char *, VA_LIST);\r
200int fflush (FILE *);\r
201int fclose (FILE *);\r
202DIR *opendir (const char *);\r
203struct dirent *readdir (DIR *);\r
204int closedir (DIR *);\r
205void openlog (const char *, int, int);\r
206void closelog (void);\r
207void syslog (int, const char *, ...);\r
208time_t time (time_t *);\r
209struct tm *localtime (const time_t *);\r
210struct tm *gmtime (const time_t *);\r
211struct tm *gmtime_r (const time_t *, struct tm *);\r
212uid_t getuid (void);\r
213uid_t geteuid (void);\r
214gid_t getgid (void);\r
215gid_t getegid (void);\r
216void qsort (void *, size_t, size_t, int (*)(const void *, const void *));\r
217char *getenv (const char *);\r
218void exit (int);\r
219void abort (void);\r
220__sighandler_t *signal (int, __sighandler_t *);\r
221\r
222//\r
223// Global variables from EFI Application Toolkit required to buiild Open SSL\r
224//\r
c61fb9c8 225extern FILE *stderr;\r
226extern FILE *stdin;\r
227extern FILE *stdout;\r
97f98500
HT
228\r
229//\r
230// Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions\r
231//\r
232#define memcpy(dest,source,count) CopyMem(dest,source,(UINTN)(count))\r
233#define memset(dest,ch,count) SetMem(dest,(UINTN)(count),(UINT8)(ch))\r
234#define memchr(buf,ch,count) ScanMem8(buf,(UINTN)(count),(UINT8)ch)\r
235#define memcmp(buf1,buf2,count) (int)(CompareMem(buf1,buf2,(UINTN)(count)))\r
4a567c96 236#define memmove(dest,source,count) CopyMem(dest,source,(UINTN)(count))\r
97f98500
HT
237#define strcmp AsciiStrCmp\r
238#define strncmp(string1,string2,count) (int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))\r
239#define strcpy(strDest,strSource) AsciiStrCpy(strDest,strSource)\r
240#define strncpy(strDest,strSource,count) AsciiStrnCpy(strDest,strSource,(UINTN)count)\r
241#define strlen(str) (size_t)(AsciiStrLen(str))\r
242#define strcat(strDest,strSource) AsciiStrCat(strDest,strSource)\r
243#define strchr(str,ch) ScanMem8((VOID *)(str),AsciiStrSize(str),(UINT8)ch)\r
244#define abort() ASSERT (FALSE)\r
245#define assert(expression)\r
246#define localtime(timer) NULL\r
97f98500 247#define gmtime_r(timer,result) (result = NULL)\r
1463ce18 248#define atoi(nptr) AsciiStrDecimalToUintn(nptr)\r
97f98500
HT
249\r
250#endif\r