INI Parser #6
@@ -20,5 +20,8 @@
|
||||
}
|
||||
},
|
||||
"terminal.integrated.defaultProfile.linux": "xtchain",
|
||||
"files.associations": {
|
||||
"globals.h": "c"
|
||||
},
|
||||
}
|
||||
}
|
39
sdk/xtdk/bmtypes.h
Normal file
39
sdk/xtdk/bmtypes.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* PROJECT: ExectOS
|
||||
* COPYRIGHT: See COPYING.md in the top level directory
|
||||
* FILE: sdk/xtdk/bmtypes.h
|
||||
* DESCRIPTION: XT Boot Manager structures definitions
|
||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
*/
|
||||
|
||||
#ifndef __XTDK_BMTYPES_H
|
||||
#define __XTDK_BMTYPES_H
|
||||
|
||||
#include <xttypes.h>
|
||||
|
||||
typedef struct _XTBL_INI_SECTION
|
||||
{
|
||||
LIST_ENTRY Flink;
|
||||
LIST_ENTRY Options;
|
||||
PWCHAR SectionName;
|
||||
} XTBL_INI_SECTION, *PXTBL_INI_SECTION;
|
||||
|
||||
typedef struct _XTBL_INI_OPTION
|
||||
{
|
||||
LIST_ENTRY Flink;
|
||||
PWCHAR Name;
|
||||
PWCHAR Value;
|
||||
} XTBL_INI_OPTION, *PXTBL_INI_OPTION;
|
||||
|
||||
/* XTLDR configuration data */
|
||||
typedef struct _XTBM_CONFIGURATION
|
||||
{
|
||||
PWCHAR Default;
|
||||
PWCHAR Debug;
|
||||
BOOLEAN Shell;
|
||||
PWCHAR Theme;
|
||||
ULONG Timeout;
|
||||
PWCHAR Tune;
|
||||
} XTBM_CONFIGURATION, *PXTBM_CONFIGURATION;
|
||||
|
||||
#endif /* __XTDK_BMTYPES_H */
|
@@ -4,10 +4,97 @@
|
||||
* FILE: xtldr/config.c
|
||||
* DESCRIPTION: XT Boot Loader Configuration
|
||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
* Jozef Nagy <schkwve@gmail.com>
|
||||
*/
|
||||
|
||||
#include <xtldr.h>
|
||||
|
||||
/**
|
||||
* Parses configuration INI file contents.
|
||||
*
|
||||
* @param FileContents
|
||||
* Supplies a pointer to a wide string containing contents of the configuration file.
|
||||
*
|
||||
* @param Sections
|
||||
* Supplies a pointer to a linked list which will be written by this routine.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpConfigParseIniFile(IN PWCHAR FileContents,
|
||||
OUT PLIST_ENTRY SectionsHead)
|
||||
{
|
||||
PWCHAR CurrentSectionName, Key, Value;
|
||||
PWCHAR Input;
|
||||
UINT SectionLength, KeyLength, ValueLength;
|
||||
|
||||
Input = FileContents;
|
||||
CurrentSectionName = L"None";
|
||||
|
||||
while(*Input != 0)
|
||||
{
|
||||
SectionLength = 0;
|
||||
KeyLength = 0;
|
||||
ValueLength = 0;
|
||||
|
||||
if(*Input == ';' || *Input == '#')
|
||||
{
|
||||
/* Skip comments */
|
||||
while(*Input != 0 && *Input != '\n')
|
||||
{
|
||||
Input++;
|
||||
}
|
||||
}
|
||||
else if(*Input == '\n')
|
||||
{
|
||||
/* Skip newline */
|
||||
Input++;
|
||||
}
|
||||
else if(*Input == '[')
|
||||
{
|
||||
/* Get the section name */
|
||||
Input++;
|
||||
CurrentSectionName = Input;
|
||||
|
||||
/* Skip to the next line */
|
||||
while(*Input != ']' && *Input != 0 && *Input != '\n')
|
||||
{
|
||||
SectionLength++;
|
||||
Input++;
|
||||
}
|
||||
Input++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the length of key */
|
||||
while(*Input != '=' && *Input != 0 && *Input != '\n')
|
||||
{
|
||||
KeyLength++;
|
||||
Input++;
|
||||
}
|
||||
|
||||
/* Set key */
|
||||
Key = Input - KeyLength;
|
||||
Key[KeyLength] = 0;
|
||||
Input++;
|
||||
|
||||
/* Get the length of value */
|
||||
while(*Input != 0 && *Input != '\n')
|
||||
{
|
||||
Input++;
|
||||
ValueLength++;
|
||||
}
|
||||
|
||||
/* Set value */
|
||||
Value = Input - ValueLength;
|
||||
Value[ValueLength] = 0;
|
||||
Input++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses command line arguments and updates global configuration.
|
||||
|
@@ -134,6 +134,11 @@ BlpFindParentBlockDevice(IN PLIST_ENTRY BlockDevices,
|
||||
IN PEFI_BLOCK_DEVICE_DATA ChildNode,
|
||||
OUT PEFI_BLOCK_DEVICE_DATA ParentNode);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpConfigParseIniFile(IN PWCHAR FileContents,
|
||||
OUT PLIST_ENTRY SectionsHead);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpParseCommandLineOptions(VOID);
|
||||
|
@@ -11,7 +11,6 @@
|
||||
|
||||
#include <xtblapi.h>
|
||||
|
||||
|
||||
/* XT Boot Loader configuration data */
|
||||
EXTERN XTBL_CONFIGURATION BlpConfiguration;
|
||||
|
||||
|
@@ -33,6 +33,9 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle,
|
||||
EfiImageHandle = ImageHandle;
|
||||
EfiSystemTable = SystemTable;
|
||||
|
||||
/* Initialize UEFI console and early print XTLDR version */
|
||||
BlpConsoleInitialize();
|
||||
|
||||
/* Initialize XTLDR and early print XTLDR version */
|
||||
BlpInitializeEfiBootLoader();
|
||||
BlConsolePrint(L"XTLDR boot loader v%s\n", XTOS_VERSION);
|
||||
|
Reference in New Issue
Block a user