MemoryFile.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /** @file
  2. Header file for helper functions useful for accessing files.
  3. Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _EFI_MEMORY_FILE_H
  7. #define _EFI_MEMORY_FILE_H
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <Common/UefiBaseTypes.h>
  11. //
  12. // Common data structures
  13. //
  14. typedef struct {
  15. CHAR8 *FileImage;
  16. CHAR8 *Eof;
  17. CHAR8 *CurrentFilePointer;
  18. } MEMORY_FILE;
  19. //
  20. // Functions declarations
  21. //
  22. EFI_STATUS
  23. GetMemoryFile (
  24. IN CHAR8 *InputFileName,
  25. OUT EFI_HANDLE *OutputMemoryFile
  26. )
  27. ;
  28. /**
  29. Routine Description:
  30. This opens a file, reads it into memory and returns a memory file
  31. object.
  32. Arguments:
  33. InputFile Memory file image.
  34. OutputMemoryFile Handle to memory file
  35. Returns:
  36. EFI_STATUS
  37. OutputMemoryFile is valid if !EFI_ERROR
  38. **/
  39. EFI_STATUS
  40. FreeMemoryFile (
  41. IN EFI_HANDLE InputMemoryFile
  42. )
  43. ;
  44. /**
  45. Routine Description:
  46. Frees all memory associated with the input memory file.
  47. Arguments:
  48. InputMemoryFile Handle to memory file
  49. Returns:
  50. EFI_STATUS
  51. **/
  52. CHAR8 *
  53. ReadMemoryFileLine (
  54. IN EFI_HANDLE InputMemoryFile
  55. )
  56. ;
  57. /**
  58. Routine Description:
  59. This function reads a line from the memory file. The newline characters
  60. are stripped and a null terminated string is returned.
  61. If the string pointer returned is non-NULL, then the caller must free the
  62. memory associated with this string.
  63. Arguments:
  64. InputMemoryFile Handle to memory file
  65. Returns:
  66. NULL if error or EOF
  67. NULL character termincated string otherwise (MUST BE FREED BY CALLER)
  68. **/
  69. #endif