ReactOS  0.4.14-dev-554-g2f8d847
cmdline.c File Reference
#include <freeldr.h>
Include dependency graph for cmdline.c:

Go to the source code of this file.

Classes

struct  tagCMDLINEINFO
 

Typedefs

typedef struct tagCMDLINEINFO CMDLINEINFO
 
typedef struct tagCMDLINEINFOPCMDLINEINFO
 

Functions

VOID CmdLineParse (IN PCSTR CmdLine)
 
PCSTR CmdLineGetDebugString (VOID)
 
PCSTR CmdLineGetDefaultOS (VOID)
 
LONG CmdLineGetTimeOut (VOID)
 

Variables

CCHAR DebugString [256]
 
CCHAR DefaultOs [256]
 
CMDLINEINFO CmdLineInfo
 

Typedef Documentation

◆ CMDLINEINFO

◆ PCMDLINEINFO

Function Documentation

◆ CmdLineGetDebugString()

PCSTR CmdLineGetDebugString ( VOID  )

Definition at line 123 of file cmdline.c.

124 {
125  return CmdLineInfo.DebugString;
126 }
CMDLINEINFO CmdLineInfo
Definition: cmdline.c:24
PCSTR DebugString
Definition: cmdline.c:17

◆ CmdLineGetDefaultOS()

PCSTR CmdLineGetDefaultOS ( VOID  )

Definition at line 129 of file cmdline.c.

130 {
131  return CmdLineInfo.DefaultOs;
132 }
CMDLINEINFO CmdLineInfo
Definition: cmdline.c:24
PCSTR DefaultOs
Definition: cmdline.c:18

Referenced by InitOperatingSystemList().

◆ CmdLineGetTimeOut()

LONG CmdLineGetTimeOut ( VOID  )

Definition at line 135 of file cmdline.c.

136 {
137  return CmdLineInfo.TimeOut;
138 }
CMDLINEINFO CmdLineInfo
Definition: cmdline.c:24
LONG TimeOut
Definition: cmdline.c:19

Referenced by GetTimeOut().

◆ CmdLineParse()

VOID CmdLineParse ( IN PCSTR  CmdLine)

Definition at line 29 of file cmdline.c.

30 {
31  PCHAR End, Setting;
32  ULONG_PTR Length, Offset = 0;
33 
34  /* Set defaults */
37  CmdLineInfo.TimeOut = -1;
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 */
54  RtlStringCbCopyNA(DebugString, sizeof(DebugString), Setting, Length);
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 }
signed char * PCHAR
Definition: retypes.h:7
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
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
uint32_t ULONG_PTR
Definition: typedefs.h:63
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define ANSI_NULL
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
CMDLINEINFO CmdLineInfo
Definition: cmdline.c:24
#define strtoull
Definition: stabs.c:72
LONG TimeOut
Definition: cmdline.c:19
ULONG gInitRamDiskSize
Definition: ramdisk.c:17
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
CHAR CmdLine[MAX_PATH]
Definition: mach.c:34
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
CCHAR DefaultOs[256]
Definition: cmdline.c:23
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
CCHAR DebugString[256]
Definition: cmdline.c:22
PCSTR DefaultOs
Definition: cmdline.c:18
PVOID gInitRamDiskBase
Definition: ramdisk.c:16
PCSTR DebugString
Definition: cmdline.c:17

Referenced by BootMain().

Variable Documentation

◆ CmdLineInfo

CMDLINEINFO CmdLineInfo

◆ DebugString

◆ DefaultOs

CCHAR DefaultOs[256]

Definition at line 23 of file cmdline.c.

Referenced by CmdLineParse().