]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Common/CommonLib.h
fa10fac4682a902ccc32e22673403d26335f0c5f
2 Common library assistance routines.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _EFI_COMMON_LIB_H
16 #define _EFI_COMMON_LIB_H
18 #include <Common/UefiBaseTypes.h>
19 #include <Common/BuildVersion.h>
21 #define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination
23 #define MAX_LONG_FILE_PATH 500
25 #define MAX_UINTN MAX_ADDRESS
26 #define MAX_UINT64 ((UINT64)0xFFFFFFFFFFFFFFFFULL)
27 #define MAX_UINT16 ((UINT16)0xFFFF)
28 #define MAX_UINT8 ((UINT8)0xFF)
29 #define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0]))
30 #define ASCII_RSIZE_MAX 1000000
32 #define RSIZE_MAX 1000000
34 #define IS_COMMA(a) ((a) == L',')
35 #define IS_HYPHEN(a) ((a) == L'-')
36 #define IS_DOT(a) ((a) == L'.')
37 #define IS_LEFT_PARENTH(a) ((a) == L'(')
38 #define IS_RIGHT_PARENTH(a) ((a) == L')')
39 #define IS_SLASH(a) ((a) == L'/')
40 #define IS_NULL(a) ((a) == L'\0')
42 #define ASSERT(x) assert(x)
49 // Function declarations
90 IN CHAR8
*InputFileName
,
91 OUT CHAR8
**InputFileImage
,
98 IN CHAR8
*OutputFileName
,
99 IN CHAR8
*OutputFileImage
,
100 IN UINT32 BytesToWrite
107 This function opens a file and writes OutputFileImage into the file.
111 OutputFileName The name of the file to write.
112 OutputFileImage A pointer to the memory buffer.
113 BytesToWrite The size of the memory buffer.
117 EFI_SUCCESS The function completed successfully.
118 EFI_INVALID_PARAMETER One of the input parameters was invalid.
119 EFI_ABORTED An error occurred.
120 EFI_OUT_OF_RESOURCES No resource to complete operations.
139 CalculateChecksum16 (
158 #define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination
162 IN OUT UINT8
*Buffer
,
180 UINTN AllocationSize
,
186 CONST CHAR16
*FirstString
,
187 CONST CHAR16
*SecondString
,
193 CONST CHAR16
*String
,
199 CONST CHAR16
*String
,
206 InternalHexCharToUintn (
211 InternalAllocateCopyPool (
212 UINTN AllocationSize
,
217 InternalIsDecimalDigitCharacter (
233 EFI_GUID
*DestinationGuid
,
234 CONST EFI_GUID
*SourceGuid
275 CONST CHAR16
*String
,
282 CONST CHAR16
*String
,
283 CHAR16
**EndPointer
, OPTIONAL
288 StrDecimalToUint64S (
289 CONST CHAR16
*String
,
290 CHAR16
**EndPointer
, OPTIONAL
296 CONST CHAR16
*String
,
297 CHAR16
**EndPointer
, OPTIONAL
305 VOID
*OldBuffer OPTIONAL
309 InternalReallocatePool (
312 VOID
*OldBuffer OPTIONAL
316 InternalAllocateZeroPool (
321 InternalAllocatePool (
327 CONST CHAR16
*String
,
332 InternalCharToUpper (
338 CONST CHAR16
*FirstString
,
339 CONST CHAR16
*SecondString
348 InternalMathSwapBytes64 (
354 CONST CHAR16
*String
,
356 EFI_IPv4_ADDRESS
*Address
,
362 CONST CHAR16
*String
,
364 EFI_IPv6_ADDRESS
*Address
,
376 UnicodeStrToAsciiStrS (
377 CONST CHAR16
*Source
,
403 InternalIsHexaDecimalDigitCharacter (
408 InternalSafeStringIsOverlap (
416 InternalSafeStringNoStrOverlap (
454 Convert FileName to the long file path, which can support larger than 260 length.
460 LongFilePath A pointer to the converted long file path.
470 #include <sys/stat.h>
471 #define stricmp strcasecmp
472 #define _stricmp strcasecmp
473 #define strnicmp strncasecmp
474 #define strcmpi strcasecmp
475 size_t _filelength(int fd
);
477 char *strlwr(char *s
);
482 // On windows, mkdir only has one parameter.
483 // On unix, it has two parameters
485 #if defined(__GNUC__)
486 #define mkdir(dir, perm) mkdir(dir, perm)
488 #define mkdir(dir, perm) mkdir(dir)