]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Common/CommonLib.h
2 Common library assistance routines.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef _EFI_COMMON_LIB_H
10 #define _EFI_COMMON_LIB_H
12 #include <Common/UefiBaseTypes.h>
13 #include <Common/BuildVersion.h>
15 #define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination
17 #define MAX_LONG_FILE_PATH 500
19 #define MAX_UINT64 ((UINT64)0xFFFFFFFFFFFFFFFFULL)
20 #define MAX_UINT32 ((UINT32)0xFFFFFFFF)
21 #define MAX_UINT16 ((UINT16)0xFFFF)
22 #define MAX_UINT8 ((UINT8)0xFF)
23 #define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0]))
24 #define ASCII_RSIZE_MAX 1000000
26 #define RSIZE_MAX 1000000
28 #define IS_COMMA(a) ((a) == L',')
29 #define IS_HYPHEN(a) ((a) == L'-')
30 #define IS_DOT(a) ((a) == L'.')
31 #define IS_LEFT_PARENTH(a) ((a) == L'(')
32 #define IS_RIGHT_PARENTH(a) ((a) == L')')
33 #define IS_SLASH(a) ((a) == L'/')
34 #define IS_NULL(a) ((a) == L'\0')
36 #define ASSERT(x) assert(x)
43 // Function declarations
84 IN CHAR8
*InputFileName
,
85 OUT CHAR8
**InputFileImage
,
92 IN CHAR8
*OutputFileName
,
93 IN CHAR8
*OutputFileImage
,
94 IN UINT32 BytesToWrite
101 This function opens a file and writes OutputFileImage into the file.
105 OutputFileName The name of the file to write.
106 OutputFileImage A pointer to the memory buffer.
107 BytesToWrite The size of the memory buffer.
111 EFI_SUCCESS The function completed successfully.
112 EFI_INVALID_PARAMETER One of the input parameters was invalid.
113 EFI_ABORTED An error occurred.
114 EFI_OUT_OF_RESOURCES No resource to complete operations.
133 CalculateChecksum16 (
152 #define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination
156 IN OUT UINT8
*Buffer
,
174 UINTN AllocationSize
,
180 CONST CHAR16
*FirstString
,
181 CONST CHAR16
*SecondString
,
187 CONST CHAR16
*String
,
193 CONST CHAR16
*String
,
200 InternalHexCharToUintn (
205 InternalAllocateCopyPool (
206 UINTN AllocationSize
,
211 InternalIsDecimalDigitCharacter (
227 EFI_GUID
*DestinationGuid
,
228 CONST EFI_GUID
*SourceGuid
259 CONST CHAR16
*String
,
265 StrDecimalToUint64S (
266 CONST CHAR16
*String
,
267 CHAR16
**EndPointer
, OPTIONAL
275 VOID
*OldBuffer OPTIONAL
279 InternalReallocatePool (
282 VOID
*OldBuffer OPTIONAL
286 InternalAllocateZeroPool (
291 InternalAllocatePool (
297 CONST CHAR16
*String
,
302 InternalCharToUpper (
308 CONST CHAR16
*FirstString
,
309 CONST CHAR16
*SecondString
318 InternalMathSwapBytes64 (
324 CONST CHAR16
*String
,
326 EFI_IPv4_ADDRESS
*Address
,
332 CONST CHAR16
*String
,
334 EFI_IPv6_ADDRESS
*Address
,
346 UnicodeStrToAsciiStrS (
347 CONST CHAR16
*Source
,
373 InternalIsHexaDecimalDigitCharacter (
378 InternalSafeStringIsOverlap (
386 InternalSafeStringNoStrOverlap (
424 Convert FileName to the long file path, which can support larger than 260 length.
430 LongFilePath A pointer to the converted long file path.
440 #include <sys/stat.h>
441 #define stricmp strcasecmp
442 #define _stricmp strcasecmp
443 #define strnicmp strncasecmp
444 #define strcmpi strcasecmp
445 size_t _filelength(int fd
);
447 char *strlwr(char *s
);
452 // On windows, mkdir only has one parameter.
453 // On unix, it has two parameters
455 #if defined(__GNUC__)
456 #define mkdir(dir, perm) mkdir(dir, perm)
458 #define mkdir(dir, perm) mkdir(dir)