]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SignedCapsulePkg/Include: Add IniParsingLib header.
authorJiewen Yao <jiewen.yao@intel.com>
Wed, 21 Sep 2016 01:30:31 +0000 (09:30 +0800)
committerJiewen Yao <jiewen.yao@intel.com>
Tue, 8 Nov 2016 14:40:51 +0000 (22:40 +0800)
This library is used to parse the INI configuration file.
The INI configuration file is used in EDKII capsule image to describe
the capsule information.

Detail format is documented in header file.

Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
Tested-by: Michael Kinney <michael.d.kinney@intel.com>
SignedCapsulePkg/Include/Library/IniParsingLib.h [new file with mode: 0644]

diff --git a/SignedCapsulePkg/Include/Library/IniParsingLib.h b/SignedCapsulePkg/Include/Library/IniParsingLib.h
new file mode 100644 (file)
index 0000000..e964dd2
--- /dev/null
@@ -0,0 +1,166 @@
+/** @file\r
+  INI configuration parsing library.\r
+\r
+  The INI file format is:\r
+    ================\r
+    [SectionName]\r
+    EntryName=EntryValue\r
+    ================\r
+\r
+    Where:\r
+      1) SectionName is an ASCII string. The valid format is [A-Za-z0-9_]+\r
+      2) EntryName is an ASCII string. The valid format is [A-Za-z0-9_]+\r
+      3) EntryValue can be:\r
+         3.1) an ASCII String. The valid format is [A-Za-z0-9_]+\r
+         3.2) a GUID. The valid format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, where x is [A-Fa-f0-9]\r
+         3.3) a decimal value. The valid format is [0-9]+\r
+         3.4) a heximal value. The valid format is 0x[A-Fa-f0-9]+\r
+      4) '#' or ';' can be used as comment at anywhere.\r
+      5) TAB(0x20) or SPACE(0x9) can be used as separator.\r
+      6) LF(\n, 0xA) or CR(\r, 0xD) can be used as line break.\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#ifndef __INI_PARSING_LIB_H__\r
+#define __INI_PARSING_LIB_H__\r
+\r
+/**\r
+  Open an INI config file and return a context.\r
+\r
+  @param[in] DataBuffer      Config raw file buffer.\r
+  @param[in] BufferSize      Size of raw buffer.\r
+\r
+  @return       Config data buffer is opened and context is returned.\r
+  @retval NULL  No enough memory is allocated.\r
+  @retval NULL  Config data buffer is invalid.\r
+**/\r
+VOID *\r
+EFIAPI\r
+OpenIniFile (\r
+  IN      UINT8                         *DataBuffer,\r
+  IN      UINTN                         BufferSize\r
+  );\r
+\r
+/**\r
+  Get section entry string value.\r
+\r
+  @param[in]  Context         INI Config file context.\r
+  @param[in]  SectionName     Section name.\r
+  @param[in]  EntryName       Section entry name.\r
+  @param[out] EntryValue      Point to the got entry string value.\r
+\r
+  @retval EFI_SUCCESS    Section entry string value is got.\r
+  @retval EFI_NOT_FOUND  Section is not found.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetStringFromDataFile (\r
+  IN      VOID                          *Context,\r
+  IN      CHAR8                         *SectionName,\r
+  IN      CHAR8                         *EntryName,\r
+  OUT     CHAR8                         **EntryValue\r
+  );\r
+\r
+/**\r
+  Get section entry GUID value.\r
+\r
+  @param[in]  Context         INI Config file context.\r
+  @param[in]  SectionName     Section name.\r
+  @param[in]  EntryName       Section entry name.\r
+  @param[out] Guid            Point to the got GUID value.\r
+\r
+  @retval EFI_SUCCESS    Section entry GUID value is got.\r
+  @retval EFI_NOT_FOUND  Section is not found.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetGuidFromDataFile (\r
+  IN      VOID                          *Context,\r
+  IN      CHAR8                         *SectionName,\r
+  IN      CHAR8                         *EntryName,\r
+  OUT     EFI_GUID                      *Guid\r
+  );\r
+\r
+/**\r
+  Get section entry decimal UINTN value.\r
+\r
+  @param[in]  Context         INI Config file context.\r
+  @param[in]  SectionName     Section name.\r
+  @param[in]  EntryName       Section entry name.\r
+  @param[out] Data            Point to the got decimal UINTN value.\r
+\r
+  @retval EFI_SUCCESS    Section entry decimal UINTN value is got.\r
+  @retval EFI_NOT_FOUND  Section is not found.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetDecimalUintnFromDataFile (\r
+  IN      VOID                          *Context,\r
+  IN      CHAR8                         *SectionName,\r
+  IN      CHAR8                         *EntryName,\r
+  OUT     UINTN                         *Data\r
+  );\r
+\r
+/**\r
+  Get section entry heximal UINTN value.\r
+\r
+  @param[in]  Context         INI Config file context.\r
+  @param[in]  SectionName     Section name.\r
+  @param[in]  EntryName       Section entry name.\r
+  @param[out] Data            Point to the got heximal UINTN value.\r
+\r
+  @retval EFI_SUCCESS    Section entry heximal UINTN value is got.\r
+  @retval EFI_NOT_FOUND  Section is not found.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetHexUintnFromDataFile (\r
+  IN      VOID                          *Context,\r
+  IN      CHAR8                         *SectionName,\r
+  IN      CHAR8                         *EntryName,\r
+  OUT     UINTN                         *Data\r
+  );\r
+\r
+/**\r
+  Get section entry heximal UINT64 value.\r
+\r
+  @param[in]  Context         INI Config file context.\r
+  @param[in]  SectionName     Section name.\r
+  @param[in]  EntryName       Section entry name.\r
+  @param[out] Data            Point to the got heximal UINT64 value.\r
+\r
+  @retval EFI_SUCCESS    Section entry heximal UINT64 value is got.\r
+  @retval EFI_NOT_FOUND  Section is not found.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetHexUint64FromDataFile (\r
+  IN      VOID                          *Context,\r
+  IN      CHAR8                         *SectionName,\r
+  IN      CHAR8                         *EntryName,\r
+  OUT     UINT64                        *Data\r
+  );\r
+\r
+/**\r
+  Close an INI config file and free the context.\r
+\r
+  @param[in] Context         INI Config file context.\r
+**/\r
+VOID\r
+EFIAPI\r
+CloseIniFile (\r
+  IN      VOID                          *Context\r
+  );\r
+\r
+#endif\r
+\r