34 ULONG CurrentLineNumber;
36 ULONG IniFileLineSize;
41 TRACE(
"IniParseFile() IniFileSize: %d\n", IniFileSize);
56 CurrentLineNumber = 0;
58 while (CurrentOffset < IniFileSize)
71 CurrentOffset =
IniGetNextLine(IniFileData, IniFileSize, IniFileLine, IniFileLineSize, CurrentOffset);
96 if (!CurrentSection->SectionName)
119 if (CurrentSection ==
NULL)
121 ERR(
"Error: freeldr.ini:%lu: Setting '%s' found outside of a [section].\n", CurrentLineNumber, IniFileLine);
163 CurrentSection->SectionItemCount++;
176 TRACE(
"IniParseFile() done.\n");
183 ULONG LineCharCount = 0;
187 for (; (CurrentOffset < IniFileSize); ++CurrentOffset)
193 if (IniFileData[CurrentOffset] ==
'\n')
199 return LineCharCount;
208 for (Idx = 0; (CurrentOffset < IniFileSize); ++CurrentOffset)
213 Buffer[Idx++] = IniFileData[CurrentOffset];
216 if (IniFileData[CurrentOffset] ==
'\n')
227 while (Idx && (
Buffer[--Idx] ==
'\n' ||
Buffer[Idx] ==
'\r'))
230 return CurrentOffset;
238 for (Idx = 0; Idx < TextLength; ++Idx)
240 if ((TextLine[Idx] ==
' ') || (TextLine[Idx] ==
'\t') ||
241 (TextLine[Idx] ==
'\n') || (TextLine[Idx] ==
'\r'))
256 for (Idx = 0; Idx < TextLength; ++Idx)
258 if ((TextLine[Idx] ==
' ') || (TextLine[Idx] ==
'\t'))
274 for (Idx = 0; Idx < TextLength; ++Idx)
276 if ((TextLine[Idx] ==
' ') || (TextLine[Idx] ==
'\t'))
279 if (TextLine[Idx] ==
'[')
291 for (Idx = 0; Idx < LineLength; ++Idx)
293 if ((SectionNameLine[Idx] ==
' ') || (SectionNameLine[Idx] ==
'\t'))
303 for (NameSize = 0; Idx < LineLength; ++Idx)
305 if ((SectionNameLine[Idx] ==
']') || (SectionNameLine[Idx] ==
'\0'))
320 for (Idx = 0; Idx < LineLength; ++Idx)
322 if ((SectionNameLine[Idx] ==
' ') || (SectionNameLine[Idx] ==
'\t'))
332 for (DestIdx = 0; Idx < LineLength; ++Idx)
334 if ((SectionNameLine[Idx] ==
']') || (SectionNameLine[Idx] ==
'\0'))
338 SectionName[DestIdx] = SectionNameLine[Idx];
343 SectionName[DestIdx] =
'\0';
351 for (Idx = 0; Idx < TextLength; ++Idx)
353 if (TextLine[Idx] ==
'=')
364 for (Idx = 0; Idx < LineLength; ++Idx)
366 if ((SettingNameLine[Idx] ==
' ') || (SettingNameLine[Idx] ==
'\t'))
372 for (NameSize = 0; Idx < LineLength; ++Idx)
374 if ((SettingNameLine[Idx] ==
'=') || (SettingNameLine[Idx] ==
'\0'))
386 ULONG Idx, ValueSize;
389 for (Idx = 0; Idx < LineLength; ++Idx)
391 if ((SettingValueLine[Idx] ==
' ') || (SettingValueLine[Idx] ==
'\t'))
397 for (; Idx < LineLength; ++Idx)
399 if (SettingValueLine[Idx] ==
'=')
406 if (SettingValueLine[Idx] ==
'\0')
411 for (ValueSize = 0; Idx < LineLength; ++Idx)
413 if (SettingValueLine[Idx] ==
'\0')
428 for (Idx = 0; Idx < LineLength; ++Idx)
430 if ((SettingNameLine[Idx] ==
' ') || (SettingNameLine[Idx] ==
'\t'))
436 for (DestIdx = 0; Idx < LineLength; ++Idx)
438 if ((SettingNameLine[Idx] ==
'=') || (SettingNameLine[Idx] ==
'\0'))
441 for (; DestIdx > 0; --DestIdx)
443 if ((SettingName[DestIdx-1] ==
' ') || (SettingName[DestIdx-1] ==
'\t'))
451 SettingName[DestIdx] = SettingNameLine[Idx];
456 SettingName[DestIdx] =
'\0';
464 for (Idx = 0; Idx < LineLength; ++Idx)
466 if ((SettingValueLine[Idx] ==
' ') || (SettingValueLine[Idx] ==
'\t'))
472 for (; Idx < LineLength; ++Idx)
474 if (SettingValueLine[Idx] ==
'=')
481 if (SettingValueLine[Idx] ==
'\0')
483 SettingValue[0] =
'\0';
489 for (DestIdx = 0; Idx < LineLength; ++Idx)
491 if (SettingValueLine[Idx] ==
'\0')
495 SettingValue[DestIdx] = SettingValueLine[Idx];
500 SettingValue[DestIdx] =
'\0';
#define DBG_DEFAULT_CHANNEL(ch)
VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
ULONG IniFileSectionCount
VOID IniExtractSettingValue(PSTR SettingValue, PCSTR SettingValueLine, ULONG LineLength)
ULONG IniGetSectionNameSize(PCSTR SectionNameLine, ULONG LineLength)
VOID IniExtractSectionName(PSTR SectionName, PCSTR SectionNameLine, ULONG LineLength)
ULONG IniGetSettingValueSize(PCSTR SettingValueLine, ULONG LineLength)
BOOLEAN IniIsLineEmpty(PCSTR TextLine, ULONG TextLength)
ULONG IniGetSettingNameSize(PCSTR SettingNameLine, ULONG LineLength)
ULONG IniFileSettingCount
LIST_ENTRY IniFileSectionListHead
BOOLEAN IniIsSectionName(PCSTR TextLine, ULONG TextLength)
ULONG IniGetNextLine(PCSTR IniFileData, ULONG IniFileSize, PCHAR Buffer, ULONG BufferSize, ULONG CurrentOffset)
VOID IniExtractSettingName(PSTR SettingName, PCSTR SettingNameLine, ULONG LineLength)
BOOLEAN IniIsCommentLine(PCSTR TextLine, ULONG TextLength)
BOOLEAN IniParseFile(PCSTR IniFileData, ULONG IniFileSize)
ULONG IniGetNextLineSize(PCSTR IniFileData, ULONG IniFileSize, ULONG CurrentOffset)
BOOLEAN IniIsSetting(PCSTR TextLine, ULONG TextLength)
BOOLEAN IniFileSectionInitialized
_ACRTIMP size_t __cdecl strlen(const char *)
#define InsertTailList(ListHead, Entry)
#define InitializeListHead(ListHead)
#define TAG_INI_SECTION_ITEM
#define INI_FILE_COMMENT_CHAR
#define RtlZeroMemory(Destination, Length)
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize