]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Common/MemoryFile.h
9148d9d06c08b0d2d5a3bf5e1cd11bbd0096e70c
[mirror_edk2.git] / BaseTools / Source / C / Common / MemoryFile.h
1 /** @file
2
3 Copyright (c) 2004 - 2008, Intel Corporation
4 All rights reserved. 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 #ifndef _MAX_PATH
30 #define _MAX_PATH 500
31 #endif
32
33 //
34 // Common data structures
35 //
36 typedef struct {
37 CHAR8 *FileImage;
38 CHAR8 *Eof;
39 CHAR8 *CurrentFilePointer;
40 } MEMORY_FILE;
41
42
43 //
44 // Functions declarations
45 //
46
47 EFI_STATUS
48 GetMemoryFile (
49 IN CHAR8 *InputFileName,
50 OUT EFI_HANDLE *OutputMemoryFile
51 )
52 ;
53 /**
54
55 Routine Description:
56
57 This opens a file, reads it into memory and returns a memory file
58 object.
59
60 Arguments:
61
62 InputFile Memory file image.
63 OutputMemoryFile Handle to memory file
64
65 Returns:
66
67 EFI_STATUS
68 OutputMemoryFile is valid if !EFI_ERROR
69
70 **/
71
72
73 EFI_STATUS
74 FreeMemoryFile (
75 IN EFI_HANDLE InputMemoryFile
76 )
77 ;
78 /**
79
80 Routine Description:
81
82 Frees all memory associated with the input memory file.
83
84 Arguments:
85
86 InputMemoryFile Handle to memory file
87
88 Returns:
89
90 EFI_STATUS
91
92 **/
93
94
95 CHAR8 *
96 ReadMemoryFileLine (
97 IN EFI_HANDLE InputMemoryFile
98 )
99 ;
100 /**
101
102 Routine Description:
103
104 This function reads a line from the memory file. The newline characters
105 are stripped and a null terminated string is returned.
106
107 If the string pointer returned is non-NULL, then the caller must free the
108 memory associated with this string.
109
110 Arguments:
111
112 InputMemoryFile Handle to memory file
113
114 Returns:
115
116 NULL if error or EOF
117 NULL character termincated string otherwise (MUST BE FREED BY CALLER)
118
119 **/
120
121
122 #endif