#include <Library/DebugLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
\r
-#define IS_HYPHEN(a) ((a) == '-')\r
-#define IS_NULL(a) ((a) == '\0')\r
+#define IS_HYPHEN(a) ((a) == '-')\r
+#define IS_NULL(a) ((a) == '\0')\r
\r
// This is default allocation. Reallocation will happen if it is not enough.\r
-#define MAX_LINE_LENGTH 512\r
+#define MAX_LINE_LENGTH 512\r
\r
typedef struct _INI_SECTION_ITEM SECTION_ITEM;\r
struct _INI_SECTION_ITEM {\r
- CHAR8 *PtrSection;\r
- UINTN SecNameLen;\r
- CHAR8 *PtrEntry;\r
- CHAR8 *PtrValue;\r
- SECTION_ITEM *PtrNext;\r
+ CHAR8 *PtrSection;\r
+ UINTN SecNameLen;\r
+ CHAR8 *PtrEntry;\r
+ CHAR8 *PtrValue;\r
+ SECTION_ITEM *PtrNext;\r
};\r
\r
typedef struct _INI_COMMENT_LINE COMMENT_LINE;\r
struct _INI_COMMENT_LINE {\r
- CHAR8 *PtrComment;\r
- COMMENT_LINE *PtrNext;\r
+ CHAR8 *PtrComment;\r
+ COMMENT_LINE *PtrNext;\r
};\r
\r
typedef struct {\r
- SECTION_ITEM *SectionHead;\r
- COMMENT_LINE *CommentHead;\r
+ SECTION_ITEM *SectionHead;\r
+ COMMENT_LINE *CommentHead;\r
} INI_PARSING_LIB_CONTEXT;\r
\r
/**\r
IN BOOLEAN IncludeHex\r
)\r
{\r
- if (DigitalChar >= '0' && DigitalChar <= '9') {\r
+ if ((DigitalChar >= '0') && (DigitalChar <= '9')) {\r
return TRUE;\r
}\r
+\r
if (IncludeHex) {\r
- if (DigitalChar >= 'a' && DigitalChar <= 'f') {\r
+ if ((DigitalChar >= 'a') && (DigitalChar <= 'f')) {\r
return TRUE;\r
}\r
- if (DigitalChar >= 'A' && DigitalChar <= 'F') {\r
+\r
+ if ((DigitalChar >= 'A') && (DigitalChar <= 'F')) {\r
return TRUE;\r
}\r
}\r
+\r
return FALSE;\r
}\r
\r
IN CHAR8 NameChar\r
)\r
{\r
- if (NameChar >= 'a' && NameChar <= 'z') {\r
+ if ((NameChar >= 'a') && (NameChar <= 'z')) {\r
return TRUE;\r
}\r
- if (NameChar >= 'A' && NameChar <= 'Z') {\r
+\r
+ if ((NameChar >= 'A') && (NameChar <= 'Z')) {\r
return TRUE;\r
}\r
- if (NameChar >= '0' && NameChar <= '9') {\r
+\r
+ if ((NameChar >= '0') && (NameChar <= '9')) {\r
return TRUE;\r
}\r
+\r
if (NameChar == '_') {\r
return TRUE;\r
}\r
+\r
return FALSE;\r
}\r
\r
)\r
{\r
UINTN Index;\r
+\r
for (Index = 0; Index < Length; Index++) {\r
- if (!IsValidDigitalChar(Digital[Index], IncludeHex)) {\r
+ if (!IsValidDigitalChar (Digital[Index], IncludeHex)) {\r
return FALSE;\r
}\r
}\r
+\r
return TRUE;\r
}\r
\r
IN UINTN Length\r
)\r
{\r
- return IsValidDigital(Decimal, Length, FALSE);\r
+ return IsValidDigital (Decimal, Length, FALSE);\r
}\r
\r
/**\r
if (Length <= 2) {\r
return FALSE;\r
}\r
+\r
if (Hex[0] != '0') {\r
return FALSE;\r
}\r
- if (Hex[1] != 'x' && Hex[1] != 'X') {\r
+\r
+ if ((Hex[1] != 'x') && (Hex[1] != 'X')) {\r
return FALSE;\r
}\r
- return IsValidDigital(&Hex[2], Length - 2, TRUE);\r
+\r
+ return IsValidDigital (&Hex[2], Length - 2, TRUE);\r
}\r
\r
/**\r
)\r
{\r
UINTN Index;\r
+\r
for (Index = 0; Index < Length; Index++) {\r
- if (!IsValidNameChar(Name[Index])) {\r
+ if (!IsValidNameChar (Name[Index])) {\r
return FALSE;\r
}\r
}\r
+\r
return TRUE;\r
}\r
\r
IN UINTN Length\r
)\r
{\r
- if (Length != sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") - 1) {\r
+ if (Length != sizeof ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") - 1) {\r
return FALSE;\r
}\r
- if (!IS_HYPHEN(Value[8])) {\r
+\r
+ if (!IS_HYPHEN (Value[8])) {\r
return FALSE;\r
}\r
- if (!IS_HYPHEN(Value[13])) {\r
+\r
+ if (!IS_HYPHEN (Value[13])) {\r
return FALSE;\r
}\r
- if (!IS_HYPHEN(Value[18])) {\r
+\r
+ if (!IS_HYPHEN (Value[18])) {\r
return FALSE;\r
}\r
- if (!IS_HYPHEN(Value[23])) {\r
+\r
+ if (!IS_HYPHEN (Value[23])) {\r
return FALSE;\r
}\r
- if (!IsValidDigital(&Value[0], 8, TRUE)) {\r
+\r
+ if (!IsValidDigital (&Value[0], 8, TRUE)) {\r
return FALSE;\r
}\r
- if (!IsValidDigital(&Value[9], 4, TRUE)) {\r
+\r
+ if (!IsValidDigital (&Value[9], 4, TRUE)) {\r
return FALSE;\r
}\r
- if (!IsValidDigital(&Value[14], 4, TRUE)) {\r
+\r
+ if (!IsValidDigital (&Value[14], 4, TRUE)) {\r
return FALSE;\r
}\r
- if (!IsValidDigital(&Value[19], 4, TRUE)) {\r
+\r
+ if (!IsValidDigital (&Value[19], 4, TRUE)) {\r
return FALSE;\r
}\r
- if (!IsValidDigital(&Value[24], 12, TRUE)) {\r
+\r
+ if (!IsValidDigital (&Value[24], 12, TRUE)) {\r
return FALSE;\r
}\r
+\r
return TRUE;\r
}\r
\r
IN UINTN Length\r
)\r
{\r
- if (IsValidName(Value, Length) || IsValidGuid(Value, Length)) {\r
+ if (IsValidName (Value, Length) || IsValidGuid (Value, Length)) {\r
return TRUE;\r
}\r
+\r
return FALSE;\r
}\r
\r
IN VOID *Context\r
)\r
{\r
- INI_PARSING_LIB_CONTEXT *IniContext;\r
- SECTION_ITEM *PtrSection;\r
- SECTION_ITEM *Section;\r
+ INI_PARSING_LIB_CONTEXT *IniContext;\r
+ SECTION_ITEM *PtrSection;\r
+ SECTION_ITEM *Section;\r
\r
if (Context == NULL) {\r
return;\r
}\r
\r
IniContext = Context;\r
- Section = IniContext->SectionHead;\r
+ Section = IniContext->SectionHead;\r
\r
while (Section != NULL) {\r
PtrSection = Section;\r
- Section = Section->PtrNext;\r
+ Section = Section->PtrNext;\r
if (PtrSection->PtrSection != NULL) {\r
- DEBUG((DEBUG_VERBOSE, "Section - %a\n", PtrSection->PtrSection));\r
+ DEBUG ((DEBUG_VERBOSE, "Section - %a\n", PtrSection->PtrSection));\r
}\r
+\r
if (PtrSection->PtrEntry != NULL) {\r
DEBUG ((DEBUG_VERBOSE, " Entry - %a\n", PtrSection->PtrEntry));\r
}\r
+\r
if (PtrSection->PtrValue != NULL) {\r
- DEBUG((DEBUG_VERBOSE, " Value - %a\n", PtrSection->PtrValue));\r
+ DEBUG ((DEBUG_VERBOSE, " Value - %a\n", PtrSection->PtrValue));\r
}\r
}\r
}\r
**/\r
EFI_STATUS\r
ProfileGetLine (\r
- IN UINT8 *Buffer,\r
- IN UINTN BufferSize,\r
- IN OUT UINT8 *LineBuffer,\r
- IN OUT UINTN *LineSize\r
+ IN UINT8 *Buffer,\r
+ IN UINTN BufferSize,\r
+ IN OUT UINT8 *LineBuffer,\r
+ IN OUT UINTN *LineSize\r
)\r
{\r
- UINTN Length;\r
- UINT8 *PtrBuf;\r
- UINTN PtrEnd;\r
+ UINTN Length;\r
+ UINT8 *PtrBuf;\r
+ UINTN PtrEnd;\r
\r
- PtrBuf = Buffer;\r
- PtrEnd = (UINTN)Buffer + BufferSize;\r
+ PtrBuf = Buffer;\r
+ PtrEnd = (UINTN)Buffer + BufferSize;\r
\r
//\r
// 0x0D indicates a line break. Otherwise there is no line break\r
//\r
while ((UINTN)PtrBuf < PtrEnd) {\r
- if (*PtrBuf == 0x0D || *PtrBuf == 0x0A) {\r
+ if ((*PtrBuf == 0x0D) || (*PtrBuf == 0x0A)) {\r
break;\r
}\r
+\r
PtrBuf++;\r
}\r
\r
// The buffer ends without any line break\r
// or it is the last character of the buffer\r
//\r
- Length = BufferSize;\r
+ Length = BufferSize;\r
} else if (*(PtrBuf + 1) == 0x0A) {\r
//\r
// Further check if a 0x0A follows. If yes, count 0xA\r
//\r
- Length = (UINTN) PtrBuf - (UINTN) Buffer + 2;\r
+ Length = (UINTN)PtrBuf - (UINTN)Buffer + 2;\r
} else {\r
- Length = (UINTN) PtrBuf - (UINTN) Buffer + 1;\r
+ Length = (UINTN)PtrBuf - (UINTN)Buffer + 1;\r
}\r
\r
if (Length > (*LineSize)) {\r
}\r
\r
SetMem (LineBuffer, *LineSize, 0x0);\r
- *LineSize = Length;\r
+ *LineSize = Length;\r
CopyMem (LineBuffer, Buffer, Length);\r
\r
return EFI_SUCCESS;\r
**/\r
VOID\r
ProfileTrim (\r
- IN OUT UINT8 *Buffer,\r
- IN OUT UINTN *BufferSize\r
+ IN OUT UINT8 *Buffer,\r
+ IN OUT UINTN *BufferSize\r
)\r
{\r
- UINTN Length;\r
- UINT8 *PtrBuf;\r
- UINT8 *PtrEnd;\r
+ UINTN Length;\r
+ UINT8 *PtrBuf;\r
+ UINT8 *PtrEnd;\r
\r
if (*BufferSize == 0) {\r
return;\r
//\r
// Trim the tail first, include CR, LF, TAB, and SPACE.\r
//\r
- Length = *BufferSize;\r
- PtrBuf = (UINT8 *) ((UINTN) Buffer + Length - 1);\r
+ Length = *BufferSize;\r
+ PtrBuf = (UINT8 *)((UINTN)Buffer + Length - 1);\r
while (PtrBuf >= Buffer) {\r
- if ((*PtrBuf != 0x0D) && (*PtrBuf != 0x0A )\r
- && (*PtrBuf != 0x20) && (*PtrBuf != 0x09)) {\r
+ if ( (*PtrBuf != 0x0D) && (*PtrBuf != 0x0A)\r
+ && (*PtrBuf != 0x20) && (*PtrBuf != 0x09))\r
+ {\r
break;\r
}\r
- PtrBuf --;\r
+\r
+ PtrBuf--;\r
}\r
\r
//\r
// all spaces, a blank line, return directly;\r
//\r
if (PtrBuf < Buffer) {\r
- *BufferSize = 0;\r
+ *BufferSize = 0;\r
return;\r
}\r
\r
- Length = (UINTN)PtrBuf - (UINTN)Buffer + 1;\r
- PtrEnd = PtrBuf;\r
- PtrBuf = Buffer;\r
+ Length = (UINTN)PtrBuf - (UINTN)Buffer + 1;\r
+ PtrEnd = PtrBuf;\r
+ PtrBuf = Buffer;\r
\r
//\r
// Now skip the heading CR, LF, TAB and SPACE\r
//\r
while (PtrBuf <= PtrEnd) {\r
- if ((*PtrBuf != 0x0D) && (*PtrBuf != 0x0A )\r
- && (*PtrBuf != 0x20) && (*PtrBuf != 0x09)) {\r
+ if ( (*PtrBuf != 0x0D) && (*PtrBuf != 0x0A)\r
+ && (*PtrBuf != 0x20) && (*PtrBuf != 0x09))\r
+ {\r
break;\r
}\r
+\r
PtrBuf++;\r
}\r
\r
// If no heading CR, LF, TAB or SPACE, directly return\r
//\r
if (PtrBuf == Buffer) {\r
- *BufferSize = Length;\r
+ *BufferSize = Length;\r
return;\r
}\r
\r
- *BufferSize = (UINTN)PtrEnd - (UINTN)PtrBuf + 1;\r
+ *BufferSize = (UINTN)PtrEnd - (UINTN)PtrBuf + 1;\r
\r
//\r
// The first Buffer..PtrBuf characters are CR, LF, TAB or SPACE.\r
// Now move out all these characters.\r
//\r
while (PtrBuf <= PtrEnd) {\r
- *Buffer = *PtrBuf;\r
+ *Buffer = *PtrBuf;\r
Buffer++;\r
PtrBuf++;\r
}\r
**/\r
EFI_STATUS\r
ProfileGetComments (\r
- IN UINT8 *Buffer,\r
- IN UINTN BufferSize,\r
- IN OUT COMMENT_LINE **CommentHead\r
+ IN UINT8 *Buffer,\r
+ IN UINTN BufferSize,\r
+ IN OUT COMMENT_LINE **CommentHead\r
)\r
{\r
- COMMENT_LINE *CommentItem;\r
+ COMMENT_LINE *CommentItem;\r
\r
CommentItem = NULL;\r
CommentItem = AllocatePool (sizeof (COMMENT_LINE));\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- CommentItem->PtrNext = *CommentHead;\r
- *CommentHead = CommentItem;\r
+ CommentItem->PtrNext = *CommentHead;\r
+ *CommentHead = CommentItem;\r
\r
//\r
// Add a trailing '\0'\r
FreePool (CommentItem);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
+\r
CopyMem (CommentItem->PtrComment, Buffer, BufferSize);\r
*(CommentItem->PtrComment + BufferSize) = '\0';\r
\r
**/\r
EFI_STATUS\r
ProfileGetSection (\r
- IN UINT8 *Buffer,\r
- IN UINTN BufferSize,\r
- IN OUT SECTION_ITEM **SectionHead\r
+ IN UINT8 *Buffer,\r
+ IN UINTN BufferSize,\r
+ IN OUT SECTION_ITEM **SectionHead\r
)\r
{\r
- SECTION_ITEM *SectionItem;\r
- UINTN Length;\r
- UINT8 *PtrBuf;\r
- UINT8 *PtrEnd;\r
+ SECTION_ITEM *SectionItem;\r
+ UINTN Length;\r
+ UINT8 *PtrBuf;\r
+ UINT8 *PtrEnd;\r
\r
- ASSERT(BufferSize >= 1);\r
+ ASSERT (BufferSize >= 1);\r
//\r
// The first character of Buffer is '[', now we want for ']'\r
//\r
- PtrEnd = (UINT8 *)((UINTN)Buffer + BufferSize - 1);\r
- PtrBuf = (UINT8 *)((UINTN)Buffer + 1);\r
+ PtrEnd = (UINT8 *)((UINTN)Buffer + BufferSize - 1);\r
+ PtrBuf = (UINT8 *)((UINTN)Buffer + 1);\r
while (PtrBuf <= PtrEnd) {\r
if (*PtrBuf == ']') {\r
break;\r
}\r
- PtrBuf ++;\r
+\r
+ PtrBuf++;\r
}\r
+\r
if (PtrBuf > PtrEnd) {\r
//\r
// Not found. Invalid line\r
//\r
return EFI_NOT_FOUND;\r
}\r
+\r
if (PtrBuf <= Buffer + 1) {\r
// Empty name\r
return EFI_NOT_FOUND;\r
//\r
// excluding the heading '[' and tailing ']'\r
//\r
- Length = PtrBuf - Buffer - 1;\r
+ Length = PtrBuf - Buffer - 1;\r
ProfileTrim (\r
Buffer + 1,\r
&Length\r
- );\r
+ );\r
\r
//\r
// Invalid line if the section name is null\r
return EFI_NOT_FOUND;\r
}\r
\r
- if (!IsValidName((CHAR8 *)Buffer + 1, Length)) {\r
+ if (!IsValidName ((CHAR8 *)Buffer + 1, Length)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
**/\r
EFI_STATUS\r
ProfileGetEntry (\r
- IN UINT8 *Buffer,\r
- IN UINTN BufferSize,\r
- IN OUT SECTION_ITEM **SectionHead\r
+ IN UINT8 *Buffer,\r
+ IN UINTN BufferSize,\r
+ IN OUT SECTION_ITEM **SectionHead\r
)\r
{\r
- EFI_STATUS Status;\r
- SECTION_ITEM *SectionItem;\r
- SECTION_ITEM *PtrSection;\r
- UINTN Length;\r
- UINT8 *PtrBuf;\r
- UINT8 *PtrEnd;\r
+ EFI_STATUS Status;\r
+ SECTION_ITEM *SectionItem;\r
+ SECTION_ITEM *PtrSection;\r
+ UINTN Length;\r
+ UINT8 *PtrBuf;\r
+ UINT8 *PtrEnd;\r
\r
- Status = EFI_SUCCESS;\r
- PtrBuf = Buffer;\r
- PtrEnd = (UINT8 *) ((UINTN)Buffer + BufferSize - 1);\r
+ Status = EFI_SUCCESS;\r
+ PtrBuf = Buffer;\r
+ PtrEnd = (UINT8 *)((UINTN)Buffer + BufferSize - 1);\r
\r
//\r
// First search for '='\r
if (*PtrBuf == '=') {\r
break;\r
}\r
+\r
PtrBuf++;\r
}\r
+\r
if (PtrBuf > PtrEnd) {\r
//\r
// Not found. Invalid line\r
//\r
return EFI_NOT_FOUND;\r
}\r
+\r
if (PtrBuf <= Buffer) {\r
// Empty name\r
return EFI_NOT_FOUND;\r
//\r
// excluding the tailing '='\r
//\r
- Length = PtrBuf - Buffer;\r
+ Length = PtrBuf - Buffer;\r
ProfileTrim (\r
Buffer,\r
&Length\r
- );\r
+ );\r
\r
//\r
// Invalid line if the entry name is null\r
return EFI_NOT_FOUND;\r
}\r
\r
- if (!IsValidName((CHAR8 *)Buffer, Length)) {\r
+ if (!IsValidName ((CHAR8 *)Buffer, Length)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
if (*SectionHead == NULL) {\r
return Status;\r
}\r
- PtrSection = *SectionHead;\r
+\r
+ PtrSection = *SectionHead;\r
\r
SectionItem = AllocatePool (sizeof (SECTION_ITEM));\r
if (SectionItem == NULL) {\r
if (SectionItem->PtrSection == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
+\r
CopyMem (SectionItem->PtrSection, PtrSection->PtrSection, PtrSection->SecNameLen + 1);\r
\r
//\r
//\r
SectionItem->PtrEntry = AllocatePool (Length + 1);\r
if (SectionItem->PtrEntry == NULL) {\r
- FreePool(SectionItem->PtrSection);\r
+ FreePool (SectionItem->PtrSection);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
+\r
CopyMem (SectionItem->PtrEntry, Buffer, Length);\r
*(SectionItem->PtrEntry + Length) = '\0';\r
\r
//\r
// Next search for '#' or ';'\r
//\r
- PtrBuf = PtrBuf + 1;\r
- Buffer = PtrBuf;\r
+ PtrBuf = PtrBuf + 1;\r
+ Buffer = PtrBuf;\r
while (PtrBuf <= PtrEnd) {\r
- if (*PtrBuf == '#' || *PtrBuf == ';') {\r
+ if ((*PtrBuf == '#') || (*PtrBuf == ';')) {\r
break;\r
}\r
+\r
PtrBuf++;\r
}\r
+\r
if (PtrBuf <= Buffer) {\r
// Empty name\r
- FreePool(SectionItem->PtrEntry);\r
- FreePool(SectionItem->PtrSection);\r
+ FreePool (SectionItem->PtrEntry);\r
+ FreePool (SectionItem->PtrSection);\r
return EFI_NOT_FOUND;\r
}\r
- Length = PtrBuf - Buffer;\r
+\r
+ Length = PtrBuf - Buffer;\r
ProfileTrim (\r
Buffer,\r
&Length\r
- );\r
+ );\r
\r
//\r
// Invalid line if the entry value is null\r
//\r
if (Length == 0) {\r
- FreePool(SectionItem->PtrEntry);\r
- FreePool(SectionItem->PtrSection);\r
+ FreePool (SectionItem->PtrEntry);\r
+ FreePool (SectionItem->PtrSection);\r
return EFI_NOT_FOUND;\r
}\r
\r
- if (!IsValidValue((CHAR8 *)Buffer, Length)) {\r
- FreePool(SectionItem->PtrEntry);\r
- FreePool(SectionItem->PtrSection);\r
+ if (!IsValidValue ((CHAR8 *)Buffer, Length)) {\r
+ FreePool (SectionItem->PtrEntry);\r
+ FreePool (SectionItem->PtrSection);\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
//\r
SectionItem->PtrValue = AllocatePool (Length + 1);\r
if (SectionItem->PtrValue == NULL) {\r
- FreePool(SectionItem->PtrEntry);\r
- FreePool(SectionItem->PtrSection);\r
+ FreePool (SectionItem->PtrEntry);\r
+ FreePool (SectionItem->PtrSection);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
+\r
CopyMem (SectionItem->PtrValue, Buffer, Length);\r
*(SectionItem->PtrValue + Length) = '\0';\r
\r
**/\r
VOID\r
FreeAllList (\r
- IN SECTION_ITEM *Section,\r
- IN COMMENT_LINE *Comment\r
+ IN SECTION_ITEM *Section,\r
+ IN COMMENT_LINE *Comment\r
)\r
{\r
- SECTION_ITEM *PtrSection;\r
- COMMENT_LINE *PtrComment;\r
+ SECTION_ITEM *PtrSection;\r
+ COMMENT_LINE *PtrComment;\r
\r
while (Section != NULL) {\r
- PtrSection = Section;\r
- Section = Section->PtrNext;\r
+ PtrSection = Section;\r
+ Section = Section->PtrNext;\r
if (PtrSection->PtrEntry != NULL) {\r
FreePool (PtrSection->PtrEntry);\r
}\r
+\r
if (PtrSection->PtrSection != NULL) {\r
FreePool (PtrSection->PtrSection);\r
}\r
+\r
if (PtrSection->PtrValue != NULL) {\r
FreePool (PtrSection->PtrValue);\r
}\r
+\r
FreePool (PtrSection);\r
}\r
\r
while (Comment != NULL) {\r
- PtrComment = Comment;\r
- Comment = Comment->PtrNext;\r
+ PtrComment = Comment;\r
+ Comment = Comment->PtrNext;\r
if (PtrComment->PtrComment != NULL) {\r
FreePool (PtrComment->PtrComment);\r
}\r
+\r
FreePool (PtrComment);\r
}\r
\r
**/\r
EFI_STATUS\r
UpdateGetProfileString (\r
- IN SECTION_ITEM *Section,\r
- IN CHAR8 *SectionName,\r
- IN CHAR8 *EntryName,\r
- OUT CHAR8 **EntryValue\r
+ IN SECTION_ITEM *Section,\r
+ IN CHAR8 *SectionName,\r
+ IN CHAR8 *EntryName,\r
+ OUT CHAR8 **EntryValue\r
)\r
{\r
- *EntryValue = NULL;\r
+ *EntryValue = NULL;\r
\r
while (Section != NULL) {\r
- if (AsciiStrCmp ((CONST CHAR8 *) Section->PtrSection, (CONST CHAR8 *) SectionName) == 0) {\r
+ if (AsciiStrCmp ((CONST CHAR8 *)Section->PtrSection, (CONST CHAR8 *)SectionName) == 0) {\r
if (Section->PtrEntry != NULL) {\r
- if (AsciiStrCmp ((CONST CHAR8 *) Section->PtrEntry, (CONST CHAR8 *) EntryName) == 0) {\r
+ if (AsciiStrCmp ((CONST CHAR8 *)Section->PtrEntry, (CONST CHAR8 *)EntryName) == 0) {\r
break;\r
}\r
}\r
}\r
- Section = Section->PtrNext;\r
+\r
+ Section = Section->PtrNext;\r
}\r
\r
if (Section == NULL) {\r
return EFI_NOT_FOUND;\r
}\r
\r
- *EntryValue = Section->PtrValue;\r
+ *EntryValue = Section->PtrValue;\r
\r
return EFI_SUCCESS;\r
}\r
**/\r
EFI_STATUS\r
PreProcessDataFile (\r
- IN UINT8 *DataBuffer,\r
- IN UINTN BufferSize,\r
- IN OUT SECTION_ITEM **SectionHead,\r
- IN OUT COMMENT_LINE **CommentHead\r
+ IN UINT8 *DataBuffer,\r
+ IN UINTN BufferSize,\r
+ IN OUT SECTION_ITEM **SectionHead,\r
+ IN OUT COMMENT_LINE **CommentHead\r
)\r
{\r
- EFI_STATUS Status;\r
- CHAR8 *Source;\r
- CHAR8 *CurrentPtr;\r
- CHAR8 *BufferEnd;\r
- CHAR8 *PtrLine;\r
- UINTN LineLength;\r
- UINTN SourceLength;\r
- UINTN MaxLineLength;\r
-\r
- *SectionHead = NULL;\r
- *CommentHead = NULL;\r
- BufferEnd = (CHAR8 *) ( (UINTN) DataBuffer + BufferSize);\r
- CurrentPtr = (CHAR8 *) DataBuffer;\r
- MaxLineLength = MAX_LINE_LENGTH;\r
- Status = EFI_SUCCESS;\r
+ EFI_STATUS Status;\r
+ CHAR8 *Source;\r
+ CHAR8 *CurrentPtr;\r
+ CHAR8 *BufferEnd;\r
+ CHAR8 *PtrLine;\r
+ UINTN LineLength;\r
+ UINTN SourceLength;\r
+ UINTN MaxLineLength;\r
+\r
+ *SectionHead = NULL;\r
+ *CommentHead = NULL;\r
+ BufferEnd = (CHAR8 *)((UINTN)DataBuffer + BufferSize);\r
+ CurrentPtr = (CHAR8 *)DataBuffer;\r
+ MaxLineLength = MAX_LINE_LENGTH;\r
+ Status = EFI_SUCCESS;\r
\r
PtrLine = AllocatePool (MaxLineLength);\r
if (PtrLine == NULL) {\r
}\r
\r
while (CurrentPtr < BufferEnd) {\r
- Source = CurrentPtr;\r
- SourceLength = (UINTN)BufferEnd - (UINTN)CurrentPtr;\r
- LineLength = MaxLineLength;\r
+ Source = CurrentPtr;\r
+ SourceLength = (UINTN)BufferEnd - (UINTN)CurrentPtr;\r
+ LineLength = MaxLineLength;\r
//\r
// With the assumption that line length is less than 512\r
// characters. Otherwise BUFFER_TOO_SMALL will be returned.\r
//\r
- Status = ProfileGetLine (\r
- (UINT8 *) Source,\r
- SourceLength,\r
- (UINT8 *) PtrLine,\r
- &LineLength\r
- );\r
+ Status = ProfileGetLine (\r
+ (UINT8 *)Source,\r
+ SourceLength,\r
+ (UINT8 *)PtrLine,\r
+ &LineLength\r
+ );\r
if (EFI_ERROR (Status)) {\r
if (Status == EFI_BUFFER_TOO_SMALL) {\r
//\r
// to the returned LineLength and try again.\r
//\r
FreePool (PtrLine);\r
- PtrLine = NULL;\r
+ PtrLine = NULL;\r
PtrLine = AllocatePool (LineLength);\r
if (PtrLine == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
+ Status = EFI_OUT_OF_RESOURCES;\r
break;\r
}\r
- SourceLength = LineLength;\r
- Status = ProfileGetLine (\r
- (UINT8 *) Source,\r
- SourceLength,\r
- (UINT8 *) PtrLine,\r
- &LineLength\r
- );\r
+\r
+ SourceLength = LineLength;\r
+ Status = ProfileGetLine (\r
+ (UINT8 *)Source,\r
+ SourceLength,\r
+ (UINT8 *)PtrLine,\r
+ &LineLength\r
+ );\r
if (EFI_ERROR (Status)) {\r
break;\r
}\r
- MaxLineLength = LineLength;\r
+\r
+ MaxLineLength = LineLength;\r
} else {\r
break;\r
}\r
}\r
- CurrentPtr = (CHAR8 *) ( (UINTN) CurrentPtr + LineLength);\r
+\r
+ CurrentPtr = (CHAR8 *)((UINTN)CurrentPtr + LineLength);\r
\r
//\r
// Line got. Trim the line before processing it.\r
//\r
ProfileTrim (\r
- (UINT8 *) PtrLine,\r
+ (UINT8 *)PtrLine,\r
&LineLength\r
- );\r
+ );\r
\r
//\r
// Blank line\r
continue;\r
}\r
\r
- if (PtrLine[0] == '#' || PtrLine[0] == ';') {\r
- Status = ProfileGetComments (\r
- (UINT8 *) PtrLine,\r
- LineLength,\r
- CommentHead\r
- );\r
+ if ((PtrLine[0] == '#') || (PtrLine[0] == ';')) {\r
+ Status = ProfileGetComments (\r
+ (UINT8 *)PtrLine,\r
+ LineLength,\r
+ CommentHead\r
+ );\r
} else if (PtrLine[0] == '[') {\r
- Status = ProfileGetSection (\r
- (UINT8 *) PtrLine,\r
- LineLength,\r
- SectionHead\r
- );\r
+ Status = ProfileGetSection (\r
+ (UINT8 *)PtrLine,\r
+ LineLength,\r
+ SectionHead\r
+ );\r
} else {\r
- Status = ProfileGetEntry (\r
- (UINT8 *) PtrLine,\r
- LineLength,\r
- SectionHead\r
- );\r
+ Status = ProfileGetEntry (\r
+ (UINT8 *)PtrLine,\r
+ LineLength,\r
+ SectionHead\r
+ );\r
}\r
\r
if (EFI_ERROR (Status)) {\r
VOID *\r
EFIAPI\r
OpenIniFile (\r
- IN UINT8 *DataBuffer,\r
- IN UINTN BufferSize\r
+ IN UINT8 *DataBuffer,\r
+ IN UINTN BufferSize\r
)\r
{\r
- EFI_STATUS Status;\r
- INI_PARSING_LIB_CONTEXT *IniContext;\r
+ EFI_STATUS Status;\r
+ INI_PARSING_LIB_CONTEXT *IniContext;\r
\r
- if (DataBuffer == NULL || BufferSize == 0) {\r
+ if ((DataBuffer == NULL) || (BufferSize == 0)) {\r
return NULL;\r
}\r
\r
- IniContext = AllocateZeroPool(sizeof(INI_PARSING_LIB_CONTEXT));\r
+ IniContext = AllocateZeroPool (sizeof (INI_PARSING_LIB_CONTEXT));\r
if (IniContext == NULL) {\r
return NULL;\r
}\r
&IniContext->SectionHead,\r
&IniContext->CommentHead\r
);\r
- if (EFI_ERROR(Status)) {\r
- FreePool(IniContext);\r
+ if (EFI_ERROR (Status)) {\r
+ FreePool (IniContext);\r
return NULL;\r
}\r
+\r
DEBUG_CODE_BEGIN ();\r
- DumpIniSection(IniContext);\r
+ DumpIniSection (IniContext);\r
DEBUG_CODE_END ();\r
return IniContext;\r
}\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
+GetStringFromDataFile (\r
+ IN VOID *Context,\r
+ IN CHAR8 *SectionName,\r
+ IN CHAR8 *EntryName,\r
+ OUT CHAR8 **EntryValue\r
)\r
{\r
- INI_PARSING_LIB_CONTEXT *IniContext;\r
- EFI_STATUS Status;\r
+ INI_PARSING_LIB_CONTEXT *IniContext;\r
+ EFI_STATUS Status;\r
\r
- if (Context == NULL || SectionName == NULL || EntryName == NULL || EntryValue == NULL) {\r
+ if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (EntryValue == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
IniContext = Context;\r
\r
- *EntryValue = NULL;\r
- Status = UpdateGetProfileString (\r
- IniContext->SectionHead,\r
- SectionName,\r
- EntryName,\r
- EntryValue\r
- );\r
+ *EntryValue = NULL;\r
+ Status = UpdateGetProfileString (\r
+ IniContext->SectionHead,\r
+ SectionName,\r
+ EntryName,\r
+ EntryValue\r
+ );\r
return Status;\r
}\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
+ IN VOID *Context,\r
+ IN CHAR8 *SectionName,\r
+ IN CHAR8 *EntryName,\r
+ OUT EFI_GUID *Guid\r
)\r
{\r
- CHAR8 *Value;\r
- EFI_STATUS Status;\r
- RETURN_STATUS RStatus;\r
+ CHAR8 *Value;\r
+ EFI_STATUS Status;\r
+ RETURN_STATUS RStatus;\r
\r
- if (Context == NULL || SectionName == NULL || EntryName == NULL || Guid == NULL) {\r
+ if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (Guid == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- Status = GetStringFromDataFile(\r
+ Status = GetStringFromDataFile (\r
Context,\r
SectionName,\r
EntryName,\r
&Value\r
);\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return EFI_NOT_FOUND;\r
}\r
+\r
ASSERT (Value != NULL);\r
RStatus = AsciiStrToGuid (Value, Guid);\r
if (RETURN_ERROR (RStatus) || (Value[GUID_STRING_LENGTH] != '\0')) {\r
return EFI_NOT_FOUND;\r
}\r
+\r
return EFI_SUCCESS;\r
}\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
+ IN VOID *Context,\r
+ IN CHAR8 *SectionName,\r
+ IN CHAR8 *EntryName,\r
+ OUT UINTN *Data\r
)\r
{\r
- CHAR8 *Value;\r
- EFI_STATUS Status;\r
+ CHAR8 *Value;\r
+ EFI_STATUS Status;\r
\r
- if (Context == NULL || SectionName == NULL || EntryName == NULL || Data == NULL) {\r
+ if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (Data == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- Status = GetStringFromDataFile(\r
+ Status = GetStringFromDataFile (\r
Context,\r
SectionName,\r
EntryName,\r
&Value\r
);\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return EFI_NOT_FOUND;\r
}\r
+\r
ASSERT (Value != NULL);\r
- if (!IsValidDecimalString(Value, AsciiStrLen(Value))) {\r
+ if (!IsValidDecimalString (Value, AsciiStrLen (Value))) {\r
return EFI_NOT_FOUND;\r
}\r
- *Data = AsciiStrDecimalToUintn(Value);\r
+\r
+ *Data = AsciiStrDecimalToUintn (Value);\r
return EFI_SUCCESS;\r
}\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
+ IN VOID *Context,\r
+ IN CHAR8 *SectionName,\r
+ IN CHAR8 *EntryName,\r
+ OUT UINTN *Data\r
)\r
{\r
- CHAR8 *Value;\r
- EFI_STATUS Status;\r
+ CHAR8 *Value;\r
+ EFI_STATUS Status;\r
\r
- if (Context == NULL || SectionName == NULL || EntryName == NULL || Data == NULL) {\r
+ if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (Data == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- Status = GetStringFromDataFile(\r
+ Status = GetStringFromDataFile (\r
Context,\r
SectionName,\r
EntryName,\r
&Value\r
);\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return EFI_NOT_FOUND;\r
}\r
+\r
ASSERT (Value != NULL);\r
- if (!IsValidHexString(Value, AsciiStrLen(Value))) {\r
+ if (!IsValidHexString (Value, AsciiStrLen (Value))) {\r
return EFI_NOT_FOUND;\r
}\r
- *Data = AsciiStrHexToUintn(Value);\r
+\r
+ *Data = AsciiStrHexToUintn (Value);\r
return EFI_SUCCESS;\r
}\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
+ IN VOID *Context,\r
+ IN CHAR8 *SectionName,\r
+ IN CHAR8 *EntryName,\r
+ OUT UINT64 *Data\r
)\r
{\r
- CHAR8 *Value;\r
- EFI_STATUS Status;\r
+ CHAR8 *Value;\r
+ EFI_STATUS Status;\r
\r
- if (Context == NULL || SectionName == NULL || EntryName == NULL || Data == NULL) {\r
+ if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (Data == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- Status = GetStringFromDataFile(\r
+ Status = GetStringFromDataFile (\r
Context,\r
SectionName,\r
EntryName,\r
&Value\r
);\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return EFI_NOT_FOUND;\r
}\r
+\r
ASSERT (Value != NULL);\r
- if (!IsValidHexString(Value, AsciiStrLen(Value))) {\r
+ if (!IsValidHexString (Value, AsciiStrLen (Value))) {\r
return EFI_NOT_FOUND;\r
}\r
- *Data = AsciiStrHexToUint64(Value);\r
+\r
+ *Data = AsciiStrHexToUint64 (Value);\r
return EFI_SUCCESS;\r
}\r
\r
VOID\r
EFIAPI\r
CloseIniFile (\r
- IN VOID *Context\r
+ IN VOID *Context\r
)\r
{\r
- INI_PARSING_LIB_CONTEXT *IniContext;\r
+ INI_PARSING_LIB_CONTEXT *IniContext;\r
\r
if (Context == NULL) {\r
- return ;\r
+ return;\r
}\r
\r
IniContext = Context;\r
- FreeAllList(IniContext->SectionHead, IniContext->CommentHead);\r
+ FreeAllList (IniContext->SectionHead, IniContext->CommentHead);\r
\r
return;\r
}\r