ReactOS 0.4.15-dev-7660-g0086d05
cmdline.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Boot Loader
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: boot/freeldr/freeldr/cmdline.c
5 * PURPOSE: FreeLDR Command Line Parsing
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include <freeldr.h>
12
13/* GLOBALS ********************************************************************/
14
15typedef struct tagCMDLINEINFO
16{
21
25
26/* FUNCTIONS ******************************************************************/
27
28VOID
30{
31 PCHAR End, Setting;
33
34 /* Set defaults */
38
39 /*
40 * Get debug string, in the following format:
41 * "debug=option1=XXX;option2=YYY;..."
42 * and translate it into the format:
43 * "OPTION1=XXX OPTION2=YYY ..."
44 */
45 Setting = strstr(CmdLine, "debug=");
46 if (Setting)
47 {
48 /* Check if there are more command-line parameters following */
49 Setting += sizeof("debug=") - sizeof(ANSI_NULL);
50 End = strstr(Setting, " ");
51 Length = (End ? (End - Setting) : strlen(Setting));
52
53 /* Copy the debug string and upcase it */
56
57 /* Replace all separators ';' by spaces */
58 Setting = DebugString;
59 while (*Setting)
60 {
61 if (*Setting == ';') *Setting = ' ';
62 Setting++;
63 }
64
66 }
67
68 /* Get timeout */
69 Setting = strstr(CmdLine, "timeout=");
70 if (Setting)
71 {
72 CmdLineInfo.TimeOut = atoi(Setting +
73 sizeof("timeout=") - sizeof(ANSI_NULL));
74 }
75
76 /* Get default OS */
77 Setting = strstr(CmdLine, "defaultos=");
78 if (Setting)
79 {
80 /* Check if there are more command-line parameters following */
81 Setting += sizeof("defaultos=") - sizeof(ANSI_NULL);
82 End = strstr(Setting, " ");
83 Length = (End ? (End - Setting) : strlen(Setting));
84
85 /* Copy the default OS */
86 RtlStringCbCopyNA(DefaultOs, sizeof(DefaultOs), Setting, Length);
88 }
89
90 /* Get ramdisk base address */
91 Setting = strstr(CmdLine, "rdbase=");
92 if (Setting)
93 {
95 (PVOID)(ULONG_PTR)strtoull(Setting +
96 sizeof("rdbase=") - sizeof(ANSI_NULL),
97 NULL, 0);
98 }
99
100 /* Get ramdisk size */
101 Setting = strstr(CmdLine, "rdsize=");
102 if (Setting)
103 {
104 gInitRamDiskSize = strtoul(Setting +
105 sizeof("rdsize=") - sizeof(ANSI_NULL),
106 NULL, 0);
107 }
108
109 /* Get ramdisk offset */
110 Setting = strstr(CmdLine, "rdoffset=");
111 if (Setting)
112 {
113 Offset = strtoul(Setting +
114 sizeof("rdoffset=") - sizeof(ANSI_NULL),
115 NULL, 0);
116 }
117
118 /* Fix it up */
120}
121
122PCSTR
124{
126}
127
128PCSTR
130{
131 return CmdLineInfo.DefaultOs;
132}
133
134LONG
136{
137 return CmdLineInfo.TimeOut;
138}
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
struct tagCMDLINEINFO * PCMDLINEINFO
LONG CmdLineGetTimeOut(VOID)
Definition: cmdline.c:135
struct tagCMDLINEINFO CMDLINEINFO
PCSTR CmdLineGetDefaultOS(VOID)
Definition: cmdline.c:129
CCHAR DebugString[256]
Definition: cmdline.c:22
VOID CmdLineParse(IN PCSTR CmdLine)
Definition: cmdline.c:29
PCSTR CmdLineGetDebugString(VOID)
Definition: cmdline.c:123
CMDLINEINFO CmdLineInfo
Definition: cmdline.c:24
CCHAR DefaultOs[256]
Definition: cmdline.c:23
#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
long LONG
Definition: pedump.c:60
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define strtoull
Definition: stabs.c:58
LONG TimeOut
Definition: cmdline.c:19
PCSTR DefaultOs
Definition: cmdline.c:18
PCSTR DebugString
Definition: cmdline.c:17
void * PVOID
Definition: typedefs.h:50
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
char CCHAR
Definition: typedefs.h:51
char * PCHAR
Definition: typedefs.h:51