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