IniParsingLib.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /** @file
  2. INI configuration parsing library.
  3. The INI file format is:
  4. ================
  5. [SectionName]
  6. EntryName=EntryValue
  7. ================
  8. Where:
  9. 1) SectionName is an ASCII string. The valid format is [A-Za-z0-9_]+
  10. 2) EntryName is an ASCII string. The valid format is [A-Za-z0-9_]+
  11. 3) EntryValue can be:
  12. 3.1) an ASCII String. The valid format is [A-Za-z0-9_]+
  13. 3.2) a GUID. The valid format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, where x is [A-Fa-f0-9]
  14. 3.3) a decimal value. The valid format is [0-9]+
  15. 3.4) a hexadecimal value. The valid format is 0x[A-Fa-f0-9]+
  16. 4) '#' or ';' can be used as comment at anywhere.
  17. 5) TAB(0x20) or SPACE(0x9) can be used as separator.
  18. 6) LF(\n, 0xA) or CR(\r, 0xD) can be used as line break.
  19. Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
  20. SPDX-License-Identifier: BSD-2-Clause-Patent
  21. **/
  22. #ifndef __INI_PARSING_LIB_H__
  23. #define __INI_PARSING_LIB_H__
  24. /**
  25. Open an INI config file and return a context.
  26. @param[in] DataBuffer Config raw file buffer.
  27. @param[in] BufferSize Size of raw buffer.
  28. @return Config data buffer is opened and context is returned.
  29. @retval NULL No enough memory is allocated.
  30. @retval NULL Config data buffer is invalid.
  31. **/
  32. VOID *
  33. EFIAPI
  34. OpenIniFile (
  35. IN UINT8 *DataBuffer,
  36. IN UINTN BufferSize
  37. );
  38. /**
  39. Get section entry string value.
  40. @param[in] Context INI Config file context.
  41. @param[in] SectionName Section name.
  42. @param[in] EntryName Section entry name.
  43. @param[out] EntryValue Point to the got entry string value.
  44. @retval EFI_SUCCESS Section entry string value is got.
  45. @retval EFI_NOT_FOUND Section is not found.
  46. **/
  47. EFI_STATUS
  48. EFIAPI
  49. GetStringFromDataFile (
  50. IN VOID *Context,
  51. IN CHAR8 *SectionName,
  52. IN CHAR8 *EntryName,
  53. OUT CHAR8 **EntryValue
  54. );
  55. /**
  56. Get section entry GUID value.
  57. @param[in] Context INI Config file context.
  58. @param[in] SectionName Section name.
  59. @param[in] EntryName Section entry name.
  60. @param[out] Guid Point to the got GUID value.
  61. @retval EFI_SUCCESS Section entry GUID value is got.
  62. @retval EFI_NOT_FOUND Section is not found.
  63. **/
  64. EFI_STATUS
  65. EFIAPI
  66. GetGuidFromDataFile (
  67. IN VOID *Context,
  68. IN CHAR8 *SectionName,
  69. IN CHAR8 *EntryName,
  70. OUT EFI_GUID *Guid
  71. );
  72. /**
  73. Get section entry decimal UINTN value.
  74. @param[in] Context INI Config file context.
  75. @param[in] SectionName Section name.
  76. @param[in] EntryName Section entry name.
  77. @param[out] Data Point to the got decimal UINTN value.
  78. @retval EFI_SUCCESS Section entry decimal UINTN value is got.
  79. @retval EFI_NOT_FOUND Section is not found.
  80. **/
  81. EFI_STATUS
  82. EFIAPI
  83. GetDecimalUintnFromDataFile (
  84. IN VOID *Context,
  85. IN CHAR8 *SectionName,
  86. IN CHAR8 *EntryName,
  87. OUT UINTN *Data
  88. );
  89. /**
  90. Get section entry hexadecimal UINTN value.
  91. @param[in] Context INI Config file context.
  92. @param[in] SectionName Section name.
  93. @param[in] EntryName Section entry name.
  94. @param[out] Data Point to the got hexadecimal UINTN value.
  95. @retval EFI_SUCCESS Section entry hexadecimal UINTN value is got.
  96. @retval EFI_NOT_FOUND Section is not found.
  97. **/
  98. EFI_STATUS
  99. EFIAPI
  100. GetHexUintnFromDataFile (
  101. IN VOID *Context,
  102. IN CHAR8 *SectionName,
  103. IN CHAR8 *EntryName,
  104. OUT UINTN *Data
  105. );
  106. /**
  107. Get section entry hexadecimal UINT64 value.
  108. @param[in] Context INI Config file context.
  109. @param[in] SectionName Section name.
  110. @param[in] EntryName Section entry name.
  111. @param[out] Data Point to the got hexadecimal UINT64 value.
  112. @retval EFI_SUCCESS Section entry hexadecimal UINT64 value is got.
  113. @retval EFI_NOT_FOUND Section is not found.
  114. **/
  115. EFI_STATUS
  116. EFIAPI
  117. GetHexUint64FromDataFile (
  118. IN VOID *Context,
  119. IN CHAR8 *SectionName,
  120. IN CHAR8 *EntryName,
  121. OUT UINT64 *Data
  122. );
  123. /**
  124. Close an INI config file and free the context.
  125. @param[in] Context INI Config file context.
  126. **/
  127. VOID
  128. EFIAPI
  129. CloseIniFile (
  130. IN VOID *Context
  131. );
  132. #endif