]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Common/MemoryFile.h
0568fed5f2e4e95cc52934ad997fc41ef6db09e1
[mirror_edk2.git] / BaseTools / Source / C / Common / MemoryFile.h
1 /** @file
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 MemoryFile.h
15
16 Abstract:
17
18 Header file for helper functions useful for accessing files.
19
20 **/
21
22 #ifndef _EFI_MEMORY_FILE_H
23 #define _EFI_MEMORY_FILE_H
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <Common/UefiBaseTypes.h>
28
29 //
30 // Common data structures
31 //
32 typedef struct {
33 CHAR8 *FileImage;
34 CHAR8 *Eof;
35 CHAR8 *CurrentFilePointer;
36 } MEMORY_FILE;
37
38
39 //
40 // Functions declarations
41 //
42
43 EFI_STATUS
44 GetMemoryFile (
45 IN CHAR8 *InputFileName,
46 OUT EFI_HANDLE *OutputMemoryFile
47 )
48 ;
49 /**
50
51 Routine Description:
52
53 This opens a file, reads it into memory and returns a memory file
54 object.
55
56 Arguments:
57
58 InputFile Memory file image.
59 OutputMemoryFile Handle to memory file
60
61 Returns:
62
63 EFI_STATUS
64 OutputMemoryFile is valid if !EFI_ERROR
65
66 **/
67
68
69 EFI_STATUS
70 FreeMemoryFile (
71 IN EFI_HANDLE InputMemoryFile
72 )
73 ;
74 /**
75
76 Routine Description:
77
78 Frees all memory associated with the input memory file.
79
80 Arguments:
81
82 InputMemoryFile Handle to memory file
83
84 Returns:
85
86 EFI_STATUS
87
88 **/
89
90
91 CHAR8 *
92 ReadMemoryFileLine (
93 IN EFI_HANDLE InputMemoryFile
94 )
95 ;
96 /**
97
98 Routine Description:
99
100 This function reads a line from the memory file. The newline characters
101 are stripped and a null terminated string is returned.
102
103 If the string pointer returned is non-NULL, then the caller must free the
104 memory associated with this string.
105
106 Arguments:
107
108 InputMemoryFile Handle to memory file
109
110 Returns:
111
112 NULL if error or EOF
113 NULL character termincated string otherwise (MUST BE FREED BY CALLER)
114
115 **/
116
117
118 #endif