ReactOS  0.4.14-dev-583-g2a1ba2c
inifile.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  INI_SECTION_ITEM
 
struct  INI_SECTION
 

Macros

#define INI_FILE_COMMENT_CHAR   ';'
 
#define TAG_INI_FILE   'FinI'
 
#define TAG_INI_SECTION   'SinI'
 
#define TAG_INI_SECTION_ITEM   'IinI'
 
#define TAG_INI_NAME   'NinI'
 
#define TAG_INI_VALUE   'VinI'
 

Typedefs

typedef struct INI_SECTION_ITEMPINI_SECTION_ITEM
 
typedef struct INI_SECTIONPINI_SECTION
 

Functions

BOOLEAN IniParseFile (PCHAR IniFileData, ULONG IniFileSize)
 
ULONG IniGetNextLineSize (PCHAR IniFileData, ULONG IniFileSize, ULONG CurrentOffset)
 
ULONG IniGetNextLine (PCHAR IniFileData, ULONG IniFileSize, PCHAR Buffer, ULONG BufferSize, ULONG CurrentOffset)
 
BOOLEAN IniIsLineEmpty (PCHAR LineOfText, ULONG TextLength)
 
BOOLEAN IniIsCommentLine (PCHAR LineOfText, ULONG TextLength)
 
BOOLEAN IniIsSectionName (PCHAR LineOfText, ULONG TextLength)
 
ULONG IniGetSectionNameSize (PCHAR SectionNameLine, ULONG LineLength)
 
VOID IniExtractSectionName (PCHAR SectionName, PCHAR SectionNameLine, ULONG LineLength)
 
BOOLEAN IniIsSetting (PCHAR LineOfText, ULONG TextLength)
 
ULONG IniGetSettingNameSize (PCHAR SettingNameLine, ULONG LineLength)
 
ULONG IniGetSettingValueSize (PCHAR SettingValueLine, ULONG LineLength)
 
VOID IniExtractSettingName (PCHAR SettingName, PCHAR SettingNameLine, ULONG LineLength)
 
VOID IniExtractSettingValue (PCHAR SettingValue, PCHAR SettingValueLine, ULONG LineLength)
 
BOOLEAN IniFileInitialize (VOID)
 
BOOLEAN IniOpenSection (PCSTR SectionName, ULONG_PTR *SectionId)
 
ULONG IniGetNumSectionItems (ULONG_PTR SectionId)
 
ULONG IniGetSectionSettingNameSize (ULONG_PTR SectionId, ULONG SettingIndex)
 
ULONG IniGetSectionSettingValueSize (ULONG_PTR SectionId, ULONG SettingIndex)
 
BOOLEAN IniReadSettingByNumber (ULONG_PTR SectionId, ULONG SettingNumber, PCHAR SettingName, ULONG NameSize, PCHAR SettingValue, ULONG ValueSize)
 
BOOLEAN IniReadSettingByName (ULONG_PTR SectionId, PCSTR SettingName, PCHAR Buffer, ULONG BufferSize)
 
BOOLEAN IniAddSection (PCSTR SectionName, ULONG_PTR *SectionId)
 
BOOLEAN IniAddSettingValueToSection (ULONG_PTR SectionId, PCSTR SettingName, PCSTR SettingValue)
 
BOOLEAN IniModifySettingValue (ULONG_PTR SectionId, PCSTR SettingName, PCSTR SettingValue)
 
VOID IniCleanup (VOID)
 

Variables

LIST_ENTRY IniFileSectionListHead
 
BOOLEAN IniFileSectionInitialized
 
ULONG IniFileSectionCount
 
ULONG IniFileSettingCount
 

Macro Definition Documentation

◆ INI_FILE_COMMENT_CHAR

#define INI_FILE_COMMENT_CHAR   ';'

Definition at line 22 of file inifile.h.

◆ TAG_INI_FILE

#define TAG_INI_FILE   'FinI'

Definition at line 24 of file inifile.h.

◆ TAG_INI_NAME

#define TAG_INI_NAME   'NinI'

Definition at line 27 of file inifile.h.

◆ TAG_INI_SECTION

#define TAG_INI_SECTION   'SinI'

Definition at line 25 of file inifile.h.

◆ TAG_INI_SECTION_ITEM

#define TAG_INI_SECTION_ITEM   'IinI'

Definition at line 26 of file inifile.h.

◆ TAG_INI_VALUE

#define TAG_INI_VALUE   'VinI'

Definition at line 28 of file inifile.h.

Typedef Documentation

◆ PINI_SECTION

◆ PINI_SECTION_ITEM

Function Documentation

◆ IniAddSection()

BOOLEAN IniAddSection ( PCSTR  SectionName,
ULONG_PTR SectionId 
)

Definition at line 179 of file inifile.c.

180 {
181  PINI_SECTION Section;
182 
183  // Allocate a new section structure
184  Section = FrLdrTempAlloc(sizeof(INI_SECTION), TAG_INI_SECTION);
185  if (!Section)
186  {
187  return FALSE;
188  }
189 
190  RtlZeroMemory(Section, sizeof(INI_SECTION));
191 
192  // Allocate the section name buffer
193  Section->SectionName = FrLdrTempAlloc(strlen(SectionName) + sizeof(CHAR), TAG_INI_NAME);
194  if (!Section->SectionName)
195  {
196  FrLdrTempFree(Section, TAG_INI_SECTION);
197  return FALSE;
198  }
199 
200  // Get the section name
201  strcpy(Section->SectionName, SectionName);
203 
204  // Add it to the section list head
207 
208  *SectionId = (ULONG_PTR)Section;
209 
210  return TRUE;
211 }
#define TRUE
Definition: types.h:120
#define TAG_INI_NAME
Definition: inifile.h:27
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
char CHAR
Definition: xmlstorage.h:175
LIST_ENTRY ListEntry
Definition: inifile.h:48
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
LIST_ENTRY IniFileSectionListHead
Definition: parse.c:25
ULONG IniFileSectionCount
Definition: parse.c:27
LIST_ENTRY SectionItemList
Definition: inifile.h:51
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PCHAR SectionName
Definition: inifile.h:49
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_PTR
Definition: config.h:101
#define TAG_INI_SECTION
Definition: inifile.h:25
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186

Referenced by EditCustomBootReactOS(), and InitOperatingSystemList().

◆ IniAddSettingValueToSection()

BOOLEAN IniAddSettingValueToSection ( ULONG_PTR  SectionId,
PCSTR  SettingName,
PCSTR  SettingValue 
)

Definition at line 252 of file inifile.c.

253 {
254  PINI_SECTION Section = (PINI_SECTION)SectionId;
255  PINI_SECTION_ITEM SectionItem;
256 
257  // Allocate a new item structure
258  SectionItem = FrLdrTempAlloc(sizeof(INI_SECTION_ITEM), TAG_INI_SECTION_ITEM);
259  if (!SectionItem)
260  {
261  return FALSE;
262  }
263 
264  RtlZeroMemory(SectionItem, sizeof(INI_SECTION_ITEM));
265 
266  // Allocate the setting name buffer
267  SectionItem->ItemName = FrLdrTempAlloc(strlen(SettingName) + 1, TAG_INI_NAME);
268  if (!SectionItem->ItemName)
269  {
270  FrLdrTempFree(SectionItem, TAG_INI_SECTION_ITEM);
271  return FALSE;
272  }
273 
274  // Allocate the setting value buffer
275  SectionItem->ItemValue = FrLdrTempAlloc(strlen(SettingValue) + 1, TAG_INI_VALUE);
276  if (!SectionItem->ItemValue)
277  {
278  FrLdrTempFree(SectionItem->ItemName, TAG_INI_NAME);
279  FrLdrTempFree(SectionItem, TAG_INI_SECTION_ITEM);
280  return FALSE;
281  }
282 
283  strcpy(SectionItem->ItemName, SettingName);
284  strcpy(SectionItem->ItemValue, SettingValue);
285 
286  // Add it to the current section
287  Section->SectionItemCount++;
288  InsertTailList(&Section->SectionItemList, &SectionItem->ListEntry);
289 
290  return TRUE;
291 }
PCHAR ItemValue
Definition: inifile.h:37
#define TRUE
Definition: types.h:120
#define TAG_INI_VALUE
Definition: inifile.h:28
#define TAG_INI_NAME
Definition: inifile.h:27
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define InsertTailList(ListHead, Entry)
LIST_ENTRY ListEntry
Definition: inifile.h:35
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
PCHAR ItemName
Definition: inifile.h:36
ULONG SectionItemCount
Definition: inifile.h:50
#define TAG_INI_SECTION_ITEM
Definition: inifile.h:26
LIST_ENTRY SectionItemList
Definition: inifile.h:51
struct INI_SECTION * PINI_SECTION
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186

Referenced by EditCustomBootReactOS(), IniModifySettingValue(), and InitOperatingSystemList().

◆ IniCleanup()

VOID IniCleanup ( VOID  )

Definition at line 235 of file inifile.c.

236 {
237  PLIST_ENTRY ListEntry;
238  PINI_SECTION Section;
239 
240  // Loop while there are sections
242  {
243  // Remove the section
245  Section = CONTAINING_RECORD(ListEntry, INI_SECTION, ListEntry);
246 
247  // Free it
248  IniFreeSection(Section);
249  }
250 }
VOID IniFreeSection(PINI_SECTION Section)
Definition: inifile.c:213
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY IniFileSectionListHead
Definition: parse.c:25
Definition: typedefs.h:117

Referenced by LoadAndBootWindowsCommon(), and RunLoader().

◆ IniExtractSectionName()

VOID IniExtractSectionName ( PCHAR  SectionName,
PCHAR  SectionNameLine,
ULONG  LineLength 
)

Definition at line 360 of file parse.c.

361 {
362  ULONG Idx;
363  ULONG DestIdx;
364 
365  // Find the opening bracket (skipping whitespace)
366  for (Idx=0; Idx<LineLength; Idx++)
367  {
368  if ((SectionNameLine[Idx] == ' ') ||
369  (SectionNameLine[Idx] == '\t'))
370  {
371  continue;
372  }
373  else //if (SectionNameLine[Idx] == '[')
374  {
375  break;
376  }
377  }
378 
379  // Skip past the opening bracket
380  Idx++;
381 
382  // Count the characters up until the closing bracket or EOL
383  for (DestIdx=0; Idx<LineLength; Idx++)
384  {
385  if ((SectionNameLine[Idx] == ']') ||
386  (SectionNameLine[Idx] == '\0'))
387  {
388  break;
389  }
390 
391  // Grab a character and increment DestIdx
392  SectionName[DestIdx] = SectionNameLine[Idx];
393  DestIdx++;
394  }
395 
396  // Terminate the string
397  SectionName[DestIdx] = '\0';
398 }
unsigned int ULONG
Definition: retypes.h:1

Referenced by IniParseFile().

◆ IniExtractSettingName()

VOID IniExtractSettingName ( PCHAR  SettingName,
PCHAR  SettingNameLine,
ULONG  LineLength 
)

Definition at line 507 of file parse.c.

508 {
509  ULONG Idx;
510  ULONG DestIdx;
511 
512  // Skip whitespace
513  for (Idx=0; Idx<LineLength; Idx++)
514  {
515  if ((SettingNameLine[Idx] == ' ') ||
516  (SettingNameLine[Idx] == '\t'))
517  {
518  continue;
519  }
520  else
521  {
522  break;
523  }
524  }
525 
526  // Get the characters up until the '=' equals sign or EOL
527  for (DestIdx=0; Idx<LineLength; Idx++)
528  {
529  if ((SettingNameLine[Idx] == '=') ||
530  (SettingNameLine[Idx] == '\0'))
531  {
532  break;
533  }
534 
535  // Grab a character and increment DestIdx
536  SettingName[DestIdx] = SettingNameLine[Idx];
537  DestIdx++;
538  }
539 
540  // Terminate the string
541  SettingName[DestIdx] = '\0';
542 }
unsigned int ULONG
Definition: retypes.h:1

Referenced by IniParseFile().

◆ IniExtractSettingValue()

VOID IniExtractSettingValue ( PCHAR  SettingValue,
PCHAR  SettingValueLine,
ULONG  LineLength 
)

Definition at line 544 of file parse.c.

545 {
546  ULONG Idx;
547  ULONG DestIdx;
548 
549  // Skip whitespace
550  for (Idx=0; Idx<LineLength; Idx++)
551  {
552  if ((SettingValueLine[Idx] == ' ') ||
553  (SettingValueLine[Idx] == '\t'))
554  {
555  continue;
556  }
557  else
558  {
559  break;
560  }
561  }
562 
563  // Skip the characters up until the '=' equals sign or EOL
564  for (; Idx<LineLength; Idx++)
565  {
566  if (SettingValueLine[Idx] == '=')
567  {
568  Idx++;
569  break;
570  }
571 
572  // If we hit EOL then obviously the value size is zero
573  if (SettingValueLine[Idx] == '\0')
574  {
575  SettingValue[0] = '\0';
576  return;
577  }
578  }
579 
580  // Get the characters up until the EOL
581  for (DestIdx=0; Idx<LineLength; Idx++)
582  {
583  if (SettingValueLine[Idx] == '\0')
584  {
585  break;
586  }
587 
588  // Grab a character and increment DestIdx
589  SettingValue[DestIdx] = SettingValueLine[Idx];
590  DestIdx++;
591  }
592 
593  // Terminate the string
594  SettingValue[DestIdx] = '\0';
595 }
unsigned int ULONG
Definition: retypes.h:1

Referenced by IniParseFile().

◆ IniFileInitialize()

BOOLEAN IniFileInitialize ( VOID  )

Definition at line 25 of file ini_init.c.

26 {
28  ULONG FileId; // File handle for freeldr.ini
29  PCHAR FreeLoaderIniFileData;
30  ULONG FreeLoaderIniFileSize, Count;
33 
34  TRACE("IniFileInitialize()\n");
35 
36  /* Try to open freeldr.ini */
37  Status = FsOpenFile("freeldr.ini", FrLdrBootPath, OpenReadOnly, &FileId);
38  if (Status != ESUCCESS)
39  {
40  ERR("Error while opening freeldr.ini, Status: %d\n", Status);
41  UiMessageBoxCritical("Error opening freeldr.ini or file not found.\nYou need to re-install FreeLoader.");
42  return FALSE;
43  }
44 
45  /* Get the file size */
47  if (Status != ESUCCESS || FileInformation.EndingAddress.HighPart != 0)
48  {
49  UiMessageBoxCritical("Error while getting informations about freeldr.ini.\nYou need to re-install FreeLoader.");
50  ArcClose(FileId);
51  return FALSE;
52  }
53  FreeLoaderIniFileSize = FileInformation.EndingAddress.LowPart;
54 
55  /* Allocate memory to cache the whole freeldr.ini */
56  FreeLoaderIniFileData = FrLdrTempAlloc(FreeLoaderIniFileSize, TAG_INI_FILE);
57  if (!FreeLoaderIniFileData)
58  {
59  UiMessageBoxCritical("Out of memory while loading freeldr.ini.");
60  ArcClose(FileId);
61  return FALSE;
62  }
63 
64  /* Load freeldr.ini from the disk */
65  Status = ArcRead(FileId, FreeLoaderIniFileData, FreeLoaderIniFileSize, &Count);
66  if (Status != ESUCCESS || Count != FreeLoaderIniFileSize)
67  {
68  ERR("Error while reading freeldr.ini, Status: %d\n", Status);
69  UiMessageBoxCritical("Error while reading freeldr.ini.");
70  ArcClose(FileId);
71  FrLdrTempFree(FreeLoaderIniFileData, TAG_INI_FILE);
72  return FALSE;
73  }
74 
75  /* Parse the .ini file data */
76  Success = IniParseFile(FreeLoaderIniFileData, FreeLoaderIniFileSize);
77 
78  /* Do some cleanup, and return */
79  ArcClose(FileId);
80  FrLdrTempFree(FreeLoaderIniFileData, TAG_INI_FILE);
81 
82  return Success;
83 }
signed char * PCHAR
Definition: retypes.h:7
Definition: arc.h:32
BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize)
Definition: parse.c:31
static OUT PIO_STATUS_BLOCK OUT PVOID FileInformation
Definition: pipe.c:75
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
ULONG ARC_STATUS
Definition: arc.h:4
ARC_STATUS FsOpenFile(IN PCSTR FileName, IN PCSTR DefaultPath OPTIONAL, IN OPENMODE OpenMode, OUT PULONG FileId)
Definition: fs.c:266
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
unsigned char BOOLEAN
#define TRACE(s)
Definition: solgame.cpp:4
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:236
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
#define TAG_INI_FILE
Definition: inifile.h:24
ARC_STATUS ArcClose(ULONG FileId)
Definition: fs.c:218
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: fs.c:250
unsigned int ULONG
Definition: retypes.h:1
CHAR FrLdrBootPath[MAX_PATH]
Definition: mach.c:34
VOID UiMessageBoxCritical(PCSTR MessageText)
Definition: ui.c:331
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186

Referenced by RunLoader().

◆ IniGetNextLine()

ULONG IniGetNextLine ( PCHAR  IniFileData,
ULONG  IniFileSize,
PCHAR  Buffer,
ULONG  BufferSize,
ULONG  CurrentOffset 
)

Definition at line 210 of file parse.c.

211 {
212  ULONG Idx;
213 
214  // Loop through grabbing chars until we hit the end of the
215  // file or we encounter a new line char
216  for (Idx=0; (CurrentOffset < IniFileSize); CurrentOffset++)
217  {
218  // If we haven't exceeded our buffer size yet
219  // then store another char
220  if (Idx < (BufferSize - 1))
221  {
222  Buffer[Idx++] = IniFileData[CurrentOffset];
223  }
224 
225  // Check for new line char
226  if (IniFileData[CurrentOffset] == '\n')
227  {
228  CurrentOffset++;
229  break;
230  }
231  }
232 
233  // Terminate the string
234  Buffer[Idx] = '\0';
235 
236  // Get rid of newline & linefeed characters (if any)
237  while(Idx && (Buffer[--Idx] == '\n' || Buffer[Idx] == '\r'))
238  Buffer[Idx] = '\0';
239 
240  // Send back new offset
241  return CurrentOffset;
242 }
Definition: bufpool.h:45
#define BufferSize
Definition: classpnp.h:419
unsigned int ULONG
Definition: retypes.h:1

Referenced by IniParseFile().

◆ IniGetNextLineSize()

ULONG IniGetNextLineSize ( PCHAR  IniFileData,
ULONG  IniFileSize,
ULONG  CurrentOffset 
)

Definition at line 185 of file parse.c.

186 {
187  ULONG LineCharCount = 0;
188 
189  // Loop through counting chars until we hit the end of the
190  // file or we encounter a new line char
191  for (; (CurrentOffset < IniFileSize); CurrentOffset++)
192  {
193  // Increment the line character count
194  LineCharCount++;
195 
196  // Check for new line char
197  if (IniFileData[CurrentOffset] == '\n')
198  {
199  break;
200  }
201  }
202 
203  // Add one for the NULL-terminator
204  LineCharCount++;
205 
206  // Send back line character count
207  return LineCharCount;
208 }
unsigned int ULONG
Definition: retypes.h:1

Referenced by IniParseFile().

◆ IniGetNumSectionItems()

ULONG IniGetNumSectionItems ( ULONG_PTR  SectionId)

Definition at line 54 of file inifile.c.

55 {
56  PINI_SECTION Section = (PINI_SECTION)SectionId;
57 
58  TRACE("IniGetNumSectionItems() SectionId = 0x%x\n", SectionId);
59  TRACE("IniGetNumSectionItems() Item count = %d\n", Section->SectionItemCount);
60 
61  return Section->SectionItemCount;
62 }
ULONG SectionItemCount
Definition: inifile.h:50
#define TRACE(s)
Definition: solgame.cpp:4
struct INI_SECTION * PINI_SECTION

Referenced by BuildArgvForOsLoader(), InitOperatingSystemList(), and UiShowMessageBoxesInSection().

◆ IniGetSectionNameSize()

ULONG IniGetSectionNameSize ( PCHAR  SectionNameLine,
ULONG  LineLength 
)

Definition at line 319 of file parse.c.

320 {
321  ULONG Idx;
322  ULONG NameSize;
323 
324  // Find the opening bracket (skipping whitespace)
325  for (Idx=0; Idx<LineLength; Idx++)
326  {
327  if ((SectionNameLine[Idx] == ' ') ||
328  (SectionNameLine[Idx] == '\t'))
329  {
330  continue;
331  }
332  else //if (SectionNameLine[Idx] == '[')
333  {
334  break;
335  }
336  }
337 
338  // Skip past the opening bracket
339  Idx++;
340 
341  // Count the characters up until the closing bracket or EOL
342  for (NameSize=0; Idx<LineLength; Idx++)
343  {
344  if ((SectionNameLine[Idx] == ']') ||
345  (SectionNameLine[Idx] == '\0'))
346  {
347  break;
348  }
349 
350  // Increment the count
351  NameSize++;
352  }
353 
354  // Add one for the NULL-terminator
355  NameSize++;
356 
357  return NameSize;
358 }
unsigned int ULONG
Definition: retypes.h:1

Referenced by IniParseFile().

◆ IniGetSectionSettingNameSize()

ULONG IniGetSectionSettingNameSize ( ULONG_PTR  SectionId,
ULONG  SettingIndex 
)

Definition at line 88 of file inifile.c.

89 {
90  PINI_SECTION_ITEM SectionItem;
91 
92  // Retrieve requested setting
93  SectionItem = IniGetSettingByNumber(SectionId, SettingIndex);
94  if (!SectionItem)
95  return 0;
96 
97  // Return the size of the string plus 1 for the null-terminator
98  return (ULONG)(strlen(SectionItem->ItemName) + 1);
99 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PCHAR ItemName
Definition: inifile.h:36
PINI_SECTION_ITEM IniGetSettingByNumber(ULONG_PTR SectionId, ULONG SettingNumber)
Definition: inifile.c:64
unsigned int ULONG
Definition: retypes.h:1

Referenced by BuildArgvForOsLoader().

◆ IniGetSectionSettingValueSize()

ULONG IniGetSectionSettingValueSize ( ULONG_PTR  SectionId,
ULONG  SettingIndex 
)

Definition at line 101 of file inifile.c.

102 {
103  PINI_SECTION_ITEM SectionItem;
104 
105  // Retrieve requested setting
106  SectionItem = IniGetSettingByNumber(SectionId, SettingIndex);
107  if (!SectionItem)
108  return 0;
109 
110  // Return the size of the string plus 1 for the null-terminator
111  return (ULONG)(strlen(SectionItem->ItemValue) + 1);
112 }
PCHAR ItemValue
Definition: inifile.h:37
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PINI_SECTION_ITEM IniGetSettingByNumber(ULONG_PTR SectionId, ULONG SettingNumber)
Definition: inifile.c:64
unsigned int ULONG
Definition: retypes.h:1

Referenced by BuildArgvForOsLoader(), and UiShowMessageBoxesInSection().

◆ IniGetSettingNameSize()

ULONG IniGetSettingNameSize ( PCHAR  SettingNameLine,
ULONG  LineLength 
)

Definition at line 416 of file parse.c.

417 {
418  ULONG Idx;
419  ULONG NameSize;
420 
421  // Skip whitespace
422  for (Idx=0; Idx<LineLength; Idx++)
423  {
424  if ((SettingNameLine[Idx] == ' ') ||
425  (SettingNameLine[Idx] == '\t'))
426  {
427  continue;
428  }
429  else
430  {
431  break;
432  }
433  }
434 
435  // Count the characters up until the '=' equals sign or EOL
436  for (NameSize=0; Idx<LineLength; Idx++)
437  {
438  if ((SettingNameLine[Idx] == '=') ||
439  (SettingNameLine[Idx] == '\0'))
440  {
441  break;
442  }
443 
444  // Increment the count
445  NameSize++;
446  }
447 
448  // Add one for the NULL-terminator
449  NameSize++;
450 
451  return NameSize;
452 }
unsigned int ULONG
Definition: retypes.h:1

Referenced by IniParseFile().

◆ IniGetSettingValueSize()

ULONG IniGetSettingValueSize ( PCHAR  SettingValueLine,
ULONG  LineLength 
)

Definition at line 454 of file parse.c.

455 {
456  ULONG Idx;
457  ULONG ValueSize;
458 
459  // Skip whitespace
460  for (Idx=0; Idx<LineLength; Idx++)
461  {
462  if ((SettingValueLine[Idx] == ' ') ||
463  (SettingValueLine[Idx] == '\t'))
464  {
465  continue;
466  }
467  else
468  {
469  break;
470  }
471  }
472 
473  // Skip the characters up until the '=' equals sign or EOL
474  for (; Idx<LineLength; Idx++)
475  {
476  if (SettingValueLine[Idx] == '=')
477  {
478  Idx++;
479  break;
480  }
481 
482  // If we hit EOL then obviously the value size is zero
483  if (SettingValueLine[Idx] == '\0')
484  {
485  return 0;
486  }
487  }
488 
489  // Count the characters up until the EOL
490  for (ValueSize=0; Idx<LineLength; Idx++)
491  {
492  if (SettingValueLine[Idx] == '\0')
493  {
494  break;
495  }
496 
497  // Increment the count
498  ValueSize++;
499  }
500 
501  // Add one for the NULL-terminator
502  ValueSize++;
503 
504  return ValueSize;
505 }
unsigned int ULONG
Definition: retypes.h:1

Referenced by IniParseFile().

◆ IniIsCommentLine()

BOOLEAN IniIsCommentLine ( PCHAR  LineOfText,
ULONG  TextLength 
)

Definition at line 267 of file parse.c.

268 {
269  ULONG Idx;
270 
271  // Check the first character (skipping whitespace)
272  // and make sure that it is an opening bracket
273  for (Idx=0; Idx<TextLength; Idx++)
274  {
275  if ((LineOfText[Idx] == ' ') ||
276  (LineOfText[Idx] == '\t'))
277  {
278  continue;
279  }
280  else if (LineOfText[Idx] == INI_FILE_COMMENT_CHAR)
281  {
282  return TRUE;
283  }
284  else
285  {
286  break;
287  }
288  }
289 
290  return FALSE;
291 }
#define TRUE
Definition: types.h:120
#define INI_FILE_COMMENT_CHAR
Definition: inifile.h:22
unsigned int ULONG
Definition: retypes.h:1

Referenced by IniParseFile().

◆ IniIsLineEmpty()

BOOLEAN IniIsLineEmpty ( PCHAR  LineOfText,
ULONG  TextLength 
)

Definition at line 244 of file parse.c.

245 {
246  ULONG Idx;
247 
248  // Check for text (skipping whitespace)
249  for (Idx=0; Idx<TextLength; Idx++)
250  {
251  if ((LineOfText[Idx] == ' ') ||
252  (LineOfText[Idx] == '\t') ||
253  (LineOfText[Idx] == '\n') ||
254  (LineOfText[Idx] == '\r'))
255  {
256  continue;
257  }
258  else
259  {
260  return FALSE;
261  }
262  }
263 
264  return TRUE;
265 }
#define TRUE
Definition: types.h:120
unsigned int ULONG
Definition: retypes.h:1

Referenced by IniParseFile().

◆ IniIsSectionName()

BOOLEAN IniIsSectionName ( PCHAR  LineOfText,
ULONG  TextLength 
)

Definition at line 293 of file parse.c.

294 {
295  ULONG Idx;
296 
297  // Check the first character (skipping whitespace)
298  // and make sure that it is an opening bracket
299  for (Idx=0; Idx<TextLength; Idx++)
300  {
301  if ((LineOfText[Idx] == ' ') ||
302  (LineOfText[Idx] == '\t'))
303  {
304  continue;
305  }
306  else if (LineOfText[Idx] == '[')
307  {
308  return TRUE;
309  }
310  else
311  {
312  break;
313  }
314  }
315 
316  return FALSE;
317 }
#define TRUE
Definition: types.h:120
unsigned int ULONG
Definition: retypes.h:1

Referenced by IniParseFile().

◆ IniIsSetting()

BOOLEAN IniIsSetting ( PCHAR  LineOfText,
ULONG  TextLength 
)

Definition at line 400 of file parse.c.

401 {
402  ULONG Idx;
403 
404  // Basically just check for an '=' equals sign
405  for (Idx=0; Idx<TextLength; Idx++)
406  {
407  if (LineOfText[Idx] == '=')
408  {
409  return TRUE;
410  }
411  }
412 
413  return FALSE;
414 }
#define TRUE
Definition: types.h:120
unsigned int ULONG
Definition: retypes.h:1

Referenced by IniParseFile().

◆ IniModifySettingValue()

BOOLEAN IniModifySettingValue ( ULONG_PTR  SectionId,
PCSTR  SettingName,
PCSTR  SettingValue 
)

Definition at line 293 of file inifile.c.

294 {
295  PINI_SECTION Section = (PINI_SECTION)SectionId;
296  PINI_SECTION_ITEM SectionItem;
297  PCHAR NewItemValue;
298 
299  // Loop through each section item and find the one we want
300  SectionItem = CONTAINING_RECORD(Section->SectionItemList.Flink, INI_SECTION_ITEM, ListEntry);
301  while (&SectionItem->ListEntry != &Section->SectionItemList)
302  {
303  // Check to see if this is the setting we want
304  if (_stricmp(SectionItem->ItemName, SettingName) == 0)
305  {
306  break;
307  }
308 
309  // Nope, keep going
310  // Get the next section item in the list
311  SectionItem = CONTAINING_RECORD(SectionItem->ListEntry.Flink, INI_SECTION_ITEM, ListEntry);
312  }
313  // If the section item does not exist, create it
314  if (&SectionItem->ListEntry == &Section->SectionItemList)
315  {
316  return IniAddSettingValueToSection(SectionId, SettingName, SettingValue);
317  }
318 
319  // Reallocate the new setting value buffer
320  NewItemValue = FrLdrTempAlloc(strlen(SettingValue) + 1, TAG_INI_VALUE);
321  if (!NewItemValue)
322  {
323  // We failed, bail out
324  return FALSE;
325  }
326  FrLdrTempFree(SectionItem->ItemValue, TAG_INI_VALUE);
327  SectionItem->ItemValue = NewItemValue;
328 
329  strcpy(SectionItem->ItemValue, SettingValue);
330 
331  return TRUE;
332 }
signed char * PCHAR
Definition: retypes.h:7
PCHAR ItemValue
Definition: inifile.h:37
#define TRUE
Definition: types.h:120
#define TAG_INI_VALUE
Definition: inifile.h:28
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LIST_ENTRY ListEntry
Definition: inifile.h:35
#define _stricmp
Definition: cat.c:22
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
PCHAR ItemName
Definition: inifile.h:36
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
BOOLEAN IniAddSettingValueToSection(ULONG_PTR SectionId, PCSTR SettingName, PCSTR SettingValue)
Definition: inifile.c:252
LIST_ENTRY SectionItemList
Definition: inifile.h:51
struct INI_SECTION * PINI_SECTION
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186

Referenced by EditCustomBootReactOS(), and InitOperatingSystemList().

◆ IniOpenSection()

BOOLEAN IniOpenSection ( PCSTR  SectionName,
ULONG_PTR SectionId 
)

Definition at line 25 of file inifile.c.

26 {
27  PINI_SECTION Section;
28 
29  TRACE("IniOpenSection() SectionName = %s\n", SectionName);
30 
31  // Loop through each section and find the one they want
33  while (&Section->ListEntry != &IniFileSectionListHead)
34  {
35  // Compare against the section name
36  if (_stricmp(SectionName, Section->SectionName) == 0)
37  {
38  // We found it
39  if (SectionId)
40  *SectionId = (ULONG_PTR)Section;
41  TRACE("IniOpenSection() Found it! SectionId = 0x%x\n", SectionId);
42  return TRUE;
43  }
44 
45  // Get the next section in the list
46  Section = CONTAINING_RECORD(Section->ListEntry.Flink, INI_SECTION, ListEntry);
47  }
48 
49  TRACE("IniOpenSection() Section not found.\n");
50 
51  return FALSE;
52 }
#define TRUE
Definition: types.h:120
LIST_ENTRY ListEntry
Definition: inifile.h:48
#define _stricmp
Definition: cat.c:22
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define TRACE(s)
Definition: solgame.cpp:4
LIST_ENTRY IniFileSectionListHead
Definition: parse.c:25
PCHAR SectionName
Definition: inifile.h:49
#define ULONG_PTR
Definition: config.h:101

Referenced by InitOperatingSystemList(), RunLoader(), and UiInitialize().

◆ IniParseFile()

BOOLEAN IniParseFile ( PCHAR  IniFileData,
ULONG  IniFileSize 
)

Definition at line 31 of file parse.c.

32 {
33  ULONG CurrentOffset;
34  ULONG CurrentLineNumber;
35  PCHAR IniFileLine;
36  ULONG IniFileLineSize;
37  ULONG LineLength;
38  PINI_SECTION CurrentSection = NULL;
39  PINI_SECTION_ITEM CurrentItem = NULL;
40 
41  TRACE("IniParseFile() IniFileSize: %d\n", IniFileSize);
42 
44  {
47  }
48 
49  // Start with an 80-byte buffer
50  IniFileLineSize = 80;
51  IniFileLine = FrLdrTempAlloc(IniFileLineSize, TAG_INI_FILE);
52  if (!IniFileLine)
53  {
54  return FALSE;
55  }
56 
57  // Loop through each line and parse it
58  CurrentLineNumber = 0;
59  CurrentOffset = 0;
60  while (CurrentOffset < IniFileSize)
61  {
62  // First check the line size and increase our buffer if necessary
63  if (IniFileLineSize < IniGetNextLineSize(IniFileData, IniFileSize, CurrentOffset))
64  {
65  IniFileLineSize = IniGetNextLineSize(IniFileData, IniFileSize, CurrentOffset);
66  FrLdrTempFree(IniFileLine, TAG_INI_FILE);
67  IniFileLine = FrLdrTempAlloc(IniFileLineSize, TAG_INI_FILE);
68  if (!IniFileLine)
69  {
70  return FALSE;
71  }
72  }
73 
74  // Get the line of data
75  CurrentOffset = IniGetNextLine(IniFileData, IniFileSize, IniFileLine, IniFileLineSize, CurrentOffset);
76  LineLength = (ULONG)strlen(IniFileLine);
77 
78  // If it is a blank line or a comment then skip it
79  if (IniIsLineEmpty(IniFileLine, LineLength) || IniIsCommentLine(IniFileLine, LineLength))
80  {
81  CurrentLineNumber++;
82  continue;
83  }
84 
85  // Check if it is a new section
86  if (IniIsSectionName(IniFileLine, LineLength))
87  {
88  // Allocate a new section structure
89  CurrentSection = FrLdrTempAlloc(sizeof(INI_SECTION), TAG_INI_SECTION);
90  if (!CurrentSection)
91  {
92  FrLdrTempFree(IniFileLine, TAG_INI_FILE);
93  return FALSE;
94  }
95 
96  RtlZeroMemory(CurrentSection, sizeof(INI_SECTION));
97 
98  // Allocate the section name buffer
99  CurrentSection->SectionName = FrLdrTempAlloc(IniGetSectionNameSize(IniFileLine, LineLength), TAG_INI_NAME);
100  if (!CurrentSection->SectionName)
101  {
102  FrLdrTempFree(CurrentSection, TAG_INI_FILE);
103  FrLdrTempFree(IniFileLine, TAG_INI_FILE);
104  return FALSE;
105  }
106 
107  // Get the section name
108  IniExtractSectionName(CurrentSection->SectionName, IniFileLine, LineLength);
109  InitializeListHead(&CurrentSection->SectionItemList);
110 
111  // Add it to the section list head
113  InsertTailList(&IniFileSectionListHead, &CurrentSection->ListEntry);
114 
115  CurrentLineNumber++;
116  continue;
117  }
118 
119  // Check if it is a setting
120  if (IniIsSetting(IniFileLine, LineLength))
121  {
122  // First check to make sure we're inside a [section]
123  if (CurrentSection == NULL)
124  {
125  printf("Error: freeldr.ini:%lu: Setting '%s' found outside of a [section].\n", CurrentLineNumber, IniFileLine);
126  printf("Press any key to continue...\n");
127  MachConsGetCh();
128  CurrentLineNumber++;
129  continue;
130  }
131 
132  // Allocate a new item structure
133  CurrentItem = FrLdrTempAlloc(sizeof(INI_SECTION_ITEM), TAG_INI_SECTION_ITEM);
134  if (!CurrentItem)
135  {
136  FrLdrTempFree(IniFileLine, TAG_INI_FILE);
137  return FALSE;
138  }
139 
140  RtlZeroMemory(CurrentItem, sizeof(INI_SECTION_ITEM));
141 
142  // Allocate the setting name buffer
143  CurrentItem->ItemName = FrLdrTempAlloc(IniGetSettingNameSize(IniFileLine, LineLength), TAG_INI_NAME);
144  if (!CurrentItem->ItemName)
145  {
146  FrLdrTempFree(CurrentItem, TAG_INI_SECTION_ITEM);
147  FrLdrTempFree(IniFileLine, TAG_INI_FILE);
148  return FALSE;
149  }
150 
151  // Allocate the setting value buffer
152  CurrentItem->ItemValue = FrLdrTempAlloc(IniGetSettingValueSize(IniFileLine, LineLength), TAG_INI_VALUE);
153  if (!CurrentItem->ItemValue)
154  {
155  FrLdrTempFree(CurrentItem->ItemName, TAG_INI_NAME);
156  FrLdrTempFree(CurrentItem, TAG_INI_SECTION_ITEM);
157  FrLdrTempFree(IniFileLine, TAG_INI_FILE);
158  return FALSE;
159  }
160 
161  // Get the section name
162  IniExtractSettingName(CurrentItem->ItemName, IniFileLine, LineLength);
163  IniExtractSettingValue(CurrentItem->ItemValue, IniFileLine, LineLength);
164 
165  // Add it to the current section
167  CurrentSection->SectionItemCount++;
168  InsertTailList(&CurrentSection->SectionItemList, &CurrentItem->ListEntry);
169 
170  CurrentLineNumber++;
171  continue;
172  }
173 
174  CurrentLineNumber++;
175  }
176 
177  FrLdrTempFree(IniFileLine, TAG_INI_FILE);
178 
179  TRACE("Parsed %d sections and %d settings.\n", IniFileSectionCount, IniFileSettingCount);
180  TRACE("IniParseFile() done.\n");
181 
182  return TRUE;
183 }
signed char * PCHAR
Definition: retypes.h:7
PCHAR ItemValue
Definition: inifile.h:37
#define TRUE
Definition: types.h:120
#define MachConsGetCh()
Definition: machine.h:90
#define TAG_INI_VALUE
Definition: inifile.h:28
#define TAG_INI_NAME
Definition: inifile.h:27
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
VOID IniExtractSettingValue(PCHAR SettingValue, PCHAR SettingValueLine, ULONG LineLength)
Definition: parse.c:544
LIST_ENTRY ListEntry
Definition: inifile.h:48
#define InsertTailList(ListHead, Entry)
LIST_ENTRY ListEntry
Definition: inifile.h:35
BOOLEAN IniIsSectionName(PCHAR LineOfText, ULONG TextLength)
Definition: parse.c:293
BOOLEAN IniFileSectionInitialized
Definition: parse.c:26
ULONG IniFileSettingCount
Definition: parse.c:28
VOID IniExtractSectionName(PCHAR SectionName, PCHAR SectionNameLine, ULONG LineLength)
Definition: parse.c:360
ULONG IniGetNextLine(PCHAR IniFileData, ULONG IniFileSize, PCHAR Buffer, ULONG BufferSize, ULONG CurrentOffset)
Definition: parse.c:210
ULONG IniGetSettingValueSize(PCHAR SettingValueLine, ULONG LineLength)
Definition: parse.c:454
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
PCHAR ItemName
Definition: inifile.h:36
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN IniIsLineEmpty(PCHAR LineOfText, ULONG TextLength)
Definition: parse.c:244
BOOLEAN IniIsCommentLine(PCHAR LineOfText, ULONG TextLength)
Definition: parse.c:267
ULONG SectionItemCount
Definition: inifile.h:50
#define TRACE(s)
Definition: solgame.cpp:4
LIST_ENTRY IniFileSectionListHead
Definition: parse.c:25
ULONG IniGetSectionNameSize(PCHAR SectionNameLine, ULONG LineLength)
Definition: parse.c:319
ULONG IniFileSectionCount
Definition: parse.c:27
#define TAG_INI_SECTION_ITEM
Definition: inifile.h:26
ULONG IniGetSettingNameSize(PCHAR SettingNameLine, ULONG LineLength)
Definition: parse.c:416
LIST_ENTRY SectionItemList
Definition: inifile.h:51
#define TAG_INI_FILE
Definition: inifile.h:24
ULONG IniGetNextLineSize(PCHAR IniFileData, ULONG IniFileSize, ULONG CurrentOffset)
Definition: parse.c:185
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PCHAR SectionName
Definition: inifile.h:49
VOID IniExtractSettingName(PCHAR SettingName, PCHAR SettingNameLine, ULONG LineLength)
Definition: parse.c:507
BOOLEAN IniIsSetting(PCHAR LineOfText, ULONG TextLength)
Definition: parse.c:400
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define TAG_INI_SECTION
Definition: inifile.h:25
#define printf
Definition: config.h:203
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186

Referenced by IniFileInitialize().

◆ IniReadSettingByName()

BOOLEAN IniReadSettingByName ( ULONG_PTR  SectionId,
PCSTR  SettingName,
PCHAR  Buffer,
ULONG  BufferSize 
)

Definition at line 147 of file inifile.c.

148 {
149  PINI_SECTION Section = (PINI_SECTION)SectionId;
150  PINI_SECTION_ITEM SectionItem;
151 
152  TRACE("IniReadSettingByName() SectionId = 0x%x\n", SectionId);
153 
154  // Loop through each section item and find the one they want
155  SectionItem = CONTAINING_RECORD(Section->SectionItemList.Flink, INI_SECTION_ITEM, ListEntry);
156  while (&SectionItem->ListEntry != &Section->SectionItemList)
157  {
158  // Check to see if this is the setting they want
159  if (_stricmp(SettingName, SectionItem->ItemName) == 0)
160  {
161  TRACE("IniReadSettingByName() Setting \'%s\' found.\n", SettingName);
162  TRACE("IniReadSettingByName() Setting value = %s\n", SectionItem->ItemValue);
163 
164  strncpy(Buffer, SectionItem->ItemValue, BufferSize - 1);
165  Buffer[BufferSize - 1] = '\0';
166 
167  return TRUE;
168  }
169 
170  // Get the next section item in the list
171  SectionItem = CONTAINING_RECORD(SectionItem->ListEntry.Flink, INI_SECTION_ITEM, ListEntry);
172  }
173 
174  WARN("IniReadSettingByName() Setting \'%s\' not found.\n", SettingName);
175 
176  return FALSE;
177 }
PCHAR ItemValue
Definition: inifile.h:37
#define TRUE
Definition: types.h:120
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define WARN(fmt,...)
Definition: debug.h:111
LIST_ENTRY ListEntry
Definition: inifile.h:35
#define _stricmp
Definition: cat.c:22
PCHAR ItemName
Definition: inifile.h:36
Definition: bufpool.h:45
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define TRACE(s)
Definition: solgame.cpp:4
#define BufferSize
Definition: classpnp.h:419
LIST_ENTRY SectionItemList
Definition: inifile.h:51
struct INI_SECTION * PINI_SECTION

Referenced by EditCustomBootReactOS(), GetTimeOut(), InitOperatingSystemList(), LoadOperatingSystem(), and UiInitialize().

◆ IniReadSettingByNumber()

BOOLEAN IniReadSettingByNumber ( ULONG_PTR  SectionId,
ULONG  SettingNumber,
PCHAR  SettingName,
ULONG  NameSize,
PCHAR  SettingValue,
ULONG  ValueSize 
)

Definition at line 114 of file inifile.c.

115 {
116  PINI_SECTION_ITEM SectionItem;
117  TRACE(".001 NameSize = %d ValueSize = %d\n", NameSize, ValueSize);
118 
119  TRACE("IniReadSettingByNumber() SectionId = 0x%x\n", SectionId);
120 
121  // Retrieve requested setting
122  SectionItem = IniGetSettingByNumber(SectionId, SettingNumber);
123  if (!SectionItem)
124  {
125  TRACE("IniReadSettingByNumber() Setting number %d not found.\n", SettingNumber);
126  return FALSE;
127  }
128 
129  TRACE("IniReadSettingByNumber() Setting number %d found.\n", SettingNumber);
130  TRACE("IniReadSettingByNumber() Setting name = %s\n", SectionItem->ItemName);
131  TRACE("IniReadSettingByNumber() Setting value = %s\n", SectionItem->ItemValue);
132 
133  TRACE("1 NameSize = %d ValueSize = %d\n", NameSize, ValueSize);
134  TRACE("2 NameSize = %d ValueSize = %d\n", NameSize, ValueSize);
135  strncpy(SettingName, SectionItem->ItemName, NameSize - 1);
136  SettingName[NameSize - 1] = '\0';
137  TRACE("3 NameSize = %d ValueSize = %d\n", NameSize, ValueSize);
138  strncpy(SettingValue, SectionItem->ItemValue, ValueSize - 1);
139  SettingValue[ValueSize - 1] = '\0';
140  TRACE("4 NameSize = %d ValueSize = %d\n", NameSize, ValueSize);
141  DbgDumpBuffer(DPRINT_INIFILE, SettingName, NameSize);
142  DbgDumpBuffer(DPRINT_INIFILE, SettingValue, ValueSize);
143 
144  return TRUE;
145 }
PCHAR ItemValue
Definition: inifile.h:37
#define TRUE
Definition: types.h:120
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
PCHAR ItemName
Definition: inifile.h:36
#define DPRINT_INIFILE
Definition: debug.h:27
#define TRACE(s)
Definition: solgame.cpp:4
PINI_SECTION_ITEM IniGetSettingByNumber(ULONG_PTR SectionId, ULONG SettingNumber)
Definition: inifile.c:64
#define DbgDumpBuffer(mask, buf, len)
Definition: debug.h:118

Referenced by BuildArgvForOsLoader(), InitOperatingSystemList(), and UiShowMessageBoxesInSection().

Variable Documentation

◆ IniFileSectionCount

ULONG IniFileSectionCount

Definition at line 27 of file parse.c.

Referenced by IniAddSection(), and IniParseFile().

◆ IniFileSectionInitialized

BOOLEAN IniFileSectionInitialized

Definition at line 26 of file parse.c.

Referenced by IniParseFile().

◆ IniFileSectionListHead

LIST_ENTRY IniFileSectionListHead

Definition at line 25 of file parse.c.

Referenced by IniAddSection(), IniCleanup(), IniOpenSection(), and IniParseFile().

◆ IniFileSettingCount

ULONG IniFileSettingCount

Definition at line 28 of file parse.c.

Referenced by IniParseFile().