1 /** @file 2 INI configuration parsing library. 3 4 The INI file format is: 5 ================ 6 [SectionName] 7 EntryName=EntryValue 8 ================ 9 10 Where: 11 1) SectionName is an ASCII string. The valid format is [A-Za-z0-9_]+ 12 2) EntryName is an ASCII string. The valid format is [A-Za-z0-9_]+ 13 3) EntryValue can be: 14 3.1) an ASCII String. The valid format is [A-Za-z0-9_]+ 15 3.2) a GUID. The valid format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, where x is [A-Fa-f0-9] 16 3.3) a decimal value. The valid format is [0-9]+ 17 3.4) a heximal value. The valid format is 0x[A-Fa-f0-9]+ 18 4) '#' or ';' can be used as comment at anywhere. 19 5) TAB(0x20) or SPACE(0x9) can be used as separator. 20 6) LF(\n, 0xA) or CR(\r, 0xD) can be used as line break. 21 22 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> 23 This program and the accompanying materials 24 are licensed and made available under the terms and conditions of the BSD License 25 which accompanies this distribution. The full text of the license may be found at 26 http://opensource.org/licenses/bsd-license.php 27 28 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 29 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 30 31 **/ 32 33 34 #ifndef __INI_PARSING_LIB_H__ 35 #define __INI_PARSING_LIB_H__ 36 37 /** 38 Open an INI config file and return a context. 39 40 @param[in] DataBuffer Config raw file buffer. 41 @param[in] BufferSize Size of raw buffer. 42 43 @return Config data buffer is opened and context is returned. 44 @retval NULL No enough memory is allocated. 45 @retval NULL Config data buffer is invalid. 46 **/ 47 VOID * 48 EFIAPI 49 OpenIniFile ( 50 IN UINT8 *DataBuffer, 51 IN UINTN BufferSize 52 ); 53 54 /** 55 Get section entry string value. 56 57 @param[in] Context INI Config file context. 58 @param[in] SectionName Section name. 59 @param[in] EntryName Section entry name. 60 @param[out] EntryValue Point to the got entry string value. 61 62 @retval EFI_SUCCESS Section entry string value is got. 63 @retval EFI_NOT_FOUND Section is not found. 64 **/ 65 EFI_STATUS 66 EFIAPI 67 GetStringFromDataFile ( 68 IN VOID *Context, 69 IN CHAR8 *SectionName, 70 IN CHAR8 *EntryName, 71 OUT CHAR8 **EntryValue 72 ); 73 74 /** 75 Get section entry GUID value. 76 77 @param[in] Context INI Config file context. 78 @param[in] SectionName Section name. 79 @param[in] EntryName Section entry name. 80 @param[out] Guid Point to the got GUID value. 81 82 @retval EFI_SUCCESS Section entry GUID value is got. 83 @retval EFI_NOT_FOUND Section is not found. 84 **/ 85 EFI_STATUS 86 EFIAPI 87 GetGuidFromDataFile ( 88 IN VOID *Context, 89 IN CHAR8 *SectionName, 90 IN CHAR8 *EntryName, 91 OUT EFI_GUID *Guid 92 ); 93 94 /** 95 Get section entry decimal UINTN value. 96 97 @param[in] Context INI Config file context. 98 @param[in] SectionName Section name. 99 @param[in] EntryName Section entry name. 100 @param[out] Data Point to the got decimal UINTN value. 101 102 @retval EFI_SUCCESS Section entry decimal UINTN value is got. 103 @retval EFI_NOT_FOUND Section is not found. 104 **/ 105 EFI_STATUS 106 EFIAPI 107 GetDecimalUintnFromDataFile ( 108 IN VOID *Context, 109 IN CHAR8 *SectionName, 110 IN CHAR8 *EntryName, 111 OUT UINTN *Data 112 ); 113 114 /** 115 Get section entry heximal UINTN value. 116 117 @param[in] Context INI Config file context. 118 @param[in] SectionName Section name. 119 @param[in] EntryName Section entry name. 120 @param[out] Data Point to the got heximal UINTN value. 121 122 @retval EFI_SUCCESS Section entry heximal UINTN value is got. 123 @retval EFI_NOT_FOUND Section is not found. 124 **/ 125 EFI_STATUS 126 EFIAPI 127 GetHexUintnFromDataFile ( 128 IN VOID *Context, 129 IN CHAR8 *SectionName, 130 IN CHAR8 *EntryName, 131 OUT UINTN *Data 132 ); 133 134 /** 135 Get section entry heximal UINT64 value. 136 137 @param[in] Context INI Config file context. 138 @param[in] SectionName Section name. 139 @param[in] EntryName Section entry name. 140 @param[out] Data Point to the got heximal UINT64 value. 141 142 @retval EFI_SUCCESS Section entry heximal UINT64 value is got. 143 @retval EFI_NOT_FOUND Section is not found. 144 **/ 145 EFI_STATUS 146 EFIAPI 147 GetHexUint64FromDataFile ( 148 IN VOID *Context, 149 IN CHAR8 *SectionName, 150 IN CHAR8 *EntryName, 151 OUT UINT64 *Data 152 ); 153 154 /** 155 Close an INI config file and free the context. 156 157 @param[in] Context INI Config file context. 158 **/ 159 VOID 160 EFIAPI 161 CloseIniFile ( 162 IN VOID *Context 163 ); 164 165 #endif 166 167