From 3b7cd5d89a226426df9c723d1f9ddfe08b7d1def Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Sun, 25 Jul 2010 16:45:21 +0000 Subject: Gavin Andresen's JSON-RPC HTTP authentication, faster initial block download -- version 0.3.3 git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@109 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- init.cpp | 85 ++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 45 insertions(+), 40 deletions(-) (limited to 'init.cpp') diff --git a/init.cpp b/init.cpp index 68e90aab04..d6d4562888 100644 --- a/init.cpp +++ b/init.cpp @@ -240,33 +240,34 @@ IMPLEMENT_APP(CMyApp) bool CMyApp::Initialize(int& argc, wxChar** argv) { - if (argc > 1 && argv[1][0] != '-' && (!fWindows || argv[1][0] != '/') && - wxString(argv[1]) != "start") - { - fCommandLine = true; - } - else if (!fGUI) - { - fDaemon = true; - } - else + for (int i = 1; i < argc; i++) + if (!IsSwitchChar(argv[i][0])) + fCommandLine = true; + + if (!fCommandLine) { - // wxApp::Initialize will remove environment-specific parameters, - // so it's too early to call ParseParameters yet - for (int i = 1; i < argc; i++) + if (!fGUI) + { + fDaemon = true; + } + else { - wxString str = argv[i]; - #ifdef __WXMSW__ - if (str.size() >= 1 && str[0] == '/') - str[0] = '-'; - char pszLower[MAX_PATH]; - strlcpy(pszLower, str.c_str(), sizeof(pszLower)); - strlwr(pszLower); - str = pszLower; - #endif - // haven't decided which argument to use for this yet - if (str == "-daemon" || str == "-d" || str == "start") - fDaemon = true; + // wxApp::Initialize will remove environment-specific parameters, + // so it's too early to call ParseParameters yet + for (int i = 1; i < argc; i++) + { + wxString str = argv[i]; + #ifdef __WXMSW__ + if (str.size() >= 1 && str[0] == '/') + str[0] = '-'; + char pszLower[MAX_PATH]; + strlcpy(pszLower, str.c_str(), sizeof(pszLower)); + strlwr(pszLower); + str = pszLower; + #endif + if (str == "-daemon") + fDaemon = true; + } } } @@ -375,22 +376,23 @@ bool CMyApp::OnInit2() // // Parameters // - if (fCommandLine) - { - int ret = CommandLineRPC(argc, argv); - exit(ret); - } - ParseParameters(argc, argv); + + if (mapArgs.count("-datadir")) + strlcpy(pszSetDataDir, mapArgs["-datadir"].c_str(), sizeof(pszSetDataDir)); + + ReadConfigFile(mapArgs, mapMultiArgs); // Must be done after processing datadir + if (mapArgs.count("-?") || mapArgs.count("--help")) { wxString strUsage = string() + _("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" + - " bitcoin [options] \t" + "\n" + - " bitcoin [command] \t" + _("Send command to bitcoin running with -server or -daemon\n") + - " bitcoin [command] -? \t" + _("Get help for a command\n") + - " bitcoin help \t" + _("List commands\n") + + " bitcoin [options] \t " + "\n" + + " bitcoin [options] [params]\t " + _("Send command to -server or bitcoind\n") + + " bitcoin [options] -? \t\t " + _("Get help for a command\n") + + " bitcoin help \t\t\t " + _("List commands\n") + _("Options:\n") + + " -conf= \t " + _("Specify configuration file (default: bitcoin.conf)\n") + " -gen \t " + _("Generate coins\n") + " -gen=0 \t " + _("Don't generate coins\n") + " -min \t " + _("Start minimized\n") + @@ -398,7 +400,7 @@ bool CMyApp::OnInit2() " -proxy=\t " + _("Connect through socks4 proxy\n") + " -addnode= \t " + _("Add a node to connect to\n") + " -connect= \t " + _("Connect only to the specified node\n") + - " -rpcpw= \t " + _("Accept command line and JSON-RPC commands with the given password\n") + + " -server \t " + _("Accept command line and JSON-RPC commands\n") + " -daemon \t " + _("Run in the background as a daemon and accept commands\n") + " -? \t " + _("This help message\n"); @@ -413,15 +415,18 @@ bool CMyApp::OnInit2() return false; } - if (mapArgs.count("-datadir")) - strlcpy(pszSetDataDir, mapArgs["-datadir"].c_str(), sizeof(pszSetDataDir)); - if (mapArgs.count("-debug")) fDebug = true; if (mapArgs.count("-printtodebugger")) fPrintToDebugger = true; + if (fCommandLine) + { + int ret = CommandLineRPC(argc, argv); + exit(ret); + } + if (!fDebug && !pszSetDataDir[0]) ShrinkDebugFile(); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); @@ -611,7 +616,7 @@ bool CMyApp::OnInit2() if (!CreateThread(StartNode, NULL)) wxMessageBox("Error: CreateThread(StartNode) failed", "Bitcoin"); - if (mapArgs.count("-server") || mapArgs.count("-rpcpw") || fDaemon) + if (mapArgs.count("-server") || fDaemon) CreateThread(ThreadRPCServer, NULL); if (fFirstRun) -- cgit v1.2.3