Example #1
0
BOOL CNWNX2App::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
	
	// set default values and parse ini file
	parseIniFile();

	// Parse command line and delete NWNX2 specific switches
	parseNWNCmdLine();
	dlg.pCmdLine = cmdline;

	startTime = COleDateTime::GetCurrentTime();
	dlg.m_strStarted = startTime.Format();

	m_pMainWnd = &dlg;
	dlg.DoModal();
	
	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}
Example #2
0
void Config::loadFromString (std::string const& fileContents)
{
    IniFileSections secConfig = parseIniFile (fileContents, true);

    build (secConfig);

    if (auto s = getIniFileSection (secConfig, SECTION_VALIDATORS))
        validators  = *s;

    if (auto s = getIniFileSection (secConfig, SECTION_CLUSTER_NODES))
        CLUSTER_NODES = *s;

    if (auto s = getIniFileSection (secConfig, SECTION_IPS))
        IPS = *s;

    if (auto s = getIniFileSection (secConfig, SECTION_IPS_FIXED))
        IPS_FIXED = *s;

    if (auto s = getIniFileSection (secConfig, SECTION_SNTP))
        SNTP_SERVERS = *s;

    if (auto s = getIniFileSection (secConfig, SECTION_RPC_STARTUP))
    {
        RPC_STARTUP = Json::arrayValue;

        for (auto const& strJson : *s)
        {
            Json::Reader    jrReader;
            Json::Value     jvCommand;

            if (!jrReader.parse (strJson, jvCommand))
                throw std::runtime_error (
                    boost::str (boost::format (
                        "Couldn't parse [" SECTION_RPC_STARTUP "] command: %s") % strJson));

            RPC_STARTUP.append (jvCommand);
        }
    }

    {
        std::string dbPath;
        if (getSingleSection (secConfig, "database_path", dbPath))
        {
            boost::filesystem::path p(dbPath);
            legacy("database_path", 
                   boost::filesystem::absolute (p).string ());
        }
    }

    (void) getSingleSection (secConfig, SECTION_VALIDATORS_SITE, VALIDATORS_SITE);

    std::string strTemp;
    if (getSingleSection (secConfig, SECTION_PEER_PRIVATE, strTemp))
        PEER_PRIVATE        = beast::lexicalCastThrow <bool> (strTemp);

    if (getSingleSection (secConfig, SECTION_PEERS_MAX, strTemp))
        PEERS_MAX           = beast::lexicalCastThrow <int> (strTemp);

    if (getSingleSection (secConfig, SECTION_NODE_SIZE, strTemp))
    {
        if (strTemp == "tiny")
            NODE_SIZE = 0;
        else if (strTemp == "small")
            NODE_SIZE = 1;
        else if (strTemp == "medium")
            NODE_SIZE = 2;
        else if (strTemp == "large")
            NODE_SIZE = 3;
        else if (strTemp == "huge")
            NODE_SIZE = 4;
        else
        {
            NODE_SIZE = beast::lexicalCastThrow <int> (strTemp);

            if (NODE_SIZE < 0)
                NODE_SIZE = 0;
            else if (NODE_SIZE > 4)
                NODE_SIZE = 4;
        }
    }

    if (getSingleSection (secConfig, SECTION_ELB_SUPPORT, strTemp))
        ELB_SUPPORT         = beast::lexicalCastThrow <bool> (strTemp);

    if (getSingleSection (secConfig, SECTION_WEBSOCKET_PING_FREQ, strTemp))
        WEBSOCKET_PING_FREQ = beast::lexicalCastThrow <int> (strTemp);

    getSingleSection (secConfig, SECTION_SSL_VERIFY_FILE, SSL_VERIFY_FILE);
    getSingleSection (secConfig, SECTION_SSL_VERIFY_DIR, SSL_VERIFY_DIR);

    if (getSingleSection (secConfig, SECTION_SSL_VERIFY, strTemp))
        SSL_VERIFY          = beast::lexicalCastThrow <bool> (strTemp);

    if (getSingleSection (secConfig, SECTION_VALIDATION_SEED, strTemp))
    {
        VALIDATION_SEED.setSeedGeneric (strTemp);

        if (VALIDATION_SEED.isValid ())
        {
            VALIDATION_PUB = DivvyAddress::createNodePublic (VALIDATION_SEED);
            VALIDATION_PRIV = DivvyAddress::createNodePrivate (VALIDATION_SEED);
        }
    }

    if (getSingleSection (secConfig, SECTION_NODE_SEED, strTemp))
    {
        NODE_SEED.setSeedGeneric (strTemp);

        if (NODE_SEED.isValid ())
        {
            NODE_PUB = DivvyAddress::createNodePublic (NODE_SEED);
            NODE_PRIV = DivvyAddress::createNodePrivate (NODE_SEED);
        }
    }

    if (getSingleSection (secConfig, SECTION_NETWORK_QUORUM, strTemp))
        NETWORK_QUORUM      = beast::lexicalCastThrow <std::size_t> (strTemp);

    if (getSingleSection (secConfig, SECTION_VALIDATION_QUORUM, strTemp))
        VALIDATION_QUORUM   = std::max (0, beast::lexicalCastThrow <int> (strTemp));

    if (getSingleSection (secConfig, SECTION_FEE_ACCOUNT_RESERVE, strTemp))
        FEE_ACCOUNT_RESERVE = beast::lexicalCastThrow <std::uint64_t> (strTemp);

    if (getSingleSection (secConfig, SECTION_FEE_OWNER_RESERVE, strTemp))
        FEE_OWNER_RESERVE   = beast::lexicalCastThrow <std::uint64_t> (strTemp);

    if (getSingleSection (secConfig, SECTION_FEE_OFFER, strTemp))
        FEE_OFFER           = beast::lexicalCastThrow <int> (strTemp);

    if (getSingleSection (secConfig, SECTION_FEE_DEFAULT, strTemp))
        FEE_DEFAULT         = beast::lexicalCastThrow <int> (strTemp);

    if (getSingleSection (secConfig, SECTION_FEE_OPERATION, strTemp))
        FEE_CONTRACT_OPERATION  = beast::lexicalCastThrow <int> (strTemp);

    if (getSingleSection (secConfig, SECTION_LEDGER_HISTORY, strTemp))
    {
        boost::to_lower (strTemp);

        if (strTemp == "full")
            LEDGER_HISTORY = 1000000000u;
        else if (strTemp == "none")
            LEDGER_HISTORY = 0;
        else
            LEDGER_HISTORY = beast::lexicalCastThrow <std::uint32_t> (strTemp);
    }

    if (getSingleSection (secConfig, SECTION_FETCH_DEPTH, strTemp))
    {
        boost::to_lower (strTemp);

        if (strTemp == "none")
            FETCH_DEPTH = 0;
        else if (strTemp == "full")
            FETCH_DEPTH = 1000000000u;
        else
            FETCH_DEPTH = beast::lexicalCastThrow <std::uint32_t> (strTemp);

        if (FETCH_DEPTH < 10)
            FETCH_DEPTH = 10;
    }

    if (getSingleSection (secConfig, SECTION_PATH_SEARCH_OLD, strTemp))
        PATH_SEARCH_OLD     = beast::lexicalCastThrow <int> (strTemp);
    if (getSingleSection (secConfig, SECTION_PATH_SEARCH, strTemp))
        PATH_SEARCH         = beast::lexicalCastThrow <int> (strTemp);
    if (getSingleSection (secConfig, SECTION_PATH_SEARCH_FAST, strTemp))
        PATH_SEARCH_FAST    = beast::lexicalCastThrow <int> (strTemp);
    if (getSingleSection (secConfig, SECTION_PATH_SEARCH_MAX, strTemp))
        PATH_SEARCH_MAX     = beast::lexicalCastThrow <int> (strTemp);

    if (getSingleSection (secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp))
        ACCOUNT_PROBE_MAX   = beast::lexicalCastThrow <int> (strTemp);

    if (getSingleSection (secConfig, SECTION_VALIDATORS_FILE, strTemp))
    {
        VALIDATORS_FILE     = strTemp;
    }

    if (getSingleSection (secConfig, SECTION_DEBUG_LOGFILE, strTemp))
        DEBUG_LOGFILE       = strTemp;
}