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