void CCKAHUMTESTUI2Dlg::OnStmChange() 
{	
	CKAHFW::HNETWORKLIST hNetList = NULL;	

	CKAHUM::OpResult result = CKAHFW::GetNetworkList (&hNetList);

	if (result == CKAHUM::srOK)
	{
		int index = m_NetListCtrl.GetCurSel();		
		
		CKAHFW::Network network;
		
		if ((result = CKAHFW::NetworkList_GetItem (hNetList, index, &network)) == CKAHUM::srOK)
		{
            if (network.HasIPv4)
            {
                CKAHSTM::StmNet Net = { CKAHUM::IP(network.IPv4) , CKAHUM::IP(network.Maskv4) };
    			
			    ClearResult ();
			    result = CKAHSTM::AddNet( &Net );
			    SetResult (result);
            }
            if (network.HasIPv6)
            {
                CKAHSTM::StmNet Net = { CKAHUM::IP(network.IPv6) , CKAHUM::IP(network.Maskv6) };
    			
			    ClearResult ();
			    result = CKAHSTM::AddNet( &Net );
			    SetResult (result);
            }
		}

		CKAHFW::NetworkList_Delete (hNetList);
	}
}
void CCKAHUMTESTUI2Dlg::OnFwStop() 
{
	ClearResult ();
	CKAHUM::OpResult result = CKAHFW::Stop ();
	m_FirewallLevelSlider.EnableWindow (FALSE);
	SetResult (result);
}
Beispiel #3
0
/*--------------------------------------------------------------------------------*/
bool PostgresDatabase::Open(const AString& host, const AString& username, const AString& password, const AString& database)
{
	bool success = false;

	if (!conn) {
		AString str;

		ClearResult();

		connstr.Delete();
		connstr.printf("postgresql://%s:%s@%s", username.str(), password.str(), host.str());

		if (CheckConnection()) {
			str = connstr;
			if (database.Valid()) str.printf("/%s", database.ToLower().str());

			success = (((conn = PQconnectdb(str.str())) != NULL) && (PQstatus(conn) == CONNECTION_OK));
			if (success) {
				if (database.Valid()) debug("Connected to database '%s' on %s\n", database.str(), host.str());
				isopen = true;
			}
			else {
				if (database.Valid()) debug("Failed to connect to database '%s' on %s: %s\n", database.str(), host.str(), GetErrorMessage().str());
				else				  debug("Failed to connect server %s: %s\n", host.str(), GetErrorMessage().str());

				Close();
			}
		}
		else debug("No connection to server!\n");
	}

	return success;
}
Beispiel #4
0
//--------------------------------------------------------------------------------
void CLargeNamedPipeFile::Write(const void* lpBuf, UINT nCount)
	{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	if(nCount == 0)
		return;

	ClearResult();

	CNamedPipeFile::Write(&nCount, sizeof(nCount));
	if(HasErrors())
		return;

	UINT nRemaining = nCount;
	UINT nTotal = 0;
	char* pBuf = (char*) lpBuf;

	UINT nPackets = (nCount / 65535) + 1;

	for(UINT i = 0; i < nPackets; i++)
		{
		UINT nWrite = nRemaining > 65535 ? 65535 : nRemaining;
	
	TRACE("writing %d bytes\n", nWrite);

		CNamedPipeFile::Write(pBuf, nWrite);
		nRemaining -= nWrite;
		pBuf += nWrite;
		if(HasErrors())
			break;
		}
	}
void CDissolveDialog::Clear()
{
	if(mSourceDialog)
	{
		for(WORD cellIndex = 0; mSourceDialog->GetCellNum() > cellIndex; ++cellIndex)
		{
			CItem* const item = (CItem*)mSourceDialog->GetIconForIdx(
				cellIndex);
			CItem* const inventoryItem = ITEMMGR->GetItem(
				item->GetDBIdx());

			if(inventoryItem)
			{
				inventoryItem->SetLock(
					FALSE);
			}

			Clear(
				*item);
		}
	}

	ClearResult();
	mIsEffectStart = FALSE;
}
void CCKAHUMTESTUI2Dlg::OnSetparam() 
{
	UpdateData ();

	ClearResult ();
	CKAHUM::OpResult result = CKAHIDS::SetIDSParam (m_SetParamID, m_SetParamNum, m_SetParamValue);
	SetResult (result);
}
void WayPointSelector::EmitResult()
{
	if(!mWayPoint) return;
	ClearResult();
	mLastWayPoint = mWayPoint;
	mWayPoint = nullptr;
	SignalSelection.emit(mLastWayPoint);
}
void CCKAHUMTESTUI2Dlg::OnReload() 
{
	USES_CONVERSION;

	UpdateData ();
	ClearResult ();
	CKAHUM::OpResult result = CKAHUM::Reload (T2W((LPTSTR)(LPCTSTR)m_ReloadPath));
	SetResult (result);
}
void CRemotePlaybackDlg::OnPageUp() 
{
	
	// TODO: Add your control notification handler code here	
	if ( m_nGetPage <= 1 || m_nCurPage <= 1)
	{
		return;
	}
	
	m_nCurPage --;
	m_nGetPage --;
	
	ClearResult();
	
	m_mapNum=m_mapNum-1;
	
	if(GetNextPageInfo(&m_mapTemp[--m_mapNum]))
	{
		H264_DVR_FILE_DATA *szSend = new H264_DVR_FILE_DATA[100];
		
		int nNum=0;
		
		int nRet=H264_DVR_FindFile(m_lLoginID,&m_mapTemp[m_mapNum],szSend,100,&nNum);
		
		m_nCurRecNum=nNum;
		
		if(nRet > 0 && nNum > 0) //处理没有录象的情况
		{
			m_pstrFileVector.reserve(m_nCurRecNum);
			
			for ( int i = 0; i < m_nCurRecNum; i ++)
			{
				m_pstrFileVector.push_back(szSend+i);
			}
			m_nSearchInfo.nChannelN0=m_nSearchInfo.nChannelN0;
			m_nSearchInfo.nFileType=m_nSearchInfo.nFileType;
			m_nSearchInfo.startTime.dwYear=szSend[m_nCurRecNum-1].stEndTime.year;
			m_nSearchInfo.startTime.dwMonth=szSend[m_nCurRecNum-1].stEndTime.month;
			m_nSearchInfo.startTime.dwDay=szSend[m_nCurRecNum-1].stEndTime.day;
			m_nSearchInfo.startTime.dwHour=szSend[m_nCurRecNum-1].stEndTime.hour;
			m_nSearchInfo.startTime.dwMinute=szSend[m_nCurRecNum-1].stEndTime.minute;
			m_nSearchInfo.startTime.dwSecond=szSend[m_nCurRecNum-1].stEndTime.second;
			memcpy(&m_nSearchInfo.endTime,&m_mapTemp[m_mapNum].endTime,sizeof(m_nSearchInfo.endTime));
			
			m_mapNum++;
		}else
		{
			if (szSend)
			{
				delete szSend;
				szSend = NULL;
			}
		}
		AddFileListInfo(m_nCurRecNum);
		SetPageBtnState();
	}
}
Beispiel #10
0
/*--------------------------------------------------------------------------------*/
void PostgresDatabase::Close()
{
	ClearResult();
	if (conn) {
		PQfinish(conn);
		conn = NULL;
	}
	connstr.Delete();
	isopen = false;
}
void CCKAHUMTESTUI2Dlg::OnUnban() 
{
	UpdateData ();
	ClearResult ();
	CKAHUM::IP ip(0), mask(0);
    m_UnbanIPCtrl.GetAddress (ip.v4);
	m_UnbanMaskCtrl.GetAddress (mask.v4);
    CKAHUM::OpResult result = CKAHIDS::UnbanHost (&ip, &mask);
	SetResult (result);
}
NXCommandResult const *const
	NXRenderingEngine::addFrame(NXMoleculeSet *const molSetPtr)
{
	ClearResult(commandResult);
	NXSGNode *newFrame = createSceneGraph(molSetPtr);
	if(newFrame != (NXSGNode*) NULL) {
		moleculeSets.push_back(molSetPtr);
		frames.push_back(newFrame);
	}
	return &commandResult;
}
Beispiel #13
0
/*--------------------------------------------------------------------------------*/
SQLQuery *PostgresDatabase::RunQuery(const AString& sql)
{
	SQLQuery *query = NULL;

	if (conn) {
		ClearResult();
		query = new PostgresQuery(this, sql);

	}

	return query;
}
void CCKAHUMTESTUI2Dlg::OnSetidsparam() 
{
	UpdateData ();

	ClearResult ();
	ULONG ResponseFlags = (m_Deny ? FLAG_ATTACK_DENY : 0) |
							(m_Notify ? FLAG_ATTACK_NOTIFY : 0) |
							(m_Log ? FLAG_ATTACK_LOG : 0) |
							(m_Ban ? FLAG_ATTACK_BAN :0);
	CKAHUM::OpResult result = CKAHIDS::SetIDSAttackNotifyParam (m_SetIDSParamID, ResponseFlags, m_BanTime);
	SetResult (result);
}
Beispiel #15
0
/*--------------------------------------------------------------------------------*/
bool PostgresDatabase::RunSQL(const AString& sql)
{
	bool success = false;

	if (conn) {
		ClearResult();
		success = (((res = PQexec(conn, sql.str())) != NULL) && (PQresultStatus(res) == PGRES_COMMAND_OK));
		//debug("Running SQL '%s': %s\n", sql.str(), success ? "** success **" : GetErrorMessage().str());
	}

	return success;
}
/* CONSTRUCTOR */
NXRenderingEngine::NXRenderingEngine()
	: // rendererSet(),
	renderStyleMap(),
	graphicsManager(NULL),
	moleculeSets(),
	frames(),
	currentFrameIndex(-1),
	pluginsInitialized(false),
	commandResult()
{
	ClearResult(commandResult);
}
void CCKAHUMTESTUI2Dlg::OnGetparamcount() 
{
	UpdateData ();

	ClearResult ();
	ULONG Value = 0;
	CKAHUM::OpResult result = CKAHIDS::GetIDSParamCount (m_GetParamCountID, &Value);
	SetResult (result);
	if (result == CKAHUM::srOK)
	{
		SetDlgItemInt (IDC_GetParamCountValue, Value, FALSE);
	}
}
Beispiel #18
0
std::vector<fuzzy_obj> LuaWrap::GenerateListFromLuaTable()
{
    /*If I read the documentation correctly, lua_next empties the table and I end up cleaning the pushed key-value
    pairs, so I will flag this method as a single use method that calls clean stack and resets the state of result!
    Make sure you limit your script-engine communication such that this method is called once or the spawning
    script function is called multiple times!
    */
    std::vector<fuzzy_obj> tmp;
    lua_gettable(Lua, LUA_TOPITEM);//index of table
    size_t t = lua_tointeger(Lua, 2);
    if(lua_isnil(Lua, LUA_TOPITEM))//check the table is valid
        return tmp;

    lua_pushnil(Lua);//Push top key? http://pgl.yoyo.org/luai/i/lua_next //http://eliasdaler.wordpress.com/2013/10/20/lua_and_cpp_pt2/
    while(lua_next(Lua, t))//Obtain key-value pairs
    {
        fuzzy_obj obj;
        obj.flag = GetResultType(Lua);
        switch(obj.flag)
        {
        case 'i':
            obj.number = lua_extractInt(Lua);
            break;
        case 'd':
            obj.decimal = lua_extractDouble(Lua);
            break;
        case 'b':
            obj.answer = lua_extractBool(Lua);
            break;
        case 'c':
            obj.c = lua_extractChar(Lua);
            break;
        case 's':
            obj.str = lua_extractStr(Lua);
            break;
        case 'v':
            obj.ptr = lua_extractPtr(Lua);
            break;
        default:
            std::cout << "Error: Argument from array returned by script function is not a valid type! "
            << "Wow, the cake is a lie!" << std::endl;
        }
        tmp.push_back(obj);
    }

    //Let's clean the stack from the new items
    ClearResult();
    hasResult = false;//Flag the result as destroyed
    //Return copy of the vector!
    return tmp;
}
Beispiel #19
0
void WebRequestObject::RequestStart(const char* page)
{
    MyAssert( IsBusy() == false );
    if( IsBusy() )
        return;

    ClearResult();
    Reset();

    sprintf_s( m_PageWanted, MAX_URLLength, page );
    strcat_s( m_PageWanted, MAX_URLLength, "?" );

    //LOGInfo( LOGTag, "WebRequestObject - RequestStart %s\n", m_PageWanted );
}
Beispiel #20
0
void CImplVulfix::Reset()
{
	m_arrLeaks.RemoveAll();
	m_arrFixedVuls.RemoveAll();
	m_arrIgnoredVuls.RemoveAll();
	m_arrInvalid.RemoveAll();
	m_arrReplacedUpdates.RemoveAll();
	m_arrSoftLeaks.RemoveAll();

	ClearResult( m_arrIgnoredVulsFromSoft );
	m_dbOS.Reset();
	m_dbOffice.Reset();
	m_dbSoft.Reset();
}
void SectionSelector::EmitResult()
{
	if(!mSection) return;
	if(mSection == mLastSection)
	{
		mSection = nullptr;
		return;
	}
	ClearResult();
	mLastSection = mSection;
	mLastNearest = mNearest;
	mSection = nullptr;
	SignalSelection.emit(mLastSection, mLastNearest);
}
void CCKAHUMTESTUI2Dlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	if (nSBCode == SB_ENDSCROLL && pScrollBar->GetSafeHwnd () == m_FirewallLevelSlider.GetSafeHwnd ())
	{
		if (m_nLastSliderPos != m_FirewallLevelSlider.GetPos ())
		{
			ClearResult ();
			CKAHUM::OpResult result = CKAHFW::SetWorkingMode ((CKAHFW::WorkingMode)(m_nLastSliderPos = m_FirewallLevelSlider.GetPos ()));
			SetResult (result);
		}
	}
	
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
Beispiel #23
0
//--------------------------------------------------------------------------------
UINT CLargeNamedPipeFile::Read(void* lpBuf, UINT nCount)
	{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	// and i quote (CFile) avoid win32 null read
	if(nCount == 0)
		return 0;

	// total msg size in bytes
	UINT nSize;

	ClearResult();

	if(CNamedPipeFile::Read(&nSize, sizeof(nSize)) != sizeof(nSize))
		return 0;

	if(HasErrors())
		return 0;

	if(nCount > 0 && nCount < nSize)
		{
		SetResultCode(CResult::errOS);
		SetOSResult(ERROR_INSUFFICIENT_BUFFER);
		return 0;
		}

	UINT nRemaining = nCount;
	UINT nRead = 0;
	UINT nTotal = 0;
	char* pBuf = (char*) lpBuf;

	UINT nPackets = (nSize / 65535) + 1;

	for(UINT i = 0; i < nPackets; i++)
		{
		nRead = CNamedPipeFile::Read(pBuf, nRemaining > 65535 ? 65535 : nRemaining);

	TRACE("read %d bytes\n", nRead);

		nRemaining -= nRead;
		nTotal += nRead;
		pBuf += nRead;
		if(HasErrors())
			break;
		}

	return nTotal;
	}
void SectionEndSelector::EmitResult()
{
	if(!mSection) return;
	if(mSectionEnd == mLastSectionEnd)
	{
		mSection = nullptr;
		mSectionEnd = nullptr;
		return;
	}
	ClearResult();
	mLastSection = mSection;
	mLastSectionEnd = mSectionEnd;
	mSection = nullptr;
	mSectionEnd = nullptr;
	SignalSelection.emit(mLastSection, mLastSectionEnd);
}
void CSensor_btprox::BtDiscover() 
{
  guilogf("btprox: scanning...");

  SWAP(GPtrArray*, iResult, iOldResult);
  ClearResult(iResult);

  iInquirySockAddr.SetIAC(KGIAC);
  iInquirySockAddr.SetAction(KHostResInquiry|KHostResName);
  // We should also specify KHostResIgnoreCache if we did not
  // want cache BT friendly names, but in most cases we do not
  // require genuine name discovery, and device discovery is
  // slow enough as it is.
  iHostResolver.GetByAddress(iInquirySockAddr, iNameEntry, iStatus);
  SetActive();
  iState = EDiscovering;
}
void CCKAHUMTESTUI2Dlg::OnBreakConnection() 
{
	ClearResult ();
	CKAHUM::OpResult result = CKAHUM::srOpFailed;
	int nSelIndex = m_OpenConnectionListCtrl.GetCurSel ();
	
	if (nSelIndex != LB_ERR)
	{
		CKAHFW::Connection Connection;

		if (CKAHFW::ConnectionList_GetItem (m_hConnectionList, nSelIndex, &Connection) == CKAHUM::srOK)
		{
			result = CKAHFW::BreakConnection (Connection.Proto, &Connection.LocalIP,
										Connection.LocalPort, &Connection.RemoteIP, Connection.RemotePort);
		}
	}	
	SetResult (result);
}
void CCKAHUMTESTUI2Dlg::OnFwStart() 
{
	ClearResult ();
	CKAHUM::OpResult result = CKAHFW::Start (PacketRuleCallback, this,
												ApplicationRuleCallback, this,
												ChecksumChangedCallback, this);
	if (result == CKAHUM::srOK || result == CKAHUM::srAlreadyStarted)
	{
		CKAHFW::WorkingMode wm = CKAHFW::wmAllowNotFiltered;
		if (CKAHFW::GetWorkingMode (&wm) == CKAHUM::srOK)
		{
			m_FirewallLevelSlider.SetPos (m_nLastSliderPos = (int)wm);
			m_FirewallLevelSlider.EnableWindow (TRUE);
		}
	}

	SetResult (result);
}
Beispiel #28
0
bool LuaWrap::executeFunction(const std::string& funcName)
{
    size_t argCount = 0;
    int errStatus = 0;
    if(hasResult)
    {
        ClearResult();
    }

    //Now, let's set the function!
    lua_setglobal(Lua, funcName.c_str());
    if(lua_isfunction(Lua, LUA_TOPITEM))
    {
        std::cout << "Error attempting to run function: " << funcName <<". Check that the name is a valid Lua function in the current Engine Version!"
                  << std::endl;
        return false;
    }

    //Check for the presence of arguments before deciding how to run the function!
    if(!argStack->empty())
    {
        //Let's reverse the order of the stack. A queue would have done the same job, but I like stacks!
        *argStack = reverseOrderStack(*argStack);
        argCount = argStack->size();
        while(!argStack->empty())
        {
            PushToLua(Lua, argStack->top());
            argStack->pop();
        }
    }

    //Let's run the function!
    /*The following function uses a mixture of the Lua documentation (http://pgl.yoyo.org/luai/i/lua_pcall) and a stack overflow
    question about how to extract the stacktrace from the pcall execution function
    (http://stackoverflow.com/questions/12256455/print-stacktrace-from-c-code-with-embedded-lua)
    */
    errStatus = lua_pcall(Lua, argCount, LUA_MULTRET, lua_gettop(Lua) - LUA_TOPITEM - argCount);

    //Check status code
    ErrF(Lua, errStatus);
    return true;
}
bool NXRenderingEngine::importRendererPluginsFromGraphicsManager(void)
{
	ClearResult(commandResult);
	
	if(graphicsManager == NULL) {
		string const msg = "Graphics-manager not set";
		SetResult(commandResult, NX_INITIALIZATION_ERROR, msg);
		NXLOG_SEVERE("NXRenderingEngine (import plugins from graphics manager)",
		             msg);
		return false;
	}
	
	bool success = true;
	
	// rendererSet.clear();
	vector<string> renderStyleCodes = graphicsManager->getRenderStyles();
	vector<string>::const_iterator renderStyleCodeIter;
	for(renderStyleCodeIter = renderStyleCodes.begin();
	    renderStyleCodeIter != renderStyleCodes.end();
	    ++renderStyleCodeIter)
	{
		NXRendererPlugin *const plugin =
			graphicsManager->getRenderer(*renderStyleCodeIter);
		NXRendererPlugin *const renderer = plugin->newInstance(this);
		if(renderer == NULL) {
			string const& renderStyleName =
				graphicsManager->getRenderStyleName(*renderStyleCodeIter);
			string const msg = "Failed to create new instance of renderer-plugin"
				" for style '" + renderStyleName + "' from graphics-manager";
			NXLOG_SEVERE("NXRenderingEngine", msg);
			SetResult(commandResult, NX_PLUGIN_CAUSED_ERROR, msg);
			success = false;
		}
		else {
			renderStyleMap[*renderStyleCodeIter] = renderer;
			// rendererSet.push_back(renderer);
		}
	}
	
	return success;
}
void CCKAHUMTESTUI2Dlg::OnFwApprules() 
{
	ClearResult ();

	CKAHFW::HAPPRULES hRules = NULL;
	
	CKAHUM::OpResult result = CKAHFW::GetApplicationRules (&hRules);

	if (result == CKAHUM::srOK)
	{
		CApplicationRulesDlg ApplicationRulesDlg (hRules, this);
		
		if (ApplicationRulesDlg.DoModal () == IDOK)
		{
			result = CKAHFW::SetApplicationRules (ApplicationRulesDlg.m_hRules);
		}
	}

	CKAHFW::ApplicationRules_Delete (hRules);

	SetResult (result);
}