Пример #1
0
static void foreverloop( void )
/*****************************/
/* This function intentionally goes into an infinite loop. It's purpose */
/* is to allow the UI thread of a Netware application to unblock off the */
/* keyboard to allow the NLM to call exit */
{
    for( ; ; ) {
        ThreadSwitch();
    }
}
Пример #2
0
void UIAPI uiforceinfloop( void )
/********************************/
/* This is a dangerous function. This may be called from any thread. */
{
    EnterForever = TRUE;
    uiwakethread();
    while( kbdisblocked() ) {
        ThreadSwitch();
    }
}
Пример #3
0
int main(int argc, char** argv)
{
/*
 *	Hook the unload routine in
 */
   signal( SIGTERM, SigTermSignalHandler ) ;

/*
 * Initialize the memory allocator. Allow use of malloc and start 
 * with a 60K heap.  For each page request approx 8KB is allocated.
 * 60KB allows for several concurrent page requests.  If more space
 * is required, malloc will be used for the overflow.
 */
   bopen(NULL, (60 * 1024), B_USE_MALLOC);

   P( 1 ) ;

/*
 *	Switch to LONG name-space. If LONG is not loaded, WEBS will default
 *	to 8.3
 */
   SetCurrentNameSpace( 4 ) ;

/*
 * Initialize the web server
 */
   if (initWebs() < 0) {
      return -1;
   }

#ifdef WEBS_SSL_SUPPORT
   websSSLOpen();
#endif

   P( 20 ) ;

/*
 * Basic event loop. SocketReady returns true when a socket is ready for
 * service. SocketSelect will block until an event occurs. SocketProcess
 * will actually do the servicing.
 */
   while (!finished) {
      if (socketReady(-1) || socketSelect(-1, 1000)) {
         socketProcess(-1);
         ThreadSwitch() ;
      }
      websCgiCleanup();
      emfSchedProcess();
   }

   NLMcleanup() ;

   return 0;
}
Пример #4
0
	//!\brief Общая функция вывода Trace информации
	void Trace(	int traceLevel, const wchar_t *module, const wchar_t *format, ... )
	{
		if ( klTraceInfo && traceLevel <= klTraceInfo->traceLevel )
		{
			va_list args;
			va_start(args, format);
			
			TraceCommon( traceLevel, module, format, args );
			
			va_end(args);
		}
#ifdef N_PLAT_NLM
		else {
			ThreadSwitch();		
		}
#endif

	}
Пример #5
0
EVENT UIAPI uieventsource( bool update )
/**************************************/
{
    register    EVENT                   ev;
    static      int                     ReturnIdle = 1;
    unsigned long                       start;

    start = uiclock();
    for( ; ; ) {
        ThreadSwitch();
        if( EnterForever )
            foreverloop();

        ev = forcedevent();
        if( ev > EV_NO_EVENT )
            break;

        /* There is no mouse support in NetWare. */
        //ev = mouseevent();
        //if( ev > EV_NO_EVENT )
        //    break;

        ev = keyboardevent();
        if( ev > EV_NO_EVENT ) {
            //uihidemouse();
            break;
        }
        if( ReturnIdle ) {
            ReturnIdle--;
            return( EV_IDLE );
        } else {
            if( update )
                uirefresh();
            if( uiclock() - start >= UIData->tick_delay ) {
                return( EV_CLOCK_TICK );
            } else if( UIData->busy_wait ) {
                return( EV_SINK );
            }
        }
        waitforevent();
    }
    ReturnIdle = 1;
    return( ev );
}
Пример #6
0
	//!\brief Общая функция трассировачного вывода 
	void TraceCommon( int traceLevel, const wchar_t *module, const wchar_t *format,
		va_list args )
	{
		if ( klTraceInfo==NULL ) return;
		TraceAutoUnlock unlocker;

		if ( !(klTraceInfo->traceFlags & TF_NOT_SYNCHRONIZE) )
			unlocker.Init( klTraceCricSec );

		FILE *out = klTraceInfo->traceOut;
		int level = klTraceInfo->traceLevel;
		
		if ( klTraceInfo->IsModulesFiltered( traceLevel ) )
		{
			TraceModuleDesc *fDesc = klTraceInfo->GetTracedModuleDesc( module );
			if ( fDesc!=NULL )
				out = fDesc->traceOut, level = fDesc->traceLevel;
			else return;
		}

		if ( klTraceInfo->IsThreadsFiltered() )
		{
			TraceThreadDesc *fDesc = klTraceInfo->GetTracedThreadDesc( KLGetCurrentThreadId() );
			if ( fDesc!=NULL )
				out = fDesc->traceOut, level = fDesc->traceLevel;
			else return;
		}

		if ( traceLevel <= level && traceLevel!=0 )
		{
			if ( klTraceInfo->traceFlags==0 ){
				vfwprintf( out, format, args );
			}
			else
			{
#if defined (__unix) //|| defined (N_PLAT_NLM) 
                std::wstringstream s_out;
				if ( klTraceInfo->traceFlags & TF_PRINT_DATETIME )
                  s_out << GetCurrentTimeString( klTraceInfo->traceFlags ).data() << " ";
#else
				char	dateTimeString[128];		
				wchar_t additionalInfoStr[256]; 
				wchar_t moduleFormatedString[256];

				additionalInfoStr[0]=0;
				dateTimeString[0]=0;
#endif

#if defined (_WIN32) || defined (N_PLAT_NLM)
				if ( klTraceInfo->traceFlags & TF_PRINT_DATETIME ) {
					strcat( dateTimeString, 
						GetCurrentTimeString( klTraceInfo->traceFlags ).c_str() );
				}
#endif
				if ( klTraceInfo->traceFlags & TF_PRINT_THREAD_ID )
				{
#if defined(_WIN32)  || defined(N_PLAT_NLM)
					swprintf( additionalInfoStr, L" %08X", KLGetCurrentThreadId() );
#else
                    s_out << std::hex
                          << std::setiosflags(std::ios_base::right)
                          << std::setfill('0')
                          << std::setw(8)
                          << KLGetCurrentThreadId();
#endif
				}

				if ( klTraceInfo->traceFlags & TF_PRINT_MODULE )
				{
#if defined(_WIN32)  || defined(N_PLAT_NLM) 
					swprintf( moduleFormatedString, L" %6ls", module );
					wcscat( additionalInfoStr, moduleFormatedString );
#else
                    s_out << ' ' << module;
#endif
				}
				
#if defined(__unix)
				std::wofstream fs( fileno(out) );
				fs << s_out.str() << " ";
                _safe_printer( fs, format, args );
#else
 				fwprintf( out, L"%hs %ls: ", dateTimeString, additionalInfoStr );
				vfwprintf( out, format, args );
#endif
#if defined(_WIN32)// && defined(_DEBUG)
                if(IsDebugOutEnabled())
                {
                    wchar_t additionalBuff[512];
				    KLSTD_SWPRINTF(additionalBuff, KLSTD_COUNTOF(additionalBuff), L"%hs %ls: ", dateTimeString, additionalInfoStr );
                    additionalBuff[KLSTD_COUNTOF(additionalBuff)-1]=0;                
                    outputDebugStringV(module, additionalBuff, args);
				    outputDebugStringV(module, format, args);
                };
#endif

			}

			fflush( out );
		}
#ifdef N_PLAT_NLM
		else	ThreadSwitch();		
#endif

	}
Пример #7
0
_WCRTLINK void __AccessSemaphore( semaphore_object *obj )
{
    TID tid;

    tid = GetCurrentThreadId();
#if defined( _NETWARE_CLIB )
    if( tid == 0 )
        return;
#endif
    if( obj->owner != tid ) {
#if defined( _M_I86 )
        DosSemRequest( &obj->semaphore, -1L );
#else
  #if !defined( __NETWARE__ )
        if( obj->initialized == 0 ) {
    #if defined( __RUNTIME_CHECKS__ ) && defined( _M_IX86 )
            if( obj == &InitSemaphore ) {
                __fatal_runtime_error( "Bad semaphore lock", 1 );
            }
    #endif
            __AccessSemaphore( &InitSemaphore );
            if( obj->initialized == 0 ) {
    #if defined( __NT__ )
                obj->semaphore = __NTGetCriticalSection();
    #elif defined( __QNX__ )
                __qsem_init( &obj->semaphore, 1, 1 );
    #elif defined( __LINUX__ )
                // TODO: Access semaphore under Linux!
    #elif defined( __RDOS__ )
                obj->semaphore = RdosCreateSection();
    #elif defined( __RDOSDEV__ )
                RdosInitKernelSection(&obj->semaphore);
    #else
                DosCreateMutexSem( NULL, &obj->semaphore, 0, FALSE );
    #endif
                obj->initialized = 1;
            }
            __ReleaseSemaphore( &InitSemaphore );
        }
  #endif
  #if defined( __NETWARE__ )
        while( obj->semaphore != 0 ) {
    #if defined (_NETWARE_CLIB)
            ThreadSwitch();
    #else
            NXThreadYield();
    #endif
        }

        obj->semaphore = 1;
        obj->initialized = 1;
  #elif defined( __NT__ )
        EnterCriticalSection( obj->semaphore );
  #elif defined( __QNX__ )
        __qsem_wait( &obj->semaphore );
  #elif defined( __LINUX__ )
        // TODO: Wait for semaphore under Linux!
  #elif defined( __RDOS__ )
        RdosEnterSection( obj->semaphore );
  #elif defined( __RDOSDEV__ )
        RdosEnterKernelSection( &obj->semaphore );
  #else
        DosRequestMutexSem( obj->semaphore, SEM_INDEFINITE_WAIT );
  #endif
#endif
        obj->owner = tid;
    }
    obj->count++;
}