void
CPulseGenerator::RequestPulse( void )
{   GUCEF_TRACE;

    LockData();
    // Are we already doing period updates ?
    if ( m_periodicUpdateRequestors.size() == 0 )
    {
        // We are not so we must trigger an update either by delegation to a
        // driver or by doing so directly
        if ( NULL != m_driver )
        {
            UnlockData();
            m_driver->RequestPulse( *this );
        }
        else
        {
            UInt64 newTickCount = GUCEFGetTickCount();
            UInt64 deltaTicks = newTickCount - m_lastCycleTickCount;
            CPulseData pulseData( newTickCount, deltaTicks, 0);
            m_lastCycleTickCount = newTickCount;
            UnlockData();

            NotifyObservers( PulseEvent, &pulseData );
        }
    }
}
void
CPulseGenerator::RequestPeriodicPulses( void* requestor )
{   GUCEF_TRACE;

    LockData();
    m_periodicUpdateRequestors[ requestor ] = m_updateDeltaInMilliSecs;
    if ( m_driver != NULL && m_periodicUpdateRequestors.size() == 1 )
    {
        UnlockData();
        m_driver->RequestPeriodicPulses( *this, m_updateDeltaInMilliSecs );
        return;
    }
    UnlockData();
}
void
CPulseGenerator::ForceStopOfPeriodicPulses( void )
{   GUCEF_TRACE;

    LockData();
    m_forcedStopOfPeriodPulses = true;
    if ( NULL != m_driver )
    {
        UnlockData();
        m_driver->RequestStopOfPeriodicUpdates( *this );
        return;
    }
    UnlockData();
}
void
CPulseGenerator::RequestPeriodicPulses( void )
{   GUCEF_TRACE;

    LockData();
    if ( !m_forcedStopOfPeriodPulses )
    {
        if ( NULL != m_driver )
        {
            UnlockData();
            m_driver->RequestPeriodicPulses( *this, m_updateDeltaInMilliSecs );
            return;
        }
    }
    UnlockData();
}
Пример #5
0
int WINAPI LibMain( HINSTANCE hInstance,
                        WORD wDataSegment,
                        WORD wHeapSize,
                        LPSTR lpszCmdLine )
#endif
{
#ifndef WIN32
/* The startup code for the DLL initializes the local heap(if there is one)
 with a call to LocalInit which locks the data segment. */

if ( wHeapSize != 0 )
   {
   UnlockData( 0 );
   }
hCurrentInst = hInstance;
return 1;   /* Indicate that the DLL was initialized successfully. */
#else
BOOL rc = TRUE;
switch( dwReason )
   {
   case DLL_PROCESS_ATTACH:
      // DLL is loaded. Do your initialization here.
      // If cannot init, set rc to FALSE.
      hCurrentInst = hInstance;
      break;

   case DLL_PROCESS_DETACH:
      // DLL is unloaded. Do your cleanup here.
      break;
   default:
      break;
   }
return rc;
#endif
}
Пример #6
0
int FAR PASCAL LibMain(HANDLE hInstance, WORD wDataSeg, WORD cbHeapSize,
                       LPSTR lpszCmdLine)
{
    HDC hScreenDC = GetDC(NULL);
    
    bProtectedLock = (GetWinFlags() & WF_PMODE) != FALSE;
    hWndKalView = NULL;
    klwLGBrush = GetStockObject(LTGRAY_BRUSH);
    klwDGBrush = GetStockObject(DKGRAY_BRUSH);
    klwBBrush = GetStockObject(BLACK_BRUSH);
    klwNBrush = GetStockObject(NULL_BRUSH);
    klwBPen = GetStockObject(BLACK_PEN);
    hInstKlwDll = hInstance;
    srclns.lines = 0;
    dbgstack = NULL;
    varstack = NULL;
    break_on_call = FALSE;

    sXPixels = GetDeviceCaps(hScreenDC, HORZRES);
    sYPixels = GetDeviceCaps(hScreenDC, VERTRES);
    ReleaseDC(NULL, hScreenDC);
    
    SaveOrigDataSeg(wDataSeg);
    
    if (cbHeapSize != 0)
    	UnlockData(0);

    return TRUE;
}
void
CPulseGenerator::RequestStopOfPeriodicUpdates( void* requestor )
{   GUCEF_TRACE;

    LockData();
    if ( NULL != requestor )
    {
        m_periodicUpdateRequestors.erase( requestor );
    }

    // Determine the new common divider interval for all clients
    m_updateDeltaInMilliSecs = DetermineRequiredPulseInterval();

    // Check if we have a driver we can pass the request on to
    if ( NULL != m_driver )
    {
        // Depending on whether we have more clients wanting updates
        // we should either update the frequency or switch to manually requested pulses
        if ( !m_periodicUpdateRequestors.empty() )
        {
            m_driver->RequestPulseInterval( *this, m_updateDeltaInMilliSecs );
        }
        else
        {
            m_driver->RequestStopOfPeriodicUpdates( *this );
        }
    }
    UnlockData();
}
Пример #8
0
int LibMain(HANDLE hinst, WORD wDataSeg, 
					WORD cbHeapSize, LPSTR lpszCmdLine)
{   
	if (cbHeapSize>0)
		UnlockData(0);
		
	return (hinst ? 1 : 0);
}                    
void
CPulseGenerator::RequestPulseInterval( const UInt32 minimalPulseDeltaInMilliSecs )
{   GUCEF_TRACE;

    LockData();
    if ( minimalPulseDeltaInMilliSecs < m_updateDeltaInMilliSecs )
    {
        if ( NULL != m_driver )
        {
            m_updateDeltaInMilliSecs = minimalPulseDeltaInMilliSecs;
            UnlockData();
            m_driver->RequestPulseInterval( *this, m_updateDeltaInMilliSecs );
            return;
        }
    }
    UnlockData();
}
void
CLogSvcClient::SetApplicationName( const CORE::CString& applicationName )
{GUCEF_TRACE;

    LockData();
    m_appName = applicationName;
    UnlockData();
}
void
CPulseGenerator::AllowPeriodicPulses( void )
{   GUCEF_TRACE;

    LockData();
    if ( m_forcedStopOfPeriodPulses )
    {
        m_forcedStopOfPeriodPulses = false;
        if ( NULL != m_driver && m_periodicUpdateRequestors.size() > 0 )
        {
            UnlockData();
            m_driver->RequestPeriodicPulses( *this, m_updateDeltaInMilliSecs );
            return;
        }
    }
    UnlockData();
}
void
CPulseGenerator::SetPulseGeneratorDriver( CIPulseGeneratorDriver* driver )
{   GUCEF_TRACE;

    LockData();
    m_driver = driver;
    if ( IsPulsingPeriodicly() )
    {
        UnlockData();
        m_driver->RequestPulseInterval( *this, m_updateDeltaInMilliSecs );
    }
    else
    {
        UnlockData();
        m_driver->RequestPulse( *this );
    }
}
Пример #13
0
void
CObservingNotifier::UnsubscribeAllFromObserver( void )
{GUCEF_TRACE;

    LockData();
    m_observer.UnsubscribeAllFromObserver();
    UnlockData();
}
Пример #14
0
UInt32
CObservingNotifier::GetObserverNotifierCount( void )
{GUCEF_TRACE;

    LockData();
    UInt32 retval( m_observer.GetNotifierCount() );
    UnlockData();
    return retval;
}
Пример #15
0
// Every DLL has an entry point LibMain and an exit point WEP.
int FAR PASCAL LibMain( HINSTANCE hInstance, WORD wDataSegment,
                                   WORD wHeapSize, LPSTR lpszCmdLine )
{
    // The startup code for the DLL initializes the local heap (if there is one)
    // with a call to LocalInit which locks the data segment.
    if ( wHeapSize != 0 )
        UnlockData( 0 );
    return 1;   // Indicate that the DLL was initialized successfully.
}
Пример #16
0
int FAR PASCAL LibMain ( HANDLE hInstance, WORD wDataSeg, WORD wHeapSize,
                         LPSTR  lpszCmdLine )
{
        if ( wHeapSize > 0 )
                UnlockData (0);

        a = 1;

        return 1;
}
Пример #17
0
void
CObservingNotifier::UnsubscribeFrom( CNotifier* notifier )
{GUCEF_TRACE;

    if ( NULL != notifier )
    {
        LockData();
        notifier->Unsubscribe( &m_observer );
        UnlockData();
    }
}
Пример #18
0
char * PlotWndPropText::GetText(size_t index)
{
    if (this->seriesInPlotWndProp.size() == 0)
        return false;

    auto seriesText = dynamic_cast<TextSeriesProp *>(this->seriesInPlotWndProp[0]);
    seriesText->LockData();
    size_t size = seriesText->DataSize();
    char * data = seriesText->GetData(size - 1 - index);
    seriesText->UnlockData();
    return data;
}
Пример #19
0
int FAR PASCAL LibMain(HANDLE hInstance, WORD wDataSeg,
                       WORD cbHeapSize, LPSTR lpszCmdLine)
{
    hInstThisDll = hInstance;

    SaveOrigDataSeg(wDataSeg);
    
    if (cbHeapSize)
        UnlockData(0);

    return TRUE;
}
void
CPulseGenerator::RequestPeriodicPulses( void* requestor                    ,
                                        const UInt32 pulseDeltaInMilliSecs )
{   GUCEF_TRACE;

    LockData();
    if ( NULL != requestor )
    {
        m_periodicUpdateRequestors[ requestor ] = pulseDeltaInMilliSecs;
    }

    m_updateDeltaInMilliSecs = DetermineRequiredPulseInterval();

    if ( NULL != m_driver )
    {
        UnlockData();
        m_driver->RequestPeriodicPulses( *this, m_updateDeltaInMilliSecs );
        return;
    }
    UnlockData();
}
Пример #21
0
int DoCommDlg(int iWhichOper) 
/* returns whether file was retrieved */
/* iWhichOper is the imi* code from the menu */
{
    int iRetval;

    bSave =  iWhichOper == imiSaveAs;

    iRetval = !InitCommDlg(iWhichOper);

    if (!iRetval)
        goto end;

    LockData(0);
    switch(iWhichOper)
    {
        case imiOpen:
            iRetval = GetOpenFileName((LPOPENFILENAME)&OFN);
        break;
        case imiSaveAs:
            iRetval = GetSaveFileName((LPOPENFILENAME)&OFN);
        break;
    }
    UnlockData(0);

    if (CommDlgExtendedError())
    {
        iRetval = FALSE;
        Error(IDPMTNoMemory);
    }

    end:

    if (iRetval)
    {
        lstrcpy(szLastDir,szFileName);
        szLastDir[OFN.nFileOffset] = 0;
        OFN.lpstrInitialDir = szLastDir;
    }

    switch(iWhichOper)
    {
        case imiOpen:
        case imiSaveAs:
            if (lpfnOFNHook)
                FreeProcInstance(lpfnOFNHook);
            lpfnOFNHook = NULL;
        break;
    }

    return iRetval;
}
Пример #22
0
// Every DLL has an entry point LibMain and an exit point WEP.
int FAR PASCAL LibMain( HANDLE hInstance, WORD wDataSegment,
								   WORD wHeapSize, LPSTR lpszCmdLine )
{
	// Required when using Zortech; causes blink to include startup code
	extern __acrtused_dll;

	// The startup code for the DLL initializes the local heap (if there is one)
	// with a call to LocalInit which locks the data segment.
	if ( wHeapSize != 0 )
		UnlockData( 0 );

	hDllInstance = hInstance;
	return 1;   // Indicate that the DLL was initialized successfully.
}
Пример #23
0
int FAR PASCAL LibMain (HANDLE hLibIns, WORD usDatSeg, WORD usHeapSz,
               LPSTR lpCmdLin)
{

    /********************************************************************/
    /********************************************************************/
    if (usHeapSz != 0) UnlockData(0);
    TBxGlo.hLibIns = hLibIns;

    /********************************************************************/
    /********************************************************************/
    return (1);

}
Пример #24
0
void
CObservingNotifier::SubscribeToImp( CNotifier* notifier                 ,
                                    const CEvent& eventid               ,
                                    CIEventHandlerFunctorBase* callback )
{GUCEF_TRACE;

    if ( NULL != notifier )
    {
        LockData();
        notifier->Subscribe( &m_observer ,
                             eventid     ,
                             callback    );
        UnlockData();
    }
}
void
CPulseGenerator::OnDriverPulse( void )
{   GUCEF_TRACE;

    LockData();
    UInt64 tickCount = MT::PrecisionTickCount();
    UInt64 deltaTicks = tickCount - m_lastCycleTickCount;
    Float64 deltaMilliSecs = deltaTicks / m_timerFreq;
    m_lastCycleTickCount = tickCount;
    UnlockData();

    CPulseData pulseData( tickCount, deltaTicks, deltaMilliSecs );
    NotifyObservers( PulseEvent, &pulseData );

}
void
CLogSvcClient::SendAllQueuedItems( void )
{GUCEF_TRACE;

    LockData();
    
    // We will copy the queue because the actual sending of the log
    // messages can cause more items to be queued
    TLogMsgStack logQueueCopy = m_logQueue;

    UnlockData();

    // Go through queue and send all items
    TLogMsgStack::reverse_iterator i = logQueueCopy.rbegin();
    while ( i != logQueueCopy.rend() )
    {
        TLogMessage& logMessage = (*i);

        // Send the logging msg header
        if ( m_tcpClient.Send( logMessage.msgHeader, 15 ) )
        {
            // Now send the logging text
            m_tcpClient.Send( logMessage.logMsg.C_String() ,
                              logMessage.logMsg.Length()   );
        }
        ++i;
    }

    LockData();

    // Clear the queue.
    // Any log messages that where added while sending will be dropped
    m_logQueue.clear();

    UnlockData();
}
Пример #27
0
int FAR PASCAL LibMain(HANDLE hInstance, WORD wDataSeg, WORD cbHeapSize,
                       LPSTR lpszCmdLine)
{
    hInstThisDll = hInstance;
    
    bProtectedLock = (GetWinFlags() & WF_PMODE) != FALSE;

    SaveOrigDataSeg(wDataSeg);

    if (cbHeapSize != 0)
        UnlockData(0);
    
#ifdef LOGMSG
    {
        OFSTRUCT of;
        hLogFile = OpenFile("msglog.txt", &of, OF_CREATE | OF_WRITE);
    }
#endif
    
    return TRUE;
}
Пример #28
0
extern "C" int far pascal LibMain (
	HINSTANCE	hInstance,
	WORD			/*wDataSeg*/,
	WORD			wHeapSize,
	LPSTR			/*lpszCmdLine*/)

	{
	#ifdef __BORLANDC__
	if(flag_HaveWeBeenLoaded())	// make sure right libMain is been call.
		return 0;	
	_WinAllocFlag = GMEM_SHARE;	// magical line to make 'new' operator work!?
	#endif

	// initialize the necessary global variables
	G.hInstance = hInstance;
	G.cbByteOffset = DWL_USER;//serdlgGetByteOffset();

	if(wHeapSize>0)
		UnlockData(0);
	return 1;	// the dll was initialized properly
	}
Пример #29
0
int FAR PASCAL LibMain( HINSTANCE hInstance,
                        WORD wDataSegment,
                        WORD wHeapSize,
                        LPSTR lpszCmdLine )
#endif
{
#ifndef WIN32
/* The startup code for the DLL initializes the local heap(if there is one)
 * with a call to LocalInit which locks the data segment.
 */

if ( wHeapSize != 0 )
   {
   UnlockData( 0 );
   }
hInst = hInstance;
return 1;   /* Indicate that the DLL was initialized successfully. */
#else
BOOL rc = TRUE;
switch( dwReason )
   {
   case DLL_PROCESS_ATTACH:
      // DLL is loaded. Do your initialization here.
      // If cannot init, set rc to FALSE.
      hInst = hInstance;
  		
//      if (!MakeVersionOK("UNZIP32.DLL", _MAKENAME, SCD_VERINFO_V0, SCD_VERINFO_V1, SCD_VERINFO_V2, SCD_VERINFO_V3))
//        return 0;
      
      break;

   case DLL_PROCESS_DETACH:
      // DLL is unloaded. Do your cleanup here.
      break;
   default:
      break;
   }
return rc;
#endif
}
Пример #30
0
void CDECL free (void *block)
{
    HANDLE  hSeg;
    WORD    wSeg;
    SEGHEADER *Seg;
    HANDLE  hBlock;
#if MEMTRACE
    WORD    RealSize = 0;
#endif

    if (FarStorage == FALSE) {  /* use the local heap */
	HANDLE hMem;

	hMem = LocalHandle (LOWORD(block));
	LocalUnlock (hMem);
	LocalFree (hMem);
	return;
    }

    wSeg = HIWORD((DWORD)block);
    hSeg = LOWORD(GlobalHandle (wSeg));

    SWITCH_DS(wSeg)
    LocalUnlock (hBlock = LocalHandle (LOWORD(block)));
#if MEMTRACE
    RealSize = LocalSize (hBlock);
#endif
    LocalFree (hBlock);
    RESTORE_DS

    Seg = (SEGHEADER *)(MAKELONG(SEGHEADOFFSET,HIWORD(block)));
#if MEMTRACE
    mtr[mtrx].m_func = MTR_FREE;
    mtr[mtrx].m_ptr.m_block = block;
    mtr[mtrx].m_cnt = Seg->alloc_count;
    mtr[mtrx].m_size = RealSize;
    mtr[mtrx++].m_optimseg = OptimumSeg;
#endif
    if (--(Seg->alloc_count) == 0) {  /* this segment is no longer used!
					 Let's get rid of it */
        SEGHEADER   *sp;

        if (Seg == OptimumSeg) OptimumSeg = NULL;
        sp = &SegList;
        while (sp->next != Seg) {
            sp = sp->next;
            if (sp == NULL) {   /* this segment is not in the list!!! */
                /* this should not happen, but you never know... */
                static BOOL WarningDisplayed = FALSE;

                if (!WarningDisplayed) {
		    MessageBox (hFrameWnd,
                                "Please shutdown EMACS as soon as possible",
                                "Corrupted memory",
                                MB_OK | MB_ICONSTOP);
                }
                WarningDisplayed = TRUE;
                return;
            }
        }
        sp->next = Seg->next;       /* unlink the segment */
#if MEMTRACE
        mtr[mtrx].m_func = MTR_FREESEG;
        mtr[mtrx].m_ptr.m_segh = Seg;
        mtr[mtrx].m_cnt = Seg->alloc_count;
        mtr[mtrx].m_size = GlobalSize (hSeg);
        mtr[mtrx++].m_optimseg = OptimumSeg;
#endif

        SWITCH_DS(wSeg)
	UnlockData (0);
	RESTORE_DS
	
        GlobalUnlock (hSeg);
        GlobalFree (hSeg);          /* and release it */
    }
    else {  /* segment still in use */
	OptimumSeg = Seg;       /* next malloc will try this segment
				   first */
    }
} /* free */