Exemple #1
0
BOOL CEditButton::Create(CWnd* pWnd, SEARCH_TYPE eType, UINT nMenu)
{
	ASSERT(eType != -1);
	ASSERT_VALID(pWnd);
	m_eType = eType;
	m_nMenu = nMenu;
	m_pWnd = pWnd;
	CWnd* pWndParent = m_pWnd->GetParent();
	ASSERT_VALID(pWndParent);
	
	CRect rc;
	m_pWnd->GetWindowRect(&rc);
	m_pWnd->SetWindowPos(NULL, 0, 0, rc.Width()-23,
		rc.Height(), SWP_NOZORDER|SWP_NOMOVE);
	pWndParent->ScreenToClient(&rc);
	rc.left = rc.right-18;

	DWORD dwStyle = WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_CENTER|BS_VCENTER;
	switch (m_eType)
	{
	case SEARCH_DIRECTORY:
	case SEARCH_FILE:
		{
			if (CButton::Create(_T("..."), dwStyle, rc,
				pWndParent, GetNextID(pWndParent)))
			{
				SetWindowPos(m_pWnd, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);
				EnableWindow(m_pWnd->IsWindowEnabled());
				SetFont(&m_Font);
				return TRUE;
			}
		}

	case SEARCH_POPUP:
		{
			if (CButton::Create(_T("..."), dwStyle|BS_ICON, rc,
				pWndParent, GetNextID(pWndParent)))
			{
				SetWindowPos(m_pWnd, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);
				EnableWindow(m_pWnd->IsWindowEnabled());
				SetFont(&m_Font);

				CImageList imageList;
				CBitmap    bitmap;

				bitmap.LoadBitmap(IDB_BTN_ARROW);
				imageList.Create(15, 17, ILC_COLORDDB|ILC_MASK, 1, 1);
				imageList.Add(&bitmap, RGB(255,0,255));

				SetIcon(imageList.ExtractIcon(0));

				imageList.Detach();
				bitmap.Detach();
				return TRUE;
			}
		}
	}

	return FALSE;
}
ServiceWorkerInfo::ServiceWorkerInfo(nsIPrincipal* aPrincipal,
                                     const nsACString& aScope,
                                     const nsACString& aScriptSpec,
                                     const nsAString& aCacheName,
                                     nsLoadFlags aImportsLoadFlags)
  : mPrincipal(aPrincipal)
  , mScope(aScope)
  , mScriptSpec(aScriptSpec)
  , mCacheName(aCacheName)
  , mState(ServiceWorkerState::EndGuard_)
  , mImportsLoadFlags(aImportsLoadFlags)
  , mServiceWorkerID(GetNextID())
  , mCreationTime(PR_Now())
  , mCreationTimeStamp(TimeStamp::Now())
  , mInstalledTime(0)
  , mActivatedTime(0)
  , mRedundantTime(0)
  , mServiceWorkerPrivate(new ServiceWorkerPrivate(this))
  , mSkipWaitingFlag(false)
  , mHandlesFetch(Unknown)
{
  MOZ_ASSERT(mPrincipal);
  // cache origin attributes so we can use them off main thread
  mOriginAttributes = mPrincipal->OriginAttributesRef();
  MOZ_ASSERT(!mScope.IsEmpty());
  MOZ_ASSERT(!mScriptSpec.IsEmpty());
  MOZ_ASSERT(!mCacheName.IsEmpty());

  // Scripts of a service worker should always be loaded bypass service workers.
  // Otherwise, we might not be able to update a service worker correctly, if
  // there is a service worker generating the script.
  MOZ_DIAGNOSTIC_ASSERT(mImportsLoadFlags & nsIChannel::LOAD_BYPASS_SERVICE_WORKER);
}
Exemple #3
0
bool CMOOSNavEngine::AddAcousticBeacon(const string & sName,
                                       int nChan,
                                       double dfTAT,
                                       double dfX,
                                       double dfY,
                                       double dfZ)
{

    //////////////////////////////////////////
    //            add a beacon
    CMOOSNavBeacon* pBeacon = new CMOOSNavBeacon;

    pBeacon->m_sName = sName;
    pBeacon->m_nID = GetNextID();
    
    pBeacon->m_State.m_dfX = dfX;
    pBeacon->m_State.m_dfY = dfY;
    pBeacon->m_State.m_dfZ = dfZ;
    
    pBeacon->m_dfTAT = dfTAT;
    pBeacon->m_nChan = nChan;    

    if(AddEntity(pBeacon))
    {
//        MOOSTrace("Added Beacon :\n\t");
//        pBeacon->Trace();
        m_Beacons.push_front(pBeacon);
    }

    return true;
    
}
Exemple #4
0
bool CMOOSNavEngine::MakeYawObservations(const CMOOSMsg &Msg, OBSLIST &ObsList)
{
    CMOOSObservation NewObs;
    NewObs.m_dfTime = Msg.m_dfTime;
    NewObs.m_dfData = Msg.m_dfVal;
    NewObs.m_dfDataStd = YAW_STD;
    NewObs.m_eType = CMOOSObservation::YAW;
    NewObs.m_nID = GetNextID();



    //use the message source to figure out the sensor this
    //corresponds to
    NewObs.m_pInterrogateSensor = GetSensorBySource(Msg.m_sSrc,Msg.m_sKey);

    if(NewObs.m_pInterrogateSensor!=NULL)
    {

        //overload noise
        if(NewObs.m_pInterrogateSensor->GetNoise()>=0)
        {
            NewObs.m_dfDataStd = NewObs.m_pInterrogateSensor->GetNoise();
        }

        ObsList.push_front(NewObs);
    }

    ObsList.push_front(NewObs);

    return true;
}
Exemple #5
0
bool CMOOSNavEngine::MakeBodyVelObservations(const CMOOSMsg &Msg, OBSLIST &ObsList,double dfSF)
{
    CMOOSObservation NewObs;
    NewObs.m_dfTime = Msg.m_dfTime;
    NewObs.m_dfData = Msg.m_dfVal;
    NewObs.m_dfDataStd = BODY_VEL_STD*dfSF;

    if(Msg.m_sKey.find("_Y")!=string::npos)
    {
        NewObs.m_eType = CMOOSObservation::BODY_VEL_Y;
    }
    else if(Msg.m_sKey.find("_X")!=string::npos)
    {
        NewObs.m_eType = CMOOSObservation::BODY_VEL_X;
    }

    NewObs.m_nID = GetNextID();

    //use the message source to figure out the sensor this
    //corresponds to
    NewObs.m_pInterrogateSensor = GetSensorBySource(Msg.m_sSrc,Msg.m_sKey);

    if(NewObs.m_pInterrogateSensor!=NULL)
    {
        //overload noise
        if(NewObs.m_pInterrogateSensor->GetNoise()>=0)
        {
            NewObs.m_dfDataStd = NewObs.m_pInterrogateSensor->GetNoise();
        }

        ObsList.push_front(NewObs);
    }
    return true;

}
Exemple #6
0
bool BreakptMgr::AddBreakpointByAddress(const wxString& address)
{
    BreakpointInfo bp;
    bp.memory_address = address;
    bp.origin = BO_Other;
    bp.internal_id = GetNextID();
    return AddBreakpoint(bp);
}
Exemple #7
0
	CConnection::CConnection() {
		m_ID = GetNextID();
		m_Address = "INVALID_ADDRESS";
		m_Port = 0;
		m_pPeer = NULL;
		m_pUser = NULL;
		m_ConnectionTime = 0;

	}
Exemple #8
0
void BreakptMgr::LoadSession(const SessionEntry& session)
{
    const std::vector<BreakpointInfo>& breakpoints = session.GetBreakpoints();
    for (std::vector<BreakpointInfo>::const_iterator itr = breakpoints.begin(); itr != breakpoints.end(); ++itr) {
        BreakpointInfo bp = *itr;
        bp.internal_id = GetNextID();
        bp.origin      = BO_Editor;
        AddBreakpoint(bp);
    }
    RefreshBreakpointMarkers();
}
Exemple #9
0
bool CMOOSNavEngine::AddTheVehicle(STRING_LIST &sParams)
{
    //////////////////////////////////////////
    //        add the vehicle itself!
    // overide this function to make more complex vehicles
    m_pTracked = new CMOOSNavVehicle;
    m_pTracked->m_nID = GetNextID();
    m_pTracked->m_sName="TheAUV";
    m_pTracked->SetEntityType(m_eVehicleType);
    m_pTracked->m_State.m_dfZ = 0;
    return AddEntity(m_pTracked);
}
Exemple #10
0
bool BreakptMgr::AddBreakpointByLineno(const wxString& file, const int lineno, const wxString& conditions/*=wxT("")*/, const bool is_temp, bool is_disabled)
{
    BreakpointInfo bp;
    bp.Create(file, lineno, GetNextID());
    bp.origin = BO_Editor;
    if (is_temp) {
        bp.bp_type = BP_type_tempbreak;
        bp.is_temp = true;
        
    } 
    bp.is_enabled = !is_disabled;
    bp.conditions = conditions;
    return AddBreakpoint(bp);
}
		int AddTimer (double interval, double delaySeconds=0, void *act=0,
			void *userData=0)
		{
			TIMER *timer = new0 TIMER;
			timer->mTimerID = GetNextID();
			timer->mInterval = interval;
			timer->Action = act;
			timer->UserData = userData;
			double startTime = GetTimeInSeconds();
			timer->StartTime = (float)startTime;
			startTime += delaySeconds;
			mMapTimers.insert(std::make_pair(startTime, timer));

			return timer->mTimerID;
		}
Exemple #12
0
void BreakptMgr::ReconcileBreakpoints(const std::vector<BreakpointInfo>& li)
{
    std::vector<BreakpointInfo> updated_bps;
    std::vector<BreakpointInfo>::const_iterator li_iter = li.begin();
    for (; li_iter != li.end(); ++li_iter) {
        int index = FindBreakpointById(li_iter->debugger_id, m_bps);
        if (index == wxNOT_FOUND) {

            if(IsDuplicate(*li_iter, updated_bps))
                continue;

            // This will happen e.g. if a bp was auto-set on Main()
            // If so, its internal_id will be invalid
            BreakpointInfo bp = *li_iter;
            bp.internal_id = GetNextID();
            updated_bps.push_back(bp);

        } else {
            // We've match the debugger_id from -break-list with a bp
            // Update the ignore-count, then store it in a new vector
            BreakpointInfo bp = m_bps.at(index);
            bp.ignore_number  = li_iter->ignore_number;
            bp.what           = li_iter->what;
            bp.at             = li_iter->at;

            // Remove it from the m_bps list
            m_bps.erase(m_bps.begin()+index);

            SetBestBPType(bp);  // as this might have just changed
            updated_bps.push_back(bp);
        }
    }
    // All the still-existing bps have been added to updated_bps
    // So throw away m_bps (which will contain stale bps) and replace with the new vector
    // First though, delete all markers. Otherwise, if the last in a file has been deleted...
    DeleteAllBreakpointMarkers();

    // All the stale breakpoints should be assigned to the 'm_pendingBreakpointList'
    m_pendingBreakpointsList = m_bps;

    m_bps.clear();
    SetBreakpoints(updated_bps);

    RefreshBreakpointMarkers();
    // update the Breakpoints pane too
    clMainFrame::Get()->GetDebuggerPane()->GetBreakpointView()->Initialize();
}
Exemple #13
0
//DLLの初期化
//戻り値:
// エラーコード
//引数:
// asyncMode		[IN]TRUE:非同期モード、FALSE:同期モード
// id				[OUT]識別ID
DWORD WINAPI InitializeEP(
	BOOL asyncFlag,
	DWORD* id
	)
{
	if( id == NULL ){
		return ERR_INVALID_ARG;
	}

	CEpgDataCap3Main* main = new CEpgDataCap3Main;
	DWORD err = main->Initialize(asyncFlag);
	if( err == NO_ERR ){
		*id = GetNextID();
		g_List.insert(pair<DWORD, CEpgDataCap3Main*>(*id, main));
	}
	return err;
}
ServiceWorkerInfo::ServiceWorkerInfo(nsIPrincipal* aPrincipal,
                                     const nsACString& aScope,
                                     const nsACString& aScriptSpec,
                                     const nsAString& aCacheName)
  : mPrincipal(aPrincipal)
  , mScope(aScope)
  , mScriptSpec(aScriptSpec)
  , mCacheName(aCacheName)
  , mState(ServiceWorkerState::EndGuard_)
  , mServiceWorkerID(GetNextID())
  , mServiceWorkerPrivate(new ServiceWorkerPrivate(this))
  , mSkipWaitingFlag(false)
{
  MOZ_ASSERT(mPrincipal);
  MOZ_ASSERT(!mScope.IsEmpty());
  MOZ_ASSERT(!mScriptSpec.IsEmpty());
  MOZ_ASSERT(!mCacheName.IsEmpty());
}
BOOL MNMeshLoopAdvancer::Advance(MNMeshLoopFront* front, MNMeshLoopItem* item)
{
  if (front->nextid < 0)
    return TRUE;


  int newid = front->nextid;
  item->previndex = front->previndex;
  item->id = newid;
  item->pos = GetPos(newid);
  front->previd = newid;


  // check for next connector
  front->connector = GetNextConnector(front->connector,front->contype,newid);
  //front->connector = front->connector == newconnector ? -1 : newconnector;
  front->nextid = front->connector < 0 ? -1 : GetNextID(front->connector,front->contype,newid);

  return FALSE;
}
BOOL CFileStreamingManager::OpenFile(
	LPCWSTR filePath,
	DWORD* ctrlID
	)
{
	if( Lock() == FALSE ) return FALSE;
	BOOL ret = TRUE;

	CFileStreamingUtil* util = new CFileStreamingUtil;
	if( util->OpenFile(filePath) == FALSE ){
		SAFE_DELETE(util);
		UnLock();
		return FALSE;
	}else{
		*ctrlID = GetNextID();
		this->utilMap.insert(pair<DWORD, CFileStreamingUtil*>(*ctrlID, util));
	}

	UnLock();
	return ret;
}
Exemple #17
0
bool CMOOSNavEngine::AddSensor(const string & sSource,
                               const string &sName,
                               CMOOSNavSensor::Type eType,
                               double dfX,
                               double dfY,
                               double dfZ,
                               double dfNoise)
{
    //////////////////////////////////////////
    //            add an new sensor
    CMOOSNavSensor * pNewSensor = new CMOOSNavSensor;
    pNewSensor->m_nID = GetNextID();
    pNewSensor->m_sName=sName;
    pNewSensor->m_eType = eType;
    pNewSensor->m_sMOOSSource = sSource;
    pNewSensor->SetNoise(dfNoise);
    if(m_pTracked!=NULL)
    {
        m_pTracked->AddSensor(pNewSensor);

        string sKey = sSource+":"+sName;
        if(m_SourceToSensorMap.find(sName)==m_SourceToSensorMap.end())
        {
            m_SourceToSensorMap[sKey] = pNewSensor;
            MOOSTrace("Added new sensor:\n\t\"%s\" @ %f %f %f\n",sKey.c_str(),dfX,dfY,dfZ);

        }
        else
        {
            MOOSTrace("Error Sensor \"%s\" already exists \n",sKey.c_str());
            return false;
        }
    }
    else
    {
        return false;
    }
    
    return true;
}
BOOL MNMeshLoopAdvancer::Advance(MNMeshLoopFront* front, MNMeshLoopItem* item, int itemindex, int wave, BitArray &finalsel)
{
  if (front->nextid < 0 || (front->crossed && finalsel[front->nextid]))
    return TRUE;


  int newid = front->nextid;
  item->wave = wave;
  item->previndex = front->previndex;
  item->id = newid;
  item->pos = GetPos(newid);
  front->previndex = itemindex;
  front->previd = newid;

  front->crossed = finalsel[newid];
  finalsel.Set(newid);

  // check for next connector
  front->connector = GetNextConnector(front->connector,front->contype,newid);
  //front->connector = front->connector == newconnector ? -1 : newconnector;
  front->nextid = front->connector < 0 ? -1 : GetNextID(front->connector,front->contype,newid);

  return FALSE;
}
Exemple #19
0
bool CMOOSNavEngine::AddFixedObservation(CMOOSObservation::Type eType, double dfVal, double dfStd)
{
    CMOOSObservation NewFixedObs;

    NewFixedObs.m_dfData = dfVal;
    NewFixedObs.m_dfDataStd = dfStd;
    NewFixedObs.m_eType = eType;
    NewFixedObs.m_nID = GetNextID();
    NewFixedObs.m_dfTime = -1;
    NewFixedObs.SetFixed(true);
    NewFixedObs.UsingHeadingBias(m_bEstimateHeadingBias);

    NewFixedObs.m_pInterrogateSensor = GetSensorByName("COG");

    if(NewFixedObs.m_pInterrogateSensor==NULL)
    {
        return false;
    }

    m_FixedObservations.push_back(NewFixedObs);

    return true;

}
Exemple #20
0
DWORD WINAPI thread_func (LPVOID param)
{
    thread_t *t = (thread_t *)param;
    char szStrTo[512];
    RETCODE rc;
    SDWORD cbRet = SQL_DATA_AT_EXEC,
	cb1 = SQL_NULL_DATA,
	cb2 = SQL_NULL_DATA,
	cb3 = SQL_NULL_DATA,
	cb4 = SQL_NULL_DATA,
	cb5 = SQL_NULL_DATA,
	cb6 = SQL_NULL_DATA,
	cb7 = SQL_NULL_DATA,
	cb8 = SQL_NULL_DATA;
    szStrTo[0] = 0;
    ::WideCharToMultiByte (CP_ACP, 0, t->bStrTo, -1, szStrTo, sizeof (szStrTo), NULL, NULL);
    CDBConnection *conn = _ppool->getConnection();
//    _Module.LogEvent ("After conn");
//    _Module.LogEvent ("From: %s, To: %s, CC: %s, BCC: %s, Subject: %s, SentOn :%s", 
//	szStrFrom, szStrTo, szStrCC, szStrBCC, szStrSubj, szStrSent);
    long ofs = 0;
    char szTo[512];
    while (-1 != (ofs = GetNextID (szStrTo, ofs, szTo)))
    {
    cb1 = SQL_NULL_DATA;
    HSTMT hstmt = SQL_NULL_HSTMT;
    try 
    {
	int reconnect_count;
again:
	reconnect_count = 0;
	hstmt = SQL_NULL_HSTMT;
	if (SQL_SUCCESS != SQLAllocStmt (conn->hdbc, &hstmt))
	    throw _T ("SQLAllocStmt error");

//	SQLSetStmtOption (hstmt, SQL_QUERY_TIMEOUT, 10);
	SQLSetParam (hstmt, 1, SQL_C_CHAR, SQL_CHAR, 0, 0, szTo, szTo[0] ? NULL : &cb1);
	SQLSetParam (hstmt, 2, SQL_C_WCHAR, SQL_CHAR, 0, 0, t->bStrSubj, t->bStrSubj[0] ? NULL : &cb2);
	SQLSetParam (hstmt, 3, SQL_C_WCHAR, SQL_CHAR, 0, 0, t->bStrCC, t->bStrCC[0] ? NULL : &cb3);
	SQLSetParam (hstmt, 4, SQL_C_WCHAR, SQL_CHAR, 0, 0, t->bStrBCC, t->bStrBCC[0] ? NULL : &cb4);
	SQLSetParam (hstmt, 5, SQL_C_WCHAR, SQL_CHAR, 0, 0, t->bStrSent, t->bStrSent[0] ? NULL : &cb5);
	SQLSetParam (hstmt, 6, SQL_C_WCHAR, SQL_CHAR, 0, 0, t->bStrTo, t->bStrTo[0] ? NULL : &cb6);
	SQLSetParam (hstmt, 7, SQL_C_WCHAR, SQL_CHAR, 0, 0, t->bStrFrom, t->bStrFrom[0] ? NULL : &cb7);
	SQLSetParam (hstmt, 8, SQL_C_WCHAR, SQL_LONGVARCHAR, 0, 0, t->bStrContent, t->bStrContent[0] ? NULL : &cb8);
//        _Module.LogEvent ("After setparam");
	rc = SQLExecDirect (hstmt, 
	    (SQLCHAR *)"BARE_NEW_MAIL (?, ?, ?, ?, ?, ?, ?, ?)", SQL_NTS);
	if (rc != SQL_SUCCESS && !reconnect_count)
	{
	    conn->ReportODBCError (hstmt, "Retry SQLExec error");
	    _Module.LogEvent ("Reconnecting ...");
	    reconnect_count = 1;
	    SQLFreeStmt (hstmt, SQL_DROP);
	    hstmt = SQL_NULL_HSTMT;
	    delete conn;
	    conn = new CDBConnection ();
	    goto again;
	}
	else if (rc != SQL_SUCCESS)
	{
	    throw _T("SQLExec Error");
	}


	SQLFreeStmt (hstmt, SQL_DROP);
//	SQLFreeStmt (hstmt, SQL_RESET_PARAMS);
	_Module.LogEvent ("Message (%ld chars) from %s routed to %s", wcslen (t->bStrContent), (char *)(bstr_t)t->bStrFrom, (char *)(bstr_t)t->bStrTo);
    }
    catch (TCHAR *ch)
    {
	int deadlock = conn->ReportODBCError (hstmt, ch);
//	SQLFreeStmt (hstmt, SQL_RESET_PARAMS);
	if (deadlock)
	    goto again;
	_ppool->releaseConnection(conn);
	delete t;
    }
    }
    _ppool->releaseConnection(conn);
    delete t;
    return 0;
}
Exemple #21
0
bool CMOOSNavEngine::MakeLBLObservations(const CMOOSMsg &Msg, OBSLIST &ObsList)
{
    //this is LBL data    
    string sData = Msg.m_sVal;
    
    //what time was interrogation sent?
    MOOSChomp(sData,"Tx=");
    double dfTxTime = atof(MOOSChomp(sData,",").c_str());
    
    if(dfTxTime<=0)
    {
        MOOSTrace("Tx time of LBL is not positive\n");
        return false;
    }
    
    while(!sData.empty())
    {
        //for each reply...
        CMOOSObservation NewObs;
        string sChunk = MOOSChomp(sData,",");

        MOOSChomp(sChunk,"Ch[");

        int nChan = atoi(sChunk.c_str());
        
        if(nChan<=0 || nChan > 14)
        {
            MOOSTrace("Channel of LBL obs is not valid\n");
            continue;
        }


        NewObs.m_nChan = nChan;
        
        //figure out the beacon from the channel....
        CMOOSNavBeacon * pBeacon = GetBeaconByChannel(nChan);
        
        if(pBeacon==NULL)
        {
            MOOSTrace("Warning: No known Beacon with Channel[%d]\n",nChan);
        }

        

        //so what was the observation - the TOF?
        MOOSChomp(sChunk,"=");
        double dfTOF = atof(sChunk.c_str());
        if(dfTOF<=0)
        {
            MOOSTrace("TOF of LBL obs is not valid\n");
            return false;
        }
        NewObs.m_dfData = dfTOF;
        

        //set obs time Tx Time plus in water time
        NewObs.m_dfTime = dfTxTime+dfTOF;

//        MOOSTrace("Making LBL Obs.dfTime = %f and now = %f\n",NewObs.m_dfTime,MOOSTime());
        
        //set obs type 
        NewObs.m_eType = CMOOSObservation::LBL_BEACON_2WR;
        
        //give it a unique id
        NewObs.m_nID = GetNextID();


        //use the message source to figure out the sensor this
        //corresponds to
        NewObs.m_pInterrogateSensor = GetSensorBySource(Msg.m_sSrc,Msg.m_sKey);

        if(NewObs.m_pInterrogateSensor==NULL)
        {
            return false;
        }
        
        //set observation noise
        NewObs.m_dfDataStd = LBL_2WR_STD;
        if(NewObs.m_pInterrogateSensor->GetNoise()>=0)
        {
            NewObs.m_dfDataStd = NewObs.m_pInterrogateSensor->GetNoise();
        }
        
        //what other responding sensor was involved?
        if(pBeacon!=NULL)
        {
            NewObs.m_pRespondingSensor = pBeacon->GetSensorByType(CMOOSNavSensor::LBL);
        }
        else
        {
            NewObs.m_pRespondingSensor=NULL;
        }
        

        //this is an acoustic obs so set the sound velocity
        NewObs.m_dfSV = m_dfSV;
        //finally add the obs to the list
        if(NewObs.m_pRespondingSensor!=NULL)
        {
            ObsList.push_back(NewObs);
        }

/*        MOOSTrace("NewLBL: MOOSTime = %.3f,msgtime= %.3f,datatime = %.3f,TxTime = %.3f, cTOF= %.3f\n",
            MOOSTime(),
            Msg.m_dfTime,
            NewObs.m_dfTime,
            dfTxTime,
            NewObs.m_dfTime-dfTxTime);*/

    }
    
    return true;
}
Exemple #22
0
void BaseTCPServer::ListenNewConnections() {
	SOCKET tmpsock;
	struct sockaddr_in	from;
	struct in_addr	in;
	unsigned int	fromlen;
	unsigned short	port;

	from.sin_family = AF_INET;
	fromlen = sizeof(from);
	LockMutex lock(&MSock);
#ifndef DARWIN // Corysia - On OSX, 0 is a valid fd.
	if (!sock)
		return;
#else
	if (sock == -1) return;
#endif

	// Check for pending connects
#ifdef _WINDOWS
	unsigned long nonblocking = 1;
	while ((tmpsock = accept(sock, (struct sockaddr*) &from, (int *) &fromlen)) != INVALID_SOCKET) {
		ioctlsocket (tmpsock, FIONBIO, &nonblocking);
#else
#ifdef __CYGWIN__
	while ((tmpsock = accept(sock, (struct sockaddr *) &from, (int *) &fromlen)) != INVALID_SOCKET) {
#else
	while ((tmpsock = accept(sock, (struct sockaddr*) &from, &fromlen)) != INVALID_SOCKET) {
#endif
		fcntl(tmpsock, F_SETFL, O_NONBLOCK);
#endif
		int bufsize = 64 * 1024; // 64kbyte recieve buffer, up from default of 8k
		setsockopt(tmpsock, SOL_SOCKET, SO_RCVBUF, (char*) &bufsize, sizeof(bufsize));
		port = from.sin_port;
		in.s_addr = from.sin_addr.s_addr;

		// New TCP connection, this must consume the socket.
		CreateNewConnection(GetNextID(), tmpsock, in.s_addr, ntohs(from.sin_port));
	}
}

bool BaseTCPServer::Open(uint16 in_port, char* errbuf) {
	if (errbuf)
		errbuf[0] = 0;
	LockMutex lock(&MSock);
	if (sock != 0) {
		if (errbuf)
			snprintf(errbuf, TCPServer_ErrorBufferSize, "Listening socket already open");
		return false;
	}
	if (in_port != 0) {
		pPort = in_port;
	}

#ifdef _WINDOWS
	SOCKADDR_IN address;
	unsigned long nonblocking = 1;
#else
	struct sockaddr_in address;
#endif
	int reuse_addr = 1;

//	Setup internet address information.
//	This is used with the bind() call
	memset((char *) &address, 0, sizeof(address));
	address.sin_family = AF_INET;
	address.sin_port = htons(pPort);
	address.sin_addr.s_addr = htonl(INADDR_ANY);

//	Setting up TCP port for new TCP connections
	sock = socket(AF_INET, SOCK_STREAM, 0);
	if (sock == INVALID_SOCKET) {
		if (errbuf)
			snprintf(errbuf, TCPServer_ErrorBufferSize, "socket(): INVALID_SOCKET");
		return false;
	}

// Quag: dont think following is good stuff for TCP, good for UDP
// Mis: SO_REUSEADDR shouldn't be a problem for tcp--allows you to restart
// without waiting for conns in TIME_WAIT to die
	setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &reuse_addr, sizeof(reuse_addr));


	if (bind(sock, (struct sockaddr *) &address, sizeof(address)) < 0) {
#ifdef _WINDOWS
		closesocket(sock);
#else
		close(sock);
#endif
		sock = 0;
		if (errbuf)
			sprintf(errbuf, "bind(): <0");
		return false;
	}

	int bufsize = 64 * 1024; // 64kbyte recieve buffer, up from default of 8k
	setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char*) &bufsize, sizeof(bufsize));
#ifdef _WINDOWS
	ioctlsocket (sock, FIONBIO, &nonblocking);
#else
	fcntl(sock, F_SETFL, O_NONBLOCK);
#endif

	if (listen(sock, SOMAXCONN) == SOCKET_ERROR) {
#ifdef _WINDOWS
		closesocket(sock);
		if (errbuf)
			snprintf(errbuf, TCPServer_ErrorBufferSize, "listen() failed, Error: %d", WSAGetLastError());
#else
		close(sock);
		if (errbuf)
			snprintf(errbuf, TCPServer_ErrorBufferSize, "listen() failed, Error: %s", strerror(errno));
#endif
		sock = 0;
		return false;
	}

	return true;
}

void BaseTCPServer::Close() {
	StopLoopAndWait();

	LockMutex lock(&MSock);
	if (sock) {
#ifdef _WINDOWS
		closesocket(sock);
#else
		close(sock);
#endif
	}
	sock = 0;
}

bool BaseTCPServer::IsOpen() {
	MSock.lock();
	bool ret = (bool) (sock != 0);
	MSock.unlock();
	return ret;
}
Exemple #23
0
BOOL CParseEpgAutoAddText::ParseText(LPCWSTR filePath)
{
	if( filePath == NULL ){
		return FALSE;
	}

	map<DWORD, EPG_AUTO_ADD_DATA*>::iterator itr;
	for( itr = this->dataIDMap.begin(); itr != this->dataIDMap.end(); itr++ ){
		SAFE_DELETE(itr->second)
	}
	this->dataIDMap.clear();
	this->nextID = 1;

	this->loadFilePath = filePath;

	HANDLE hFile = _CreateFile2( filePath, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
	if( hFile == INVALID_HANDLE_VALUE ){
		return FALSE;
	}
	DWORD dwFileSize = GetFileSize( hFile, NULL );
	if( dwFileSize == 0 ){
		CloseHandle(hFile);
		return TRUE;
	}
	char* pszBuff = new char[dwFileSize+1];
	if( pszBuff == NULL ){
		CloseHandle(hFile);
		return FALSE;
	}
	ZeroMemory(pszBuff,dwFileSize+1);
	DWORD dwRead=0;
	ReadFile( hFile, pszBuff, dwFileSize, &dwRead, NULL );

	string strRead = pszBuff;

	CloseHandle(hFile);
	SAFE_DELETE_ARRAY(pszBuff)

	string parseLine="";
	size_t iIndex = 0;
	size_t iFind = 0;
	while( iFind != string::npos ){
		iFind = strRead.find("\r\n", iIndex);
		if( iFind == (int)string::npos ){
			parseLine = strRead.substr(iIndex);
			//strRead.clear();
		}else{
			parseLine = strRead.substr(iIndex,iFind-iIndex);
			//strRead.erase( 0, iIndex+2 );
			iIndex = iFind + 2;
		}
		//先頭;はコメント行
		if( parseLine.find(";") != 0 ){
			//空行?
			if( parseLine.find("\t") != string::npos ){
				EPG_AUTO_ADD_DATA* item = new EPG_AUTO_ADD_DATA;
				BOOL bRet = Parse1Line(parseLine, item);
				if( bRet == FALSE ){
					SAFE_DELETE(item)
				}else{
					item->dataID = GetNextID();
					this->dataIDMap.insert( pair<DWORD, EPG_AUTO_ADD_DATA*>(item->dataID,item) );
				}
			}
		}
	}
Exemple #24
0
// Add a breakpoint using the 'Properties' dialog
void BreakptMgr::AddBreakpoint()
{
    BreakptPropertiesDlg dlg(NULL);
    dlg.SetTitle(_("Create a breakpoint or watchpoint"));

    LEditor* const editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
    BreakpointInfo bp;
    bp.Create(editor ? editor->GetFileName().GetFullPath() : wxString(), editor ? editor->GetCurrentLine() : -1, GetNextID());
    dlg.EnterBPData(bp);

    if (dlg.ShowModal() != wxID_OK) {
        return;
    }

    if (AddBreakpoint(dlg.b)) {
        IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
        if ((!dlg.b.is_enabled) && dbgr && dbgr->IsRunning()) {
            SetBPEnabledState(dlg.b.debugger_id, dlg.b.is_enabled);
        }
        wxString msg;
        if (dlg.b.bp_type == BP_type_watchpt) {
            msg = _("Watchpoint successfully added");
        } else {
            msg = _("Breakpoint successfully added");
        }
        clMainFrame::Get()->SetStatusMessage(msg, 0);
    }
}