MCPcopy Create free account
hub / github.com/ElementsProject/elements / ParseParameters

Method ParseParameters

src/util/system.cpp:294–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::string& error)
295{
296 LOCK(cs_args);
297 m_settings.command_line_options.clear();
298
299 for (int i = 1; i < argc; i++) {
300 std::string key(argv[i]);
301
302#ifdef MAC_OSX
303 // At the first time when a user gets the "App downloaded from the
304 // internet" warning, and clicks the Open button, macOS passes
305 // a unique process serial number (PSN) as -psn_... command-line
306 // argument, which we filter out.
307 if (key.substr(0, 5) == "-psn_") continue;
308#endif
309
310 if (key == "-") break; //bitcoin-tx using stdin
311 std::string val;
312 size_t is_index = key.find('=');
313 if (is_index != std::string::npos) {
314 val = key.substr(is_index + 1);
315 key.erase(is_index);
316 }
317#ifdef WIN32
318 key = ToLower(key);
319 if (key[0] == '/')
320 key[0] = '-';
321#endif
322
323 if (key[0] != '-') {
324 if (!m_accept_any_command && m_command.empty()) {
325 // The first non-dash arg is a registered command
326 std::optional<unsigned int> flags = GetArgFlags(key);
327 if (!flags || !(*flags & ArgsManager::COMMAND)) {
328 error = strprintf("Invalid command '%s'", argv[i]);
329 return false;
330 }
331 }
332 m_command.push_back(key);
333 while (++i < argc) {
334 // The remaining args are command args
335 m_command.push_back(argv[i]);
336 }
337 break;
338 }
339
340 // Transform --foo to -foo
341 if (key.length() > 1 && key[1] == '-')
342 key.erase(0, 1);
343
344 // Transform -foo to foo
345 key.erase(0, 1);
346 KeyInfo keyinfo = InterpretKey(key);
347 std::optional<unsigned int> flags = GetArgFlags('-' + keyinfo.name);
348
349 // Unknown command line options and command line options with dot
350 // characters (which are returned from InterpretKey with nonempty
351 // section strings) are not valid.

Callers 15

AppInitRawTxFunction · 0.80
AppInitRPCFunction · 0.80
AppInitUtilFunction · 0.80
AppInitFunction · 0.80
WalletAppInitFunction · 0.80
CheckValueMethod · 0.80
ParseMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
TestParseFunction · 0.80
BOOST_FIXTURE_TEST_CASEFunction · 0.80
ResetArgsFunction · 0.80
FUZZ_TARGET_INITFunction · 0.80

Calls 11

InterpretKeyFunction · 0.85
InterpretValueFunction · 0.85
FindKeyFunction · 0.85
findMethod · 0.80
ToLowerFunction · 0.70
clearMethod · 0.45
eraseMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45
writeMethod · 0.45
beginMethod · 0.45

Tested by 8

CheckValueMethod · 0.64
ParseMethod · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64
TestParseFunction · 0.64
BOOST_FIXTURE_TEST_CASEFunction · 0.64
ResetArgsFunction · 0.64
FUZZ_TARGET_INITFunction · 0.64
BasicTestingSetupMethod · 0.64