ReactOS 0.4.15-dev-8100-g1887773
settings.c File Reference
#include <freeldr.h>
Include dependency graph for settings.c:

Go to the source code of this file.

Functions

static VOID CmdLineParse (_In_ PCSTR CmdLine)
 
VOID LoadSettings (_In_opt_ PCSTR CmdLine)
 

Variables

static CCHAR DebugString [256]
 
static CCHAR DefaultOs [256]
 
BOOTMGRINFO BootMgrInfo = {0}
 

Function Documentation

◆ CmdLineParse()

static VOID CmdLineParse ( _In_ PCSTR  CmdLine)
static

Definition at line 23 of file settings.c.

25{
26 PCHAR End, Setting;
28
29 /* Set defaults */
33 // BootMgrInfo.FrLdrSection = 0;
34
35 /*
36 * Get the debug string, in the following format:
37 * "debug=option1=XXX;option2=YYY;..."
38 * and translate it into the format:
39 * "OPTION1=XXX OPTION2=YYY ..."
40 */
41 Setting = strstr(CmdLine, "debug=");
42 if (Setting)
43 {
44 /* Check if there are more command-line parameters following */
45 Setting += sizeof("debug=") - sizeof(ANSI_NULL);
46 End = strstr(Setting, " ");
47 Length = (End ? (End - Setting) : strlen(Setting));
48
49 /* Copy the debug string and upcase it */
52
53 /* Replace all separators ';' by spaces */
54 Setting = DebugString;
55 while (*Setting)
56 {
57 if (*Setting == ';') *Setting = ' ';
58 Setting++;
59 }
60
62 }
63
64 /* Get the timeout */
65 Setting = strstr(CmdLine, "timeout=");
66 if (Setting)
67 {
68 BootMgrInfo.TimeOut = atoi(Setting +
69 sizeof("timeout=") - sizeof(ANSI_NULL));
70 }
71
72 /* Get the default OS */
73 Setting = strstr(CmdLine, "defaultos=");
74 if (Setting)
75 {
76 /* Check if there are more command-line parameters following */
77 Setting += sizeof("defaultos=") - sizeof(ANSI_NULL);
78 End = strstr(Setting, " ");
79 Length = (End ? (End - Setting) : strlen(Setting));
80
81 /* Copy the default OS */
82 RtlStringCbCopyNA(DefaultOs, sizeof(DefaultOs), Setting, Length);
84 }
85
86 /* Get the ramdisk base address */
87 Setting = strstr(CmdLine, "rdbase=");
88 if (Setting)
89 {
91 (PVOID)(ULONG_PTR)strtoull(Setting +
92 sizeof("rdbase=") - sizeof(ANSI_NULL),
93 NULL, 0);
94 }
95
96 /* Get the ramdisk size */
97 Setting = strstr(CmdLine, "rdsize=");
98 if (Setting)
99 {
100 gInitRamDiskSize = strtoul(Setting +
101 sizeof("rdsize=") - sizeof(ANSI_NULL),
102 NULL, 0);
103 }
104
105 /* Get the ramdisk offset */
106 Setting = strstr(CmdLine, "rdoffset=");
107 if (Setting)
108 {
109 Offset = strtoul(Setting +
110 sizeof("rdoffset=") - sizeof(ANSI_NULL),
111 NULL, 0);
112 }
113
114 /* Fix it up */
116}
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PVOID gInitRamDiskBase
Definition: ramdisk.c:17
ULONG gInitRamDiskSize
Definition: ramdisk.c:18
static CCHAR DebugString[256]
Definition: settings.c:16
BOOTMGRINFO BootMgrInfo
Definition: settings.c:18
static CCHAR DefaultOs[256]
Definition: settings.c:17
#define NULL
Definition: types.h:112
static const WCHAR CmdLine[]
Definition: install.c:48
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define ANSI_NULL
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTRSAFEAPI RtlStringCbCopyNA(_Out_writes_bytes_(cbDest) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCSTR pszSrc, _In_ size_t cbToCopy)
Definition: ntstrsafe.h:395
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define strtoull
Definition: stabs.c:58
PCSTR DefaultOs
Definition: settings.h:13
LONG TimeOut
Definition: settings.h:14
PCSTR DebugString
Definition: settings.h:12
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
char * PCHAR
Definition: typedefs.h:51

Referenced by LoadSettings().

◆ LoadSettings()

VOID LoadSettings ( _In_opt_ PCSTR  CmdLine)

Definition at line 119 of file settings.c.

121{
122 /* Pre-initialization: The settings originate from the command-line.
123 * Main initialization: Overwrite them if needed with those from freeldr.ini */
124 if (CmdLine)
125 {
127 return;
128 }
130 {
131 // ERR("LoadSettings() called but no freeldr.ini\n");
132 return;
133 }
134
135 /* Open the [FreeLoader] section and load the settings */
136 if ((BootMgrInfo.FrLdrSection == 0) &&
137 !IniOpenSection("FreeLoader", &BootMgrInfo.FrLdrSection))
138 {
139 UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini");
140 return;
141 }
142
143 /* Get the debug string. Always override it with the one from freeldr.ini */
145 DebugString, sizeof(DebugString)))
146 {
148 }
149
150 /* Get the timeout. Keep the existing one if it is valid,
151 * otherwise retrieve it from freeldr.ini */
152 if (BootMgrInfo.TimeOut < 0)
153 {
154 CHAR TimeOutText[20];
155 BootMgrInfo.TimeOut = -1;
157 TimeOutText, sizeof(TimeOutText)))
158 {
159 BootMgrInfo.TimeOut = atoi(TimeOutText);
160 }
161 }
162
163 /* Get the default OS */
165 {
167 DefaultOs, sizeof(DefaultOs)))
168 {
170 }
171 }
172}
VOID UiMessageBoxCritical(_In_ PCSTR MessageText)
Definition: ui.c:372
static VOID CmdLineParse(_In_ PCSTR CmdLine)
Definition: settings.c:23
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
LIST_ENTRY IniFileSectionListHead
Definition: parse.c:25
BOOLEAN IniReadSettingByName(ULONG_PTR SectionId, PCSTR SettingName, PCHAR Buffer, ULONG BufferSize)
Definition: inifile.c:149
BOOLEAN IniOpenSection(PCSTR SectionName, ULONG_PTR *SectionId)
Definition: inifile.c:25
ULONG_PTR FrLdrSection
Definition: settings.h:15
char CHAR
Definition: xmlstorage.h:175

Variable Documentation

◆ BootMgrInfo

◆ DebugString

◆ DefaultOs

CCHAR DefaultOs[256]
static

Definition at line 17 of file settings.c.

Referenced by CmdLineParse(), and LoadSettings().