1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_GeckoArgs_h
6 #define mozilla_GeckoArgs_h
8 #include "mozilla/CmdLineAndEnvUtils.h"
9 #include "mozilla/Maybe.h"
22 struct CommandLineArg
{
23 Maybe
<T
> Get(int& aArgc
, char** aArgv
,
24 const CheckArgFlag aFlags
= CheckArgFlag::RemoveArg
);
26 const char* Name() { return sName
; };
28 void Put(std::vector
<std::string
>& aArgs
);
29 void Put(T aValue
, std::vector
<std::string
>& aArgs
);
38 inline Maybe
<const char*> CommandLineArg
<const char*>::Get(
39 int& aArgc
, char** aArgv
, const CheckArgFlag aFlags
) {
40 MOZ_ASSERT(aArgv
, "aArgv must be initialized before CheckArg()");
41 const char* rv
= nullptr;
42 if (ARG_FOUND
== CheckArg(aArgc
, aArgv
, sMatch
, &rv
, aFlags
)) {
49 inline Maybe
<bool> CommandLineArg
<bool>::Get(int& aArgc
, char** aArgv
,
50 const CheckArgFlag aFlags
) {
51 MOZ_ASSERT(aArgv
, "aArgv must be initialized before CheckArg()");
53 CheckArg(aArgc
, aArgv
, sMatch
, (const char**)nullptr, aFlags
)) {
60 inline Maybe
<uint64_t> CommandLineArg
<uint64_t>::Get(
61 int& aArgc
, char** aArgv
, const CheckArgFlag aFlags
) {
62 MOZ_ASSERT(aArgv
, "aArgv must be initialized before CheckArg()");
63 const char* rv
= nullptr;
64 if (ARG_FOUND
== CheckArg(aArgc
, aArgv
, sMatch
, &rv
, aFlags
)) {
66 char* endptr
= nullptr;
67 uint64_t conv
= std::strtoull(rv
, &endptr
, 10);
68 if (errno
== 0 && endptr
&& *endptr
== '\0') {
78 inline void CommandLineArg
<const char*>::Put(const char* aValue
,
79 std::vector
<std::string
>& aArgs
) {
80 aArgs
.push_back(Name());
81 aArgs
.push_back(aValue
);
85 inline void CommandLineArg
<bool>::Put(bool aValue
,
86 std::vector
<std::string
>& aArgs
) {
88 aArgs
.push_back(Name());
93 inline void CommandLineArg
<bool>::Put(std::vector
<std::string
>& aArgs
) {
98 inline void CommandLineArg
<uint64_t>::Put(uint64_t aValue
,
99 std::vector
<std::string
>& aArgs
) {
100 aArgs
.push_back(Name());
101 aArgs
.push_back(std::to_string(aValue
));
104 #if defined(__GNUC__)
105 # pragma GCC diagnostic push
106 # pragma GCC diagnostic ignored "-Wunused-variable"
109 static CommandLineArg
<const char*> sParentBuildID
{"-parentBuildID",
111 static CommandLineArg
<const char*> sAppDir
{"-appDir", "appdir"};
112 static CommandLineArg
<const char*> sGREOmni
{"-greomni", "greomni"};
113 static CommandLineArg
<const char*> sAppOmni
{"-appomni", "appomni"};
114 static CommandLineArg
<const char*> sProfile
{"-profile", "profile"};
116 static CommandLineArg
<uint64_t> sJsInitHandle
{"-jsInitHandle", "jsinithandle"};
117 static CommandLineArg
<uint64_t> sJsInitLen
{"-jsInitLen", "jsinitlen"};
118 static CommandLineArg
<uint64_t> sPrefsHandle
{"-prefsHandle", "prefshandle"};
119 static CommandLineArg
<uint64_t> sPrefsLen
{"-prefsLen", "prefslen"};
120 static CommandLineArg
<uint64_t> sPrefMapHandle
{"-prefMapHandle",
122 static CommandLineArg
<uint64_t> sPrefMapSize
{"-prefMapSize", "prefmapsize"};
124 static CommandLineArg
<uint64_t> sChildID
{"-childID", "childid"};
126 static CommandLineArg
<uint64_t> sSandboxingKind
{"-sandboxingKind",
129 static CommandLineArg
<bool> sSafeMode
{"-safeMode", "safemode"};
131 static CommandLineArg
<bool> sIsForBrowser
{"-isForBrowser", "isforbrowser"};
132 static CommandLineArg
<bool> sNotForBrowser
{"-notForBrowser", "notforbrowser"};
134 static CommandLineArg
<const char*> sPluginPath
{"-pluginPath", "pluginpath"};
135 static CommandLineArg
<bool> sPluginNativeEvent
{"-pluginNativeEvent",
136 "pluginnativeevent"};
139 # if defined(MOZ_SANDBOX)
140 static CommandLineArg
<bool> sWin32kLockedDown
{"-win32kLockedDown",
142 # endif // defined(MOZ_SANDBOX)
143 static CommandLineArg
<bool> sDisableDynamicDllBlocklist
{
144 "-disableDynamicBlocklist", "disabledynamicblocklist"};
145 #endif // defined(XP_WIN)
147 #if defined(__GNUC__)
148 # pragma GCC diagnostic pop
151 } // namespace geckoargs
153 } // namespace mozilla
155 #endif // mozilla_GeckoArgs_h