• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GetArg函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetArg函数的典型用法代码示例。如果您正苦于以下问题:C++ GetArg函数的具体用法?C++ GetArg怎么用?C++ GetArg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetArg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: InitHTTPServer

bool InitHTTPServer()
{
    struct evhttp* http = 0;
    struct event_base* base = 0;

    if (!InitHTTPAllowList())
        return false;

    if (GetBoolArg("-rpcssl", false)) {
        uiInterface.ThreadSafeMessageBox(
            "SSL mode for RPC (-rpcssl) is no longer supported.",
            "", CClientUIInterface::MSG_ERROR);
        return false;
    }

    // Redirect libevent's logging to our own log
    event_set_log_callback(&libevent_log_cb);
    // Update libevent's log handling. Returns false if our version of
    // libevent doesn't support debug logging, in which case we should
    // clear the BCLog::LIBEVENT flag.
    if (!UpdateHTTPServerLogging(logCategories & BCLog::LIBEVENT)) {
        logCategories &= ~BCLog::LIBEVENT;
    }

#ifdef WIN32
    evthread_use_windows_threads();
#else
    evthread_use_pthreads();
#endif

    base = event_base_new(); // XXX RAII
    if (!base) {
        LogPrintf("Couldn't create an event_base: exiting\n");
        return false;
    }

    /* Create a new evhttp object to handle requests. */
    http = evhttp_new(base); // XXX RAII
    if (!http) {
        LogPrintf("couldn't create evhttp. Exiting.\n");
        event_base_free(base);
        return false;
    }

    evhttp_set_timeout(http, GetArg("-rpcservertimeout", DEFAULT_HTTP_SERVER_TIMEOUT));
    evhttp_set_max_headers_size(http, MAX_HEADERS_SIZE);
    evhttp_set_max_body_size(http, MAX_SIZE);
    evhttp_set_gencb(http, http_request_cb, NULL);

    if (!HTTPBindAddresses(http)) {
        LogPrintf("Unable to bind any endpoint for RPC server\n");
        evhttp_free(http);
        event_base_free(base);
        return false;
    }

    LogPrint(BCLog::HTTP, "Initialized HTTP server\n");
    int workQueueDepth = std::max((long)GetArg("-rpcworkqueue", DEFAULT_HTTP_WORKQUEUE), 1L);
    LogPrintf("HTTP: creating work queue of depth %d\n", workQueueDepth);

    workQueue = new WorkQueue<HTTPClosure>(workQueueDepth);
    eventBase = base;
    eventHTTP = http;
    return true;
}
开发者ID:Crinklebine,项目名称:bitcoin,代码行数:65,代码来源:httpserver.cpp


示例2: Reset


//.........这里部分代码省略.........
    if (!settings.contains("fShowGoldminenodesTab"))
        settings.setValue("fShowGoldminenodesTab", goldminenodeConfig.getCount());

    if (!settings.contains("fShowAdvancedPSUI"))
        settings.setValue("fShowAdvancedPSUI", false);
    fShowAdvancedPSUI = settings.value("fShowAdvancedPSUI", false).toBool();

    if (!settings.contains("fLowKeysWarning"))
        settings.setValue("fLowKeysWarning", true);

    // These are shared with the core or have a command-line parameter
    // and we want command-line parameters to overwrite the GUI settings.
    //
    // If setting doesn't exist create it with defaults.
    //
    // If SoftSetArg() or SoftSetBoolArg() return false we were overridden
    // by command-line and show this in the UI.

    // Main
    if (!settings.contains("nDatabaseCache"))
        settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
    if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
        addOverriddenOption("-dbcache");

    if (!settings.contains("nThreadsScriptVerif"))
        settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS);
    if (!SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString()))
        addOverriddenOption("-par");

    // Wallet
#ifdef ENABLE_WALLET
    if (!settings.contains("bSpendZeroConfChange"))
        settings.setValue("bSpendZeroConfChange", true);
    if (!SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
        addOverriddenOption("-spendzeroconfchange");

    // SpySend
    if (!settings.contains("nSpySendRounds"))
        settings.setValue("nSpySendRounds", DEFAULT_PRIVATESEND_ROUNDS);
    if (!SoftSetArg("-privatesendrounds", settings.value("nSpySendRounds").toString().toStdString()))
        addOverriddenOption("-privatesendrounds");
    nSpySendRounds = settings.value("nSpySendRounds").toInt();

    if (!settings.contains("nSpySendAmount")) {
        // for migration from old settings
        if (!settings.contains("nAnonymizeArcticAmount"))
            settings.setValue("nSpySendAmount", DEFAULT_PRIVATESEND_AMOUNT);
        else
            settings.setValue("nSpySendAmount", settings.value("nAnonymizeArcticAmount").toInt());
    }
    if (!SoftSetArg("-privatesendamount", settings.value("nSpySendAmount").toString().toStdString()))
        addOverriddenOption("-privatesendamount");
    nSpySendAmount = settings.value("nSpySendAmount").toInt();

    if (!settings.contains("fSpySendMultiSession"))
        settings.setValue("fSpySendMultiSession", DEFAULT_PRIVATESEND_MULTISESSION);
    if (!SoftSetBoolArg("-privatesendmultisession", settings.value("fSpySendMultiSession").toBool()))
        addOverriddenOption("-privatesendmultisession");
    fSpySendMultiSession = settings.value("fSpySendMultiSession").toBool();
#endif

    // Network
    if (!settings.contains("fUseUPnP"))
        settings.setValue("fUseUPnP", DEFAULT_UPNP);
    if (!SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool()))
        addOverriddenOption("-upnp");

    if (!settings.contains("fListen"))
        settings.setValue("fListen", DEFAULT_LISTEN);
    if (!SoftSetBoolArg("-listen", settings.value("fListen").toBool()))
        addOverriddenOption("-listen");

    if (!settings.contains("fUseProxy"))
        settings.setValue("fUseProxy", false);
    if (!settings.contains("addrProxy"))
        settings.setValue("addrProxy", "127.0.0.1:9050");
    // Only try to set -proxy, if user has enabled fUseProxy
    if (settings.value("fUseProxy").toBool() && !SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()))
        addOverriddenOption("-proxy");
    else if(!settings.value("fUseProxy").toBool() && !GetArg("-proxy", "").empty())
        addOverriddenOption("-proxy");

    if (!settings.contains("fUseSeparateProxyTor"))
        settings.setValue("fUseSeparateProxyTor", false);
    if (!settings.contains("addrSeparateProxyTor"))
        settings.setValue("addrSeparateProxyTor", "127.0.0.1:9050");
    // Only try to set -onion, if user has enabled fUseSeparateProxyTor
    if (settings.value("fUseSeparateProxyTor").toBool() && !SoftSetArg("-onion", settings.value("addrSeparateProxyTor").toString().toStdString()))
        addOverriddenOption("-onion");
    else if(!settings.value("fUseSeparateProxyTor").toBool() && !GetArg("-onion", "").empty())
        addOverriddenOption("-onion");

    // Display
    if (!settings.contains("language"))
        settings.setValue("language", "");
    if (!SoftSetArg("-lang", settings.value("language").toString().toStdString()))
        addOverriddenOption("-lang");

    language = settings.value("language").toString();
}
开发者ID:ArcticCore,项目名称:ArcticCoin,代码行数:101,代码来源:optionsmodel.cpp


示例3: BzSrchMe

VOID BzSrchMe(PSPAWNINFO pChar, PCHAR szLine)
{
	lockit lk(bzsrchhandle);

	CHAR szArg[MAX_STRING] = { 0 };
	CHAR szItem[MAX_STRING] = { 0 };
    PCHARINFO pCharInfo = GetCharInfo();
    BOOL bArg = TRUE;
	bool first = true;


	if (CButtonWnd *ptr = (CButtonWnd *)pBazaarSearchWnd->GetChildItem("BZR_Default")) {
		SendWndClick2((CXWnd*)ptr, "leftmouseup");
	}
	while (bArg) {
		GetArg(szArg, szLine, 1);
		szLine = GetNextArg(szLine, 1);
		if (szArg[0] == 0) {
			bArg = FALSE;
		} else if (!strcmp(szArg, "class")) {
			GetArg(szArg, szLine, 1);
			szLine = GetNextArg(szLine, 1);
			DoClass(szArg);
		} else if (!_stricmp(szArg, "race")) {
			GetArg(szArg, szLine, 1);
			szLine = GetNextArg(szLine, 1);
			DoRace(szArg);
		} else if (!_stricmp(szArg, "stat")) {
			GetArg(szArg, szLine, 1);
			szLine = GetNextArg(szLine, 1);
			DoCombo(szArg, "Stat", "BZR_StatSlotCombobox");
		} else if (!_stricmp(szArg, "slot")) {
			GetArg(szArg, szLine, 1);
			szLine = GetNextArg(szLine, 1);
			DoCombo(szArg, "Slot", "BZR_ItemSlotCombobox");
		} else if (!_stricmp(szArg, "type")) {
			GetArg(szArg, szLine, 1);
			szLine = GetNextArg(szLine, 1);
			DoCombo(szArg, "Type", "BZR_ItemTypeCombobox");
		} else if (!strcmp(szArg, "price")) {
			GetArg(szArg, szLine, 1);
			szLine = GetNextArg(szLine, 1);
			if (szArg[0] == 0) {
				MacroError("Bad price low.");
				goto error_out;
			}
			if (CXWnd *pEdit = (CXWnd *)pBazaarSearchWnd->GetChildItem("BZR_MinPriceInput")) {
				pEdit->SetWindowTextA(CXStr(szArg));
			}
			GetArg(szArg, szLine, 1);
			szLine = GetNextArg(szLine, 1);
			if (szArg[0] == 0) {
				MacroError("Bad price high.");
				goto error_out;
			}
			if (CXWnd *pEdit = (CXWnd *)pBazaarSearchWnd->GetChildItem("BZR_MaxPriceInput")) {
				pEdit->SetWindowTextA(CXStr(szArg));
			}
		} else if (!_stricmp(szArg, "trader")) {
			GetArg(szArg, szLine, 1);
			szLine = GetNextArg(szLine, 1);
			DoCombo(szArg, "Trader", "BZR_PlayersCombobox");
		} else if (!_stricmp(szArg, "prestige")) {
			GetArg(szArg, szLine, 1);
			szLine = GetNextArg(szLine, 1);
			DoCombo(szArg, "Prestige", "BZR_ItemPrestigeCombobox");
		} else if (!_stricmp(szArg, "augment")) {
			GetArg(szArg, szLine, 1);
			szLine = GetNextArg(szLine, 1);
			DoCombo(szArg, "Augment", "BZR_ItemAugmentCombobox");
		} else {
			if (first) {
				first = false;
			} else {
				strcat(szItem, " ");
			}
			strcat(szItem, szArg);
		}
	}
	if (CXWnd *pEdit = (CXWnd *)pBazaarSearchWnd->GetChildItem("BZR_ItemNameInput")) {
		pEdit->SetWindowTextA(CXStr(szItem));
		DWORD nThreadID = 0;
		CreateThread(NULL, NULL, searchthread, 0, 0, &nThreadID);
	}
error_out:
	return;
}
开发者ID:TheTypoMaster,项目名称:macroquest2,代码行数:87,代码来源:MQ2Bzsrch.cpp


示例4: HideDoCommand

VOID HideDoCommand(PSPAWNINFO pChar, PCHAR szLine, BOOL delayed)
{
    if (delayed)
    {
        PCHATBUF pChat = (PCHATBUF)malloc(sizeof(CHATBUF));
        if (pChat) {
            strcpy(pChat->szText,szLine);
            pChat->pNext = NULL;
            if (!gDelayedCommands) {
                gDelayedCommands = pChat;
            } else {
                PCHATBUF pCurrent;
                for (pCurrent = gDelayedCommands;pCurrent->pNext;pCurrent=pCurrent->pNext);
                pCurrent->pNext = pChat;
            }
        }
        return;
    }

    CAutoLock DoCommandLock(&gCommandCS);
    CHAR szCmd[MAX_STRING] = {0};
    CHAR szParam[MAX_STRING] = {0};
    CHAR szOriginalLine[MAX_STRING] = {0};

    strcpy(szOriginalLine,szLine);
    GetArg(szCmd,szLine,1);
    PALIAS pLoop = pAliases;
    while (pLoop) {
        if (!stricmp(szCmd,pLoop->szName)) {
            sprintf(szLine,"%s%s",pLoop->szCommand,szOriginalLine+strlen(pLoop->szName));
            break;
        }
        pLoop = pLoop->pNext;
    }


    GetArg(szCmd,szLine,1);
    if (szCmd[0]==0)
		return;
    strcpy(szParam, GetNextArg(szLine));

    if ((szCmd[0]==':') || (szCmd[0]=='{')) {
        bRunNextCommand = TRUE;
        return;
    }
	if(gMacroBlock && gMacroBlock->LoopLine!=0) {
		//this is a command thats inside a while loop
		//so its time to loop back
		gMacroBlock = GetWhileBlock(gMacroBlock->LoopLine);
		if (szCmd[0]=='}') {
			bRunNextCommand = TRUE;
			return;
		}
	} else if (szCmd[0]=='}') {
		if (strstr(szLine,"{")) {
			GetArg(szCmd,szLine,2);
			if (stricmp(szCmd,"else")) {
				FatalError("} and { seen on the same line without an else present");
			}
			//          DebugSpew("DoCommand - handing {} off to FailIf");
			FailIf(pChar,"{",gMacroBlock,TRUE);
		} else {
			// handle this: 
			//            /if () {
			//            } else /echo stuff
			GetArg(szCmd,szLine,2);
			if (!stricmp(szCmd,"else")) {
				// check here to fail this:
				//            /if () {
				//            } else 
				//                /echo stuff
				GetArg(szCmd,szLine,3);
				if (!stricmp(szCmd,"")) {
					FatalError("no command or { following else");
				}
				bRunNextCommand = TRUE;
			} else {
				bRunNextCommand = TRUE;
			}
		}
		return;
    }
    if (szCmd[0]==';' || szCmd[0]=='[')
    {
        pEverQuest->InterpretCmd((EQPlayer*)pChar,szOriginalLine);
        return;
    }



    PMQCOMMAND pCommand=pCommands;
    while(pCommand)
    {
        if (pCommand->InGameOnly && gGameState!=GAMESTATE_INGAME)
        {
            pCommand=pCommand->pNext;
            continue;
        }
        int Pos=strnicmp(szCmd,pCommand->Command,strlen(szCmd));
        if (Pos<0)
//.........这里部分代码省略.........
开发者ID:isxGames,项目名称:ISXEQ,代码行数:101,代码来源:MQ2CommandAPI.cpp


示例5: GetArg

const char *DArgs::operator[] (size_t n)
{
	return GetArg(n);
}
开发者ID:JohnnyonFlame,项目名称:odamex,代码行数:4,代码来源:m_argv.cpp


示例6: switch

////////////////////////////////////////////////////////////////
// キー入力処理
////////////////////////////////////////////////////////////////
void cWndMon::KeyIn( int kcode, bool shift, int ccode )
{
	static int LastKey  = KVC_ENTER;	// 前回のキー
	static int HisLevel = 1;			// ヒストリレベル
	
	switch( kcode ){		// キーコード
	case KVC_F6:			// モニタモード変更
		vm->el->ToggleMonitor();
		break;
		
	case KVC_ENTER:			// Enter
	case KVC_P_ENTER:		// Enter(テンキー)
		ZCons::Printf( "\n" );
		
		if( strlen( KeyBuf ) > 0 ){						// キーバッファが有効で
			if( stricmp( KeyBuf, HisBuf[1] ) != 0 ){	// 直前のヒストリと異なるなら
				for( int i=MAX_HIS-1; i>1; i-- ) strcpy( HisBuf[i], HisBuf[i-1] );
				strcpy( HisBuf[1], KeyBuf );			// キーバッファをヒストリバッファにコピー
			}
		}
		
		// ここで引数解析処理
		Exec( GetArg() );
		
		*KeyBuf = '\0';						// キーバッファクリア
		ZCons::Printf( PROMPT );
		break;
		
	case KVC_UP:			// 上矢印
	case KVC_DOWN:			// 下矢印
		if( LastKey == KVC_UP || LastKey == KVC_DOWN ){
			if( kcode == KVC_UP   && HisLevel < MAX_HIS-1 && strlen( HisBuf[HisLevel+1] ) > 0 ) HisLevel++;
			if( kcode == KVC_DOWN && HisLevel > 0 )                                             HisLevel--;
		}else{
			if( kcode == KVC_UP ) HisLevel = 1;
			else                  HisLevel = 0;
		}
		
		// 今のコマンドラインを消去
		while( strlen(KeyBuf) > 0 ){
			ZCons::LocateR( -1, 0 );
			ZCons::PutCharH( ' ' );
			ZCons::LocateR( -1, 0 );
			KeyBuf[strlen(KeyBuf)-1] = (BYTE)'\0';
		}
		// ヒストリバッファからキーバッファにコピーして表示
		strcpy( KeyBuf, HisBuf[HisLevel] );
		ZCons::Printf( KeyBuf );
		break;
		
	case KVC_BACKSPACE:		// BackSpace
		if( strlen(KeyBuf) > 0 ){
			ZCons::LocateR( -1, 0 );
			ZCons::PutCharH( ' ' );
			ZCons::LocateR( -1, 0 );
			KeyBuf[strlen(KeyBuf)-1] = (BYTE)'\0';
		}
		break;
		
	// メモリウィンドウ
	case KVC_PAGEDOWN:		// PageDown
		vm->el->memw->SetAddress( vm->el->memw->GetAddress() + ( shift ? 2048 : 16 ) );
		break;
		
	case KVC_PAGEUP:		// PageUp
		vm->el->memw->SetAddress( vm->el->memw->GetAddress() - ( shift ? 2048 : 16 ) );
		break;
		
	default:
		// 有効な文字コードかつバッファがあふれていなければ
		if( ( ccode > 0x1f ) && ( ccode < 0x80 ) ){
			if( strlen(KeyBuf) < (MAX_CHRS-1) ){
				char *p = &KeyBuf[strlen(KeyBuf)];
				*p++ = (BYTE)ccode;
				*p   = (BYTE)'\0';
//				ZCons::PutCharH( ccode );
				ZCons::Printf( "%c", ccode );
			}
		}
	}
	
	LastKey = kcode;
	
}
开发者ID:eighttails,项目名称:PC6001VX,代码行数:87,代码来源:debug.cpp


示例7: DumpDynPcdMain

/**
  Main entrypoint for DumpDynPcd shell application.

  @param[in]  ImageHandle     The image handle.
  @param[in]  SystemTable     The system table.

  @retval EFI_SUCCESS            Command completed successfully.
  @retval EFI_INVALID_PARAMETER  Command usage error.
  @retval EFI_OUT_OF_RESOURCES   Not enough resources were available to run the command.
  @retval EFI_ABORTED            Aborted by user.
  @retval EFI_NOT_FOUND          The specified PCD is not found.
  @retval Others                 Error status returned from gBS->LocateProtocol.
**/
EFI_STATUS
EFIAPI
DumpDynPcdMain (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
  EFI_STATUS    Status;
  CHAR16        *InputPcdName;

  InputPcdName  = NULL;

  Status = gBS->LocateProtocol(&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID **) &mUnicodeCollation);
  if (EFI_ERROR (Status)) {
    mUnicodeCollation = NULL;
  }

  Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd);
  if (EFI_ERROR (Status)) {
    Print (L"DumpDynPcd: %EError. %NPI PCD protocol is not present.\n");
    return Status;
  }

  Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **) &mPiPcdInfo);
  if (EFI_ERROR (Status)) {
    Print (L"DumpDynPcd: %EError. %NPI PCD info protocol is not present.\n");
    return Status;
  }

  Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **) &mPcd);
  if (EFI_ERROR (Status)) {
    Print (L"DumpDynPcd: %EError. %NPCD protocol is not present.\n");
    return Status;
  }

  Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **) &mPcdInfo);
  if (EFI_ERROR (Status)) {
    Print (L"DumpDynPcd: %EError. %NPCD info protocol is not present.\n");
    return Status;
  }

  //
  // get the command line arguments
  //
  Status = GetArg();
  if (EFI_ERROR(Status)){
    Print (L"DumpDynPcd: %EError. %NThe input parameters are not recognized.\n");
    Status = EFI_INVALID_PARAMETER;
    return Status;
  }

  if (Argc > 2){
    Print (L"DumpDynPcd: %EError. %NToo many arguments specified.\n");
    Status = EFI_INVALID_PARAMETER;
    return Status;
  }

  if (Argc == 1){
    Status = ProcessPcd (InputPcdName);
    goto Done;
  }

  if ((StrCmp(Argv[1], L"-?") == 0)||(StrCmp(Argv[1], L"-h") == 0)||(StrCmp(Argv[1], L"-H") == 0)){
    ShowHelp ();
    goto Done;
  } else {
    if ((StrCmp(Argv[1], L"-v") == 0)||(StrCmp(Argv[1], L"-V") == 0)){
      ShowVersion ();
      goto Done;
    } else {
      if (StrStr(Argv[1], L"-") != NULL){
        Print (L"DumpDynPcd: %EError. %NThe argument '%B%s%N' is invalid.\n", Argv[1]);
        goto Done;
      }
    }
  }

  InputPcdName = Argv[1];
  Status = ProcessPcd (InputPcdName);

  Done:

  if (mTempPcdNameBuffer != NULL) {
    FreePool (mTempPcdNameBuffer);
  }

  return Status;
//.........这里部分代码省略.........
开发者ID:lersek,项目名称:edk2,代码行数:101,代码来源:DumpDynPcd.c


示例8: atexit

//
// Load OpenSSL's list of root certificate authorities
//
void PaymentServer::LoadRootCAs(X509_STORE* _store)
{
    if (PaymentServer::certStore == NULL)
        atexit(PaymentServer::freeCertStore);
    else
        freeCertStore();

    // Unit tests mostly use this, to pass in fake root CAs:
    if (_store)
    {
        PaymentServer::certStore = _store;
        return;
    }

    // Normal execution, use either -rootcertificates or system certs:
    PaymentServer::certStore = X509_STORE_new();

    // Note: use "-system-" default here so that users can pass -rootcertificates=""
    // and get 'I don't like X.509 certificates, don't trust anybody' behavior:
    QString certFile = QString::fromStdString(GetArg("-rootcertificates", "-system-"));

    if (certFile.isEmpty())
        return; // Empty store

    QList<QSslCertificate> certList;

    if (certFile != "-system-")
    {
        certList = QSslCertificate::fromPath(certFile);
        // Use those certificates when fetching payment requests, too:
        QSslSocket::setDefaultCaCertificates(certList);
    }
    else
        certList = QSslSocket::systemCaCertificates ();

    int nRootCerts = 0;
    const QDateTime currentTime = QDateTime::currentDateTime();
    foreach (const QSslCertificate& cert, certList)
    {
        if (currentTime < cert.effectiveDate() || currentTime > cert.expiryDate()) {
            ReportInvalidCertificate(cert);
            continue;
        }
#if QT_VERSION >= 0x050000
        if (cert.isBlacklisted()) {
            ReportInvalidCertificate(cert);
            continue;
        }
#endif
        QByteArray certData = cert.toDer();
        const unsigned char *data = (const unsigned char *)certData.data();

        X509* x509 = d2i_X509(0, &data, certData.size());
        if (x509 && X509_STORE_add_cert(PaymentServer::certStore, x509))
        {
            // Note: X509_STORE_free will free the X509* objects when
            // the PaymentServer is destroyed
            ++nRootCerts;
        }
        else
        {
            ReportInvalidCertificate(cert);
            continue;
        }
    }
    if (fDebug)
        qDebug() << "PaymentServer::LoadRootCAs : Loaded " << nRootCerts << " root certificates";

    // Project for another day:
    // Fetch certificate revocation lists, and add them to certStore.
    // Issues to consider:
    //   performance (start a thread to fetch in background?)
    //   privacy (fetch through tor/proxy so IP address isn't revealed)
    //   would it be easier to just use a compiled-in blacklist?
    //    or use Qt's blacklist?
    //   "certificate stapling" with server-side caching is more efficient
}
开发者ID:AUSTRALIANBITCOINS,项目名称:bitcoin,代码行数:80,代码来源:paymentserver.cpp


示例9: AddTimeData

void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
{
    LOCK(cs_nTimeOffset);
    // Ignore duplicates
    static std::set<CNetAddr> setKnown;
    if (setKnown.size() == GULDEN_TIMEDATA_MAX_SAMPLES)
        return;
    if (!setKnown.insert(ip).second)
        return;

    // Add data
    static CMedianFilter<int64_t> vTimeOffsets(GULDEN_TIMEDATA_MAX_SAMPLES, 0);
    vTimeOffsets.input(nOffsetSample);
    LogPrint(BCLog::NET,"added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);

    // There is a known issue here (see issue #4521):
    //
    // - The structure vTimeOffsets contains up to 200 elements, after which
    // any new element added to it will not increase its size, replacing the
    // oldest element.
    //
    // - The condition to update nTimeOffset includes checking whether the
    // number of elements in vTimeOffsets is odd, which will never happen after
    // there are 200 elements.
    //
    // But in this case the 'bug' is protective against some attacks, and may
    // actually explain why we've never seen attacks which manipulate the
    // clock offset.
    //
    // So we should hold off on fixing this and clean it up as part of
    // a timing cleanup that strengthens it in a number of other ways.
    //
    if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)
    {
        int64_t nMedian = vTimeOffsets.median();
        std::vector<int64_t> vSorted = vTimeOffsets.sorted();
        // Only let other nodes change our time by so much
        if (abs64(nMedian) <= std::max<int64_t>(0, GetArg("-maxtimeadjustment", DEFAULT_MAX_TIME_ADJUSTMENT)))
        {
            nTimeOffset = nMedian;
        }
        else
        {
            nTimeOffset = 0;

            static bool fDone;
            if (!fDone)
            {
                // If nobody has a time different than ours but within 5 minutes of ours, give a warning
                bool fMatch = false;
                for(int64_t nOffset : vSorted)
                    if (nOffset != 0 && abs64(nOffset) < 5 * 60)
                        fMatch = true;

                if (!fMatch)
                {
                    fDone = true;
                    std::string strMessage = strprintf(_("Please check that your computer's date and time are correct! If your clock is wrong, %s will not work properly."), _(PACKAGE_NAME));
                    SetMiscWarning(strMessage);
                    uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING);
                }
            }
        }

        if (LogAcceptCategory(BCLog::NET)) {
            for(int64_t n : vSorted) {
                LogPrint(BCLog::NET, "%+d  ", n);
            }
            LogPrint(BCLog::NET, "|  ");

            LogPrint(BCLog::NET, "nTimeOffset = %+d  (%+d minutes)\n", nTimeOffset, nTimeOffset/60);
        }
    }
}
开发者ID:ALEX196969,项目名称:gulden-official,代码行数:74,代码来源:timedata.cpp


示例10: CallRPC

UniValue CallRPC(const std::string& strMethod, const UniValue& params)
{
    std::string host = GetArg("-rpcconnect", DEFAULT_RPCCONNECT);
    int port = GetArg("-rpcport", BaseParams().RPCPort());

    // Obtain event base
    raii_event_base base = obtain_event_base();

    // Synchronously look up hostname
    raii_evhttp_connection evcon = obtain_evhttp_connection_base(base.get(), host, port);
    evhttp_connection_set_timeout(evcon.get(), GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT));

    HTTPReply response;
    raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
    if (req == NULL)
        throw std::runtime_error("create http request failed");
#if LIBEVENT_VERSION_NUMBER >= 0x02010300
    evhttp_request_set_error_cb(req.get(), http_error_cb);
#endif

    // Get credentials
    std::string strRPCUserColonPass;
    if (GetArg("-rpcpassword", "") == "") {
        // Try fall back to cookie-based authentication if no password is provided
        if (!GetAuthCookie(&strRPCUserColonPass)) {
            throw std::runtime_error(strprintf(
                _("Could not locate RPC credentials. No authentication cookie could be found, and no rpcpassword is set in the configuration file (%s)"),
                    GetConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)).string().c_str()));

        }
    } else {
        strRPCUserColonPass = GetArg("-rpcuser", "") + ":" + GetArg("-rpcpassword", "");
    }

    struct evkeyvalq* output_headers = evhttp_request_get_output_headers(req.get());
    assert(output_headers);
    evhttp_add_header(output_headers, "Host", host.c_str());
    evhttp_add_header(output_headers, "Connection", "close");
    evhttp_add_header(output_headers, "Authorization", (std::string("Basic ") + EncodeBase64(strRPCUserColonPass)).c_str());

    // Attach request data
    std::string strRequest = JSONRPCRequestObj(strMethod, params, 1).write() + "\n";
    struct evbuffer* output_buffer = evhttp_request_get_output_buffer(req.get());
    assert(output_buffer);
    evbuffer_add(output_buffer, strRequest.data(), strRequest.size());

    int r = evhttp_make_request(evcon.get(), req.get(), EVHTTP_REQ_POST, "/");
    req.release(); // ownership moved to evcon in above call
    if (r != 0) {
        throw CConnectionFailed("send http request failed");
    }

    event_base_dispatch(base.get());

    if (response.status == 0)
        throw CConnectionFailed(strprintf("couldn't connect to server: %s (code %d)\n(make sure server is running and you are connecting to the correct RPC port)", http_errorstring(response.error), response.error));
    else if (response.status == HTTP_UNAUTHORIZED)
        throw std::runtime_error("incorrect rpcuser or rpcpassword (authorization failed)");
    else if (response.status >= 400 && response.status != HTTP_BAD_REQUEST && response.status != HTTP_NOT_FOUND && response.status != HTTP_INTERNAL_SERVER_ERROR)
        throw std::runtime_error(strprintf("server returned HTTP error %d", response.status));
    else if (response.body.empty())
        throw std::runtime_error("no response from server");

    // Parse reply
    UniValue valReply(UniValue::VSTR);
    if (!valReply.read(response.body))
        throw std::runtime_error("couldn't parse reply from server");
    const UniValue& reply = valReply.get_obj();
    if (reply.empty())
        throw std::runtime_error("expected reply to have result, error and id properties");

    return reply;
}
开发者ID:SergioDemianLerner,项目名称:bitcoin,代码行数:73,代码来源:bitcoin-cli.cpp


示例11: main

/*********************************
* main - this is where it begins
*********************************/
int main(int argc, char **argv)
{
  std::cout << "********************************************" << std::endl;
  std::cout << "*** ptsminer - Pts Pool Miner v" << VERSION_MAJOR << "." << VERSION_MINOR << " " << VERSION_EXT << std::endl;
  std::cout << "*** by xolokram/TB - www.beeeeer.org - glhf" << std::endl;
  std::cout << "***" << std::endl;
  std::cout << "*** press CTRL+C to exit" << std::endl;
  std::cout << "********************************************" << std::endl;

  t_start = boost::posix_time::second_clock::universal_time();
  running = true;

#if defined(__MINGW32__) || defined(__MINGW64__)
  SetConsoleCtrlHandler(ctrl_handler, TRUE);
#elif defined(__GNUG__) && !defined(__APPLE__)
  set_signal_handler(SIGINT, ctrl_handler);
#endif

  if (argc < 2)
  {
    std::cerr << "usage: " << argv[0] <<
    " -poolfee=<fee-in-%> -poolip=<ip> -poolport=<port> -pooluser=<user> -poolpassword=<password>" <<
    std::endl;
    return EXIT_FAILURE;
  }

  const int atexit_res = std::atexit(exit_handler);
  if (atexit_res != 0)
    std::cerr << "atexit registration failed, shutdown will be dirty!" << std::endl;

  // init everything:
  ParseParameters(argc, argv);

  socket_to_server = NULL;
  //pool_share_minimum = (unsigned int)GetArg("-poolshare", 7);
  thread_num_max = GetArg("-genproclimit", 1); // what about boost's hardware_concurrency() ?
  fee_to_pay = GetArg("-poolfee", 3);
  miner_id = GetArg("-minerid", 0);
  pool_username = GetArg("-pooluser", "");
  pool_password = GetArg("-poolpassword", "");

  if (thread_num_max == 0 || thread_num_max > MAX_THREADS)
  {
    std::cerr << "usage: " << "current maximum supported number of threads = " << MAX_THREADS << std::endl;
    return EXIT_FAILURE;
  }

  if (fee_to_pay == 0 || fee_to_pay > 100)
  {
    std::cerr << "usage: " << "please use a pool fee between [1 , 100]" << std::endl;
    return EXIT_FAILURE;
  }

  if (miner_id > 65535)
  {
    std::cerr << "usage: " << "please use a miner id between [0 , 65535]" << std::endl;
    return EXIT_FAILURE;
  }

  { //password to sha1
    boost::uuids::detail::sha1 sha;
    sha.process_bytes(pool_password.c_str(), pool_password.size());
    unsigned int digest[5];
    sha.get_digest(digest);
    std::stringstream ss;
    ss << std::setw(5) << std::setfill('0') << std::hex << (digest[0] ^ digest[1] ^ digest[4]) << (digest[2] ^ digest[3] ^ digest[4]);
    pool_password = ss.str();
  }
std::cout << pool_username << std::endl;

  fPrintToConsole = true; // always on
  fDebug          = GetBoolArg("-debug");

  pindexBest = new CBlockIndex();

  //GeneratePrimeTable();

  // ok, start mining:
  CBlockProviderGW* bprovider = new CBlockProviderGW();
  CMasterThread *mt = new CMasterThread(bprovider);
  mt->run();

  // end:
  return EXIT_SUCCESS;
}
开发者ID:Doken-Tokuyama,项目名称:ptsminer,代码行数:88,代码来源:main_poolminer.cpp


示例12: run

  void run() {

	{
		boost::unique_lock<boost::shared_mutex> lock(_mutex_master);
		std::cout << "spawning " << thread_num_max << " worker thread(s)" << std::endl;

		for (unsigned int i = 0; i < thread_num_max; ++i) {
			CWorkerThread *worker = new CWorkerThread(this, i, _bprovider);
			worker->work();
		}
	}

    boost::asio::io_service io_service;
    boost::asio::ip::tcp::resolver resolver(io_service); //resolve dns
    boost::asio::ip::tcp::resolver::query query(GetArg("-poolip", "127.0.0.1"), GetArg("-poolport", "1337"));
    boost::asio::ip::tcp::resolver::iterator endpoint;
	boost::asio::ip::tcp::resolver::iterator end;
	boost::asio::ip::tcp::no_delay nd_option(true);
	boost::asio::socket_base::keep_alive ka_option(true);

	while (running) {
		endpoint = resolver.resolve(query);
		boost::scoped_ptr<boost::asio::ip::tcp::socket> socket;
		boost::system::error_code error_socket = boost::asio::error::host_not_found;
		while (error_socket && endpoint != end)
		{
		  //socket->close();
		  socket.reset(new boost::asio::ip::tcp::socket(io_service));
		  boost::asio::ip::tcp::endpoint tcp_ep = *endpoint++;
		  socket->connect(tcp_ep, error_socket);
		  std::cout << "connecting to " << tcp_ep << std::endl;
		}
		socket->set_option(nd_option);
		socket->set_option(ka_option);

		if (error_socket) {
			std::cout << error_socket << std::endl;
			boost::this_thread::sleep(boost::posix_time::seconds(10));
			continue;
		}

		{ //send hello message
			char* hello = new char[pool_username.length()+/*v0.2/0.3=*/2+/*v0.4=*/20+/*v0.7=*/1+pool_password.length()];
			memcpy(hello+1, pool_username.c_str(), pool_username.length());
			*((unsigned char*)hello) = pool_username.length();
			*((unsigned char*)(hello+pool_username.length()+1)) = 0; //hi, i'm v0.4+
			*((unsigned char*)(hello+pool_username.length()+2)) = VERSION_MAJOR;
			*((unsigned char*)(hello+pool_username.length()+3)) = VERSION_MINOR;
			*((unsigned char*)(hello+pool_username.length()+4)) = thread_num_max;
			*((unsigned char*)(hello+pool_username.length()+5)) = fee_to_pay;
			*((unsigned short*)(hello+pool_username.length()+6)) = miner_id;
			*((unsigned int*)(hello+pool_username.length()+8)) = 0;
			*((unsigned int*)(hello+pool_username.length()+12)) = 0;
			*((unsigned int*)(hello+pool_username.length()+16)) = 0;
			*((unsigned char*)(hello+pool_username.length()+20)) = pool_password.length();
			memcpy(hello+pool_username.length()+21, pool_password.c_str(), pool_password.length());
			*((unsigned short*)(hello+pool_username.length()+21+pool_password.length())) = 0; //EXTENSIONS
			boost::system::error_code error;
			socket->write_some(boost::asio::buffer(hello, pool_username.length()+2+20+1+pool_password.length()), error);
			//if (error)
			//	std::cout << error << " @ write_some_hello" << std::endl;
			delete[] hello;
		}

		socket_to_server = socket.get(); //TODO: lock/mutex

		int reject_counter = 0;
		bool done = false;
		while (!done) {
			int type = -1;
			{ //get the data header
				unsigned char buf = 0; //get header
				boost::system::error_code error;
				size_t len = boost::asio::read(*socket_to_server, boost::asio::buffer(&buf, 1), boost::asio::transfer_all(), error);
				//size_t len = socket->read_some(boost::asio::buffer(&buf, 1), error);
				if (error == boost::asio::error::eof)
					break; // Connection closed cleanly by peer.
				else if (error) {
					//std::cout << error << " @ read_some1" << std::endl;
					break;
				}
				type = buf;
				if (len != 1)
					std::cout << "error on read1: " << len << " should be " << 1 << std::endl;
			}

			switch (type) {
				case 0: {
					size_t buf_size = 112; //*thread_num_max;
					unsigned char* buf = new unsigned char[buf_size]; //get header
					boost::system::error_code error;
					size_t len = boost::asio::read(*socket_to_server, boost::asio::buffer(buf, buf_size), boost::asio::transfer_all(), error);
					//size_t len = socket->read_some(boost::asio::buffer(buf, buf_size), error);
					//while (len < buf_size)
					//	len += socket->read_some(boost::asio::buffer(buf+len, buf_size-len), error);
					if (error == boost::asio::error::eof) {
						done = true;
						break; // Connection closed cleanly by peer.
					} else if (error) {
						//std::cout << error << " @ read2a" << std::endl;
//.........这里部分代码省略.........
开发者ID:Doken-Tokuyama,项目名称:ptsminer,代码行数:101,代码来源:main_poolminer.cpp


示例13: OBServer_Help

//______________________________________________________________________________
//                                                                            []
//` OBServer_Help                                                             []
//                                                                            []
void OBServer_Help (void ** ppData, 
					string_arr& FnNames, 
					string_arr& FnDesc, 
					CPtr<FUNCTION_ARGS>& REGISTERED_FUNCTIONS_ARGS, 
					const char * InputArgs)
{
	int OBServer_result = OBServer_OK;

	OBServer_WRAPPER_START;

	string	OutArgs;

	OutArgs.Format(
		"%ca1%ca2%ca3%ca4%ca5%ca6%ca7%ca8",
		ARG_NAME_HEADER_CHAR, ARG_NAME_HEADER_CHAR,
		ARG_NAME_HEADER_CHAR, ARG_NAME_HEADER_CHAR,
		ARG_NAME_HEADER_CHAR, ARG_NAME_HEADER_CHAR, 
		ARG_NAME_HEADER_CHAR, ARG_NAME_HEADER_CHAR);


// Список функций с описаниями
	int FuncNum = -1;
	if (!GetArg(InputArgs, FuncNum, "a1"))
	{
	// Запись имён функций в выходной буфер:
		PackArg(OutArgs.c_str(), FnNames,	"a1",	BufferPos);
		PackArg(OutArgs.c_str(), FnDesc,		"a2",	BufferPos);
	}
	else
// Описание аргументов функции
	{
		if ((FuncNum >= 0) && (FuncNum < REGISTERED_FUNCTIONS_ARGS.Size()))
		{
		// Функция
			PackArg(OutArgs.c_str(), FnNames[FuncNum],	"a1",	BufferPos);
			PackArg(OutArgs.c_str(), FnDesc[FuncNum],		"a2",	BufferPos);

		// Входные аргументы
			PackArg(	OutArgs.c_str(), 
						REGISTERED_FUNCTIONS_ARGS[FuncNum].InArgs_Type,
						"a3",
						BufferPos);
			PackArg(	OutArgs.c_str(), 
						REGISTERED_FUNCTIONS_ARGS[FuncNum].InArgs_Name,
						"a4",
						BufferPos);
			PackArg( OutArgs.c_str(), 
						REGISTERED_FUNCTIONS_ARGS[FuncNum].InArgs_Description,
						"a5",
						BufferPos);

		// Выходные аргументы
			PackArg(	OutArgs.c_str(), 
						REGISTERED_FUNCTIONS_ARGS[FuncNum].OutArgs_Type,
						"a6",
						BufferPos);
			PackArg(	OutArgs.c_str(), 
						REGISTERED_FUNCTIONS_ARGS[FuncNum].OutArgs_Name,
						"a7",
						BufferPos);
			PackArg(	OutArgs.c_str(), 
						REGISTERED_FUNCTIONS_ARGS[FuncNum].OutArgs_Description,
						"a8",
						BufferPos);
		}
		else
		{
			OBServer_result = OBServer_SYSTEM_ERROR;
		}

	}

	if (OBServer_result	== OBServer_OK)
	{
	}

	OBServer_WRAPPER_END;
}
开发者ID:RomanKoshelev,项目名称:school,代码行数:82,代码来源:OBServer_Interface.cpp


示例14: switch

QVariant OptionsModel::data(const QModelIndex & index, int role) const
{
    if(role == Qt::EditRole)
    {
        QSettings settings;
        switch(index.row())
        {
        case StartAtStartup:
            return QVariant(GUIUtil::GetStartOnSystemStartup());
        case MinimizeToTray:
            return QVariant(fMinimizeToTray);
        case MapPortUPnP:
            return settings.value("fUseUPnP", GetBoolArg("-upnp", true));
        case MinimizeOnClose:
            return QVariant(fMinimizeOnClose);
        case ProxyUse:
            return settings.value("fUseProxy", false);
        case ProxyIP: {
            proxyType proxy;
            if (GetProxy(NET_IPV4, proxy))
                return QVariant(QString::fromStdString(proxy.ToStringIP()));
            else
                return QVariant(QString::fromStdString("127.0.0.1"));
        }
        case ProxyPort: {
            proxyType proxy;
            if (GetProxy(NET_IPV4, proxy))
                return QVariant(proxy.GetPort());
            else
                return QVariant(9050);
        }
        case Fee:
            return QVariant((qint64) nTransactionFee);
        case ReserveBalance:
            return QVariant((qint64) nReserveBalance);
        case DisplayUnit:
            return QVariant(nDisplayUnit);
        case Language:
            return settings.value("language", "");
        case CoinControlFeatures:
            return QVariant(fCoinControlFeatures);
        case SandstormRounds:
            return QVariant(nSandstormRounds);
        case AnonymizeDarkSilkAmount:
            return QVariant(nAnonymizeDarkSilkAmount);
        case UseBlackTheme:
            return QVariant(fUseBlackTheme);
#ifdef USE_NATIVE_I2P
        case I2PUseI2POnly:
        {
            ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME);
            bool useI2POnly = false;
            if (mapArgs.count("-onlynet"))
            {
                const std::vector<std::string>& onlyNets = mapMultiArgs["-onlynet"];
                if (std::find(onlyNets.begin(), onlyNets.end(), NATIVE_I2P_NET_STRING) != onlyNets.end())
                    useI2POnly = true;
            }
            return settings.value("useI2POnly", useI2POnly);
        }
        case I2PSAMHost:
        {
            ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME);
            return settings.value("samhost", QString::fromStdString(GetArg(I2P_SAM_HOST_PARAM, I2P_SAM_HOST_DEFAULT)));
        }
        case I2PSAMPort:
        {
            ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME);
            return settings.value("samport", QString::number((qint64)GetArg(I2P_SAM_PORT_PARAM, I2P_SAM_PORT_DEFAULT)));
        }
        case I2PSessionName:
        {
            ScopeGroupHelper s(settings, I2P_OPTIONS_SECTION_NAME);
            return settings.value("sessionName", QString::fromStdString(GetArg(I2P_SESSION_NAME_PARAM, I2P_SESSION_NAME_DEFAULT)));
        }
        case I2PInboundQuantity:
            return QVariant(i2pInboundQuantity);
        case I2PInboundLength:
            return QVariant(i2pInboundLength);
        case I2PInboundLengthVariance:
            return QVariant(i2pInboundLengthVariance);
        case I2PInboundBackupQuantity:
            return QVariant(i2pInboundBackupQuantity);
        case I2PInboundAllowZeroHop:
            return QVariant(i2pInboundAllowZeroHop);
        case I2PInboundIPRestriction:
            return QVariant(i2pInboundIPRestriction);
        case I2POutboundQuantity:
            return QVariant(i2pOutboundQuantity);
        case I2POutboundLength:
            return QVariant(i2pOutboundLength);
        case I2POutboundLengthVariance:
            return QVariant(i2pOutboundLengthVariance);
        case I2POutboundBackupQuantity:
            return QVariant(i2pOutboundBackupQuantity);
        case I2POutboundAllowZeroHop:
            return QVariant(i2pOutboundAllowZeroHop);
        case I2POutboundIPRestriction:
            return QVariant(i2pOutboundIPRestriction);
        case I2POutboundPriority:
//.........这里部分代码省略.........
开发者ID:Infernoman,项目名称:DarkSilk-Release-Candidate,代码行数:101,代码来源:optionsmodel.cpp


示例15: LoadRootCAs


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetArgs函数代码示例发布时间:2022-05-30
下一篇:
C++ GetAreaFlagByAreaID函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap