]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Common/MemoryFile.h
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / C / Common / MemoryFile.h
1 /** @file
2 Header file for helper functions useful for accessing files.
3
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef _EFI_MEMORY_FILE_H
10 #define _EFI_MEMORY_FILE_H
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <Common/UefiBaseTypes.h>
15
16 //
17 // Common data structures
18 //
19 typedef struct {
20 CHAR8 *FileImage;
21 CHAR8 *Eof;
22 CHAR8 *CurrentFilePointer;
23 } MEMORY_FILE;
24
25
26 //
27 // Functions declarations
28 //
29
30 EFI_STATUS
31 GetMemoryFile (
32 IN CHAR8 *InputFileName,
33 OUT EFI_HANDLE *OutputMemoryFile
34 )
35 ;
36 /**
37
38 Routine Description:
39
40 This opens a file, reads it into memory and returns a memory file
41 object.
42
43 Arguments:
44
45 InputFile Memory file image.
46 OutputMemoryFile Handle to memory file
47
48 Returns:
49
50 EFI_STATUS
51 OutputMemoryFile is valid if !EFI_ERROR
52
53 **/
54
55
56 EFI_STATUS
57 FreeMemoryFile (
58 IN EFI_HANDLE InputMemoryFile
59 )
60 ;
61 /**
62
63 Routine Description:
64
65 Frees all memory associated with the input memory file.
66
67 Arguments:
68
69 InputMemoryFile Handle to memory file
70
71 Returns:
72
73 EFI_STATUS
74
75 **/
76
77
78 CHAR8 *
79 ReadMemoryFileLine (
80 IN EFI_HANDLE InputMemoryFile
81 )
82 ;
83 /**
84
85 Routine Description:
86
87 This function reads a line from the memory file. The newline characters
88 are stripped and a null terminated string is returned.
89
90 If the string pointer returned is non-NULL, then the caller must free the
91 memory associated with this string.
92
93 Arguments:
94
95 InputMemoryFile Handle to memory file
96
97 Returns:
98
99 NULL if error or EOF
100 NULL character termincated string otherwise (MUST BE FREED BY CALLER)
101
102 **/
103
104
105 #endif