Esempio n. 1
0
BOOL
CHyperLink:: ModifyLinkStyle( DWORD dwRemove, DWORD dwAdd,
                             BOOL bApply /* =TRUE */ )
{
   // Check if we are adding and removing the same style.
   if ( (dwRemove & dwAdd) != 0 )
      return( FALSE );

   // Remove old styles and set the new ones
   CLEARBITS( m_dwStyle, dwRemove );
   SETBITS( m_dwStyle, dwAdd );

   if ( bApply && mIs_hWnd( GetSafeHwnd( ) ) )
   {
      // If possible, APPLY the new styles on the fly.
      if ( BITSET( dwAdd, StyleUnderline ) ||
           BITSET( dwRemove, StyleUnderline ) )
      {
         SwitchUnderline( );
      }

      if ( BITSET( dwAdd, StyleAutoSize ) )
         AdjustWindow( );

      if ( BITSET( dwRemove, StyleUseHover ) )
         Invalidate( );
   }

   return( TRUE );
}
Esempio n. 2
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPathTrack::DisableAlternatePath( void )
{
	if ( m_paltpath != NULL )
	{
		CLEARBITS( m_spawnflags, SF_PATH_ALTERNATE );
	}
}
//-----------------------------------------------------------------------------
// Purpose: Tell the driver to start firing at targets
//-----------------------------------------------------------------------------
void CNPC_VehicleDriver::InputStartFiring( inputdata_t &inputdata )
{
	CLEARBITS( m_spawnflags, SF_VEHICLEDRIVER_INACTIVE );
	SetCondition( COND_PROVOKED );

	float flMinRange, flMaxRange;
	// If the vehicle has a weapon, set our capability
	if ( m_pVehicleInterface->NPC_HasPrimaryWeapon() )
	{
		CapabilitiesAdd( bits_CAP_INNATE_RANGE_ATTACK1 );
		m_pVehicleInterface->Weapon_PrimaryRanges( &flMinRange, &flMaxRange );

		// Ensure the look distances is long enough
		if ( m_flDistTooFar < flMaxRange || GetSenses()->GetDistLook() < flMaxRange )
		{
			m_flDistTooFar = flMaxRange;
			SetDistLook( flMaxRange );
		}
	}

	if ( m_pVehicleInterface->NPC_HasSecondaryWeapon() )
	{
		CapabilitiesAdd( bits_CAP_INNATE_RANGE_ATTACK2 );
		m_pVehicleInterface->Weapon_SecondaryRanges( &flMinRange, &flMaxRange );

		// Ensure the look distances is long enough
		if ( m_flDistTooFar < flMaxRange || GetSenses()->GetDistLook() < flMaxRange )
		{
			m_flDistTooFar = flMaxRange;
			SetDistLook( flMaxRange );
		}
	}
}
Esempio n. 4
0
//-----------------------------------------------------------------------------
// Purpose: Input handler for setting a light pattern
//-----------------------------------------------------------------------------
void CLight::InputSetPattern( inputdata_t &inputdata )
{
	m_iszPattern = inputdata.value.StringID();
	engine->LightStyle(m_iStyle, (char *)STRING( m_iszPattern ));

	// Light is on if pattern is set
	CLEARBITS(m_spawnflags, SF_LIGHT_START_OFF);
}
Esempio n. 5
0
/**
 * Initialisieren der Sequencer-Boards
 */
void io_sequencer_init(void)
{
    // Led-Array-Pins auf ausgabg
    SETBITS(SEQUENCER_DDR, BIT(SEQUENCER_PD_LED1) | BIT(SEQUENCER_PD_LED2));

    // Leds aus
    CLEARBITS(SEQUENCER_PORT, BIT(SEQUENCER_PD_LED1) | BIT(SEQUENCER_PD_LED2));
}
Esempio n. 6
0
//-----------------------------------------------------------------------------
// Purpose: Input handler for fading from first value in old pattern to 
//			first value in new pattern
//-----------------------------------------------------------------------------
void CLight::InputFadeToPattern( inputdata_t &inputdata )
{
	m_iCurrentFade	= (STRING(m_iszPattern))[0];
	m_iTargetFade	= inputdata.value.String()[0];
	m_iszPattern	= inputdata.value.StringID();
	SetThink(&CLight::FadeThink);
	SetNextThink( gpGlobals->curtime );

	// Light is on if pattern is set
	CLEARBITS(m_spawnflags, SF_LIGHT_START_OFF);
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CNPC_VehicleDriver::InputStartForward( inputdata_t &inputdata )
{
	CLEARBITS( m_spawnflags, SF_VEHICLEDRIVER_INACTIVE );
	if ( m_NPCState == NPC_STATE_IDLE )
	{
		SetState( NPC_STATE_ALERT );
	}
	SetCondition( COND_PROVOKED );

	RecalculateSpeeds();
}
Esempio n. 8
0
/**
 * Die Multiplexer auf einen anderen Kanal umschalten
 */
void io_select(uint8_t channel)
{
	// Die drei Multiplexer-Pins auf 1 schalten
	CLEARBITS(MUX_PORT, BIT(MUX_PIN0) | BIT(MUX_PIN1) | BIT(MUX_PIN2));

	// Die Kanalwahl auf 3 Bits beschränken und auf die Multiplexer-Pins legen
	MUX_PORT |= ((channel & 0x07) << MUX_PIN);

	// den Multiplexern Zeit zum Umschalten geben
	_delay_us(1);
}
Esempio n. 9
0
 static void printEnable(uint16_t area, bool on)
 {
   uint8_t index = AREA_INDEX(area);
   if (index < sizeof(bitmasks)) {
     uint8_t bitmask = AREA_BITMASK(area);
     if (on) {
       SETBITS(bitmasks[index], bitmask);
     } else {
       CLEARBITS(bitmasks[index], bitmask);
     }
   }
 }
Esempio n. 10
0
//-----------------------------------------------------------------------------
// Purpose: Turn the light on
//-----------------------------------------------------------------------------
void CLight::TurnOn( void )
{
	if ( m_iszPattern != NULL_STRING )
	{
		engine->LightStyle( m_iStyle, (char *) STRING( m_iszPattern ) );
	}
	else
	{
		engine->LightStyle( m_iStyle, "m" );
	}

	CLEARBITS( m_spawnflags, SF_LIGHT_START_OFF );
}
//-----------------------------------------------------------------------------
// Purpose: Force the driver to pickup a specific entity
// Input  : &inputdata - 
//-----------------------------------------------------------------------------
void CNPC_CraneDriver::InputForcePickup( inputdata_t &inputdata )
{
	string_t iszPickupName = inputdata.value.StringID();
	if ( iszPickupName != NULL_STRING )
	{
		// Turn the magnet off now to drop anything we might have already on the magnet
		m_hCrane->TurnMagnetOff();
		m_hPickupTarget = gEntList.FindEntityByName( NULL, iszPickupName, NULL );
		m_bForcedPickup = true;
		m_bForcedDropoff = false;
		SetCondition( COND_PROVOKED );
		CLEARBITS( m_spawnflags, SF_VEHICLEDRIVER_INACTIVE );
	}
}
Esempio n. 12
0
void
CHyperLink::PreSubclassWindow( )
{
   // If the URL string is empty try to set it to the window text.
   if ( m_csURL.IsEmpty( ) )
      GetWindowText( m_csURL );

   // Check that the window text isn't empty.  If so, set it as URL string.
   CString csWndText;
   GetWindowText( csWndText );
   if ( csWndText.IsEmpty( ) )
   {
      // Set the URL string as the window text
      ASSERT( m_csURL.IsEmpty( ) == FALSE ); // window text and URL both empty!
      CStatic::SetWindowText( m_csURL );
   }

   // Get the current window font
   CFont *pFont = GetFont( );

   if ( pFont )
   {
      LOGFONT lf;
      pFont->GetLogFont( &lf );
      lf.lfUnderline = BITSET( m_dwStyle, StyleUnderline );
      if ( m_Font.CreateFontIndirect( &lf ) )
         CStatic::SetFont( &m_Font );

      // Adjust window size to fit URL if necessary.
      AdjustWindow( );
   }
   else
   {
      // If GetFont returns 0 then the static control is probably not of a
      // text type: it's better to set auto-resizing off.
      CLEARBITS( m_dwStyle, StyleAutoSize );
   }

   if ( !BITSET( m_dwStyle, StyleNoHandCursor ) )
      SetDefaultCursor( );      // try to load a "hand" cursor

    // Create the tooltip.
    CRect rect;
    GetClientRect( rect );
    m_ToolTip.Create( this );
    m_ToolTip.AddTool( this, m_csURL, rect, TOOLTIP_ID );

    CStatic::PreSubclassWindow( );
}
//-----------------------------------------------------------------------------
// Purpose: Force the driver to drop his held entity at a specific point
// Input  : &inputdata - 
//-----------------------------------------------------------------------------
void CNPC_CraneDriver::InputForceDrop( inputdata_t &inputdata )
{
	string_t iszDropName = inputdata.value.StringID();
	if ( iszDropName != NULL_STRING )
	{
		CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, iszDropName, NULL );
		if ( !pEntity )
		{
			Warning("Crane couldn't find entity named %s\n", STRING(iszDropName) );
			return;
		}
		m_bForcedPickup = false;
		m_bForcedDropoff = true;
		SetDesiredPosition( pEntity->GetAbsOrigin() );
		SetCondition( COND_PROVOKED );
		CLEARBITS( m_spawnflags, SF_VEHICLEDRIVER_INACTIVE );
	}
}
Esempio n. 14
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPathTrack::EnablePath( void )
{
	CLEARBITS( m_spawnflags, SF_PATH_DISABLED );
}
Esempio n. 15
0
WaitForInput()
{
    int	Quit();
    int i;
    struct timeval waittime, *wt;
    long timeout;
    long readyClients[mskcnt];
    long curclient;
    int selecterr;

    CLEARBITS(readyClients);

    COPYBITS(AllSockets, LastSelectMask);

    wt = NULL;

/* 
    if (!ANYSET(AllClients))
    {
    	wt = &waittime;
	waittime.tv_sec  = 5*60;
	waittime.tv_usec = 0;
    }
    else {
	sleep(1);
        alarm(NSECONDS);
        signal(SIGALRM, catchit);
        while(wait((int *)0) > 0);
    	alarm(0);
    	wt = NULL;
    }

*/
    i = select (MAXSOCKS, LastSelectMask, (int *) NULL, (int *) NULL, wt);

    selecterr = errno;
    
    if (i <= 0) /* An error or timeout occurred */
    {
	if(i == 0)
		Quit();
	if (i < 0) 
		if (selecterr == EBADF)    /* Some client disconnected */
			CheckConnections ();
		else if (selecterr != EINTR)
			fprintf(stderr, "WaitForInput(): select: errno=%d\n",
								selecterr);
    }
    else
    {
	MASKANDSETBITS(readyClients, LastSelectMask, AllClients); 
	if (LastSelectMask[0] & WellKnownConnections) 
		   EstablishNewConnections();
    }
    if (ANYSET(readyClients))
    {
	for (i=0; i<mskcnt; i++)
	{
	    while (readyClients[i])
	    {
		curclient = NextSetBit (readyClients[i]) - 1;
		ServiceClient(curclient);	
		readyClients[i] &= ~(1 << curclient);
	    }
	}	
    }
}
Esempio n. 16
0
/******************************************************************************
 *
 * main
 *
 *****************************************************************************/
int
main (
        int argc,
        char **argv )
{
    char **cmdLine;
    int    success;
    fd_set readfds, exceptfds;
    int    nfound;
    struct timeval timeoutShort, timeoutLong;
    int    junki,i;
    char  *tmpBuffer;
    int    errorBytes;
    int    firstPass, tmpi;
    char  *tmpProgName = NULL;


    setlocale( LC_ALL, "" );

#ifdef _DTEXEC_NLS16
    Dt_nlInit();
#endif /* _DTEXEC_NLS16 */
 
    /*
     * For debugging purposes, a way to pause the process and allow
     * time for a xdb -P debugger attach. If no args, (e.g. libDtSvc is
     * test running the executable), cruise on.
     */
    if (getenv("_DTEXEC_DEBUG") && (argc > 1)) {
	/*
	 * Don't block in a system call, or on libDtSvc's attempts to
	 * just test exec us.
	 */
	SPINBLOCK
    }

    /*
     * Note: dtSvcProcIdG is used like a boolean to control whether
     * we are communicating with libDtSvc using Tooltalk.
     */
    dtSvcProcIdG = (char *) NULL;	/* assume not communicating with TT */
    ttfdG = -1;

    cmdLine = ParseCommandLine (argc, argv);

    /*
     * If a signal goes off *outside* the upcoming select, we'll need to
     * rediscover the signal by letting select() timeout.
     *
     * We might also set a rediscover flag to fake a signal response.
     */
    rediscoverSigCldG = 0;		/* boolean and counter */
    rediscoverUrgentSigG = 0;		/* boolean and counter */

    InitializeSignalHandling ();

    /*
     * Create a pipe for logging of errors for actions without
     * windows.
     */
    errorpipeG[0] = -1;                 /* by default, no stderr redirection */
    errorpipeG[1] = -1;
    if ( requestTypeG == TRANSIENT ) {    /* should be WINDOW_TYPE NO_STDIO  */
	if ( pipe(errorpipeG) == -1 ) {
	    errorpipeG[0] = -1;
	    errorpipeG[1] = -1;
	}
    }

    if (cmdLine) {
	success = ExecuteCommand (cmdLine);
	if (!success) {
	    /*
	     * Act like we were killed - it will result in a
	     * DtACTION_FAILED.
	     */
	    childPidG = -1;
	    rediscoverUrgentSigG = 1;
	}
    }
    else {
	/*
	 * Act like we had a child and it went away - it will result
	 * in a DtACTION_DONE.
	 */
	childPidG = -1;
	rediscoverSigCldG = 1;
    }

   /*
    * Note when we started so we can compare times when we finish.
    */
   (void) gettimeofday (&startTimeG, &zoneG);

    if (dtSvcProcIdG) {
	if ( !InitializeTooltalk() ) {
	    /*
	     * We have no hope of talking to our caller via Tooltalk.
	     */
	    dtSvcProcIdG = (char *) NULL;
	}
    }

    /*
     * Tie in to the default session and start chatting.
     */
    if (dtSvcProcIdG) tt_session_join(tt_default_session());

    /*
     * Finally send caller our current proc id so they can talk back.
     */
    if (dtSvcProcIdG) IdSelfToCallerRequest();

    /*
     * Monitor file descriptors for activity.  If errors occur on a fds,
     * it will be removed from allactivefdsG after handling the error.
     */
    CLEARBITS(allactivefdsG);

    /*
     * Add Tooltalk
     */
    if ( ttfdG != -1 )
	BITSET(allactivefdsG, ttfdG);          /* add Tooltalk */

    /*
     * Add Error Log
     */
    if ( errorpipeG[0] != -1 )
	BITSET(allactivefdsG, errorpipeG[0]);  /* add read side of error pipe */

    /*
     * Set options for rediscovery and not-rediscovery modes of
     * operation. 
     */
    shutdownPhaseG = SDP_DONE_STARTING;	/* triggered with rediscoverSigCldG */
    timeoutShort.tv_sec  = 0;		/* in quick rediscovery mode */
    timeoutShort.tv_usec = SHORT_SELECT_TIMEOUT;
    timeoutLong.tv_sec  = 86400;	/* don't thrash on rediscovery */
    timeoutLong.tv_usec = 0;

    for (;;) {
	COPYBITS(allactivefdsG, readfds);
	COPYBITS(allactivefdsG, exceptfds);

	if (rediscoverSigCldG || rediscoverUrgentSigG) {
	    nfound =select(MAXSOCKS, FD_SET_CAST(&readfds), FD_SET_CAST(NULL),
				FD_SET_CAST(&exceptfds), &timeoutShort);
 	}
	else {
	    nfound =select(MAXSOCKS, FD_SET_CAST(&readfds), FD_SET_CAST(NULL),
				FD_SET_CAST(&exceptfds), &timeoutLong);
	}

	if (nfound == -1) {
	    /*
	     * Handle select() problem.
	     */
	    if (errno == EINTR) {
		/*
		 * A signal happened - let rediscover flags redirect flow
		 * via short select timeouts.
		 */
	    }
	    else if ((errno == EBADF) || (errno == EFAULT)) {
		/*
		 * A connection probably dropped.
		 */
		if (ttfdG != -1) {
		    if ( GETBIT(exceptfds, ttfdG) ) {
			/*
			 * Tooltalk connection has gone bad.
			 *
			 * Judgement call - when the Tooltalk connection goes
			 * bad, let dtexec continue rather than doing an exit.
			 */
			DetachFromTooltalk(NULL);
		    }
		}

		if (errorpipeG[0] != -1) {
		    if ( GETBIT(exceptfds, errorpipeG[0]) ) {
			/*
			 * Error pipe has gone bad.
			 */
			close(errorpipeG[0]);
			BITCLEAR(allactivefdsG, errorpipeG[0]);
			errorpipeG[0] = -1;
		    }
		}
	    }
	    else {
		/*
		 * We have bad paremeters to select()
		 */
	    }
	    /*
	     * So that select() errors cannot dominate, now behave as
	     * though only a timeout had occured.
	     */
	    nfound = 0;
	}

	if (nfound > 0) {
	    /*
	     * Have some input to process.  Figure out who.
	     */
	    if (ttfdG != -1) {
		if ( GETBIT(readfds, ttfdG) ) {
		    /* Clear bit first, since calling input_handler() could */
		    /* have the side-effect of setting ttfdG to -1! */
		    BITCLEAR(readfds, ttfdG);

		    /*
		     * Tooltalk activity.
		     *
		     * Note that the input_handler parameters match
		     * an XtInputHandler() style callback in case Xt is
		     * ever used.
		     */
		    input_handler((char *) NULL, (int *) &junki,
					(unsigned long *) &junki);
		}
	    }

	    if (errorpipeG[0] != -1) {
		if ( GETBIT(readfds, errorpipeG[0]) ) {
		    /*
		     * Stderr activity.
		     *
		     * Read the errorpipe until no more seems available.
		     * Call that good enough and write a time-stamped
		     * block to the errorLog file.
		     */
		    errorBytes = 0;		/* what we have so far */
		    tmpBuffer  = NULL;
		    firstPass = 1;

		    while (1) {
			char buf;
			nfound =select(MAXSOCKS, FD_SET_CAST(&readfds), FD_SET_CAST(NULL),
			     FD_SET_CAST(NULL), &timeoutShort);
			if (nfound > 0) {
			    tmpi = read (errorpipeG[0], &buf, 1);
			} else {
			    tmpi = 0;
			}

			if ( tmpi > 0 ) {
			    /*
			     * Grow buffer to hold entire error stream.
			     */
			    firstPass = 0;
			    if (tmpBuffer == NULL)
				tmpBuffer = (char *) malloc(
						tmpi + 1);
			    else
				tmpBuffer = (char *) realloc( tmpBuffer,
						errorBytes + tmpi + 1);
			    /*
			     * Drain error pipe.
			     */
			    tmpBuffer[errorBytes] = buf;
			    errorBytes += tmpi;
			    tmpBuffer[errorBytes] = '\0';

			    if (errorBytes < 65535) {
				/*
				 * Pause a bit and wait for a continuation of
				 * the error stream if there is more.
				 */
				select(0, FD_SET_CAST(NULL),
					  FD_SET_CAST(NULL),
					  FD_SET_CAST(NULL), &timeoutShort);
			    }
			    else {
				/*
				 * We have enough to do a dump now.
				 */
				break;
			    }
			}
			else {
			    /*
			     * No more to read.
			     */
			    if (firstPass) {
				/*
				 * On the first pass after select(), if we have 0 bytes,
				 * it really means the pipe has gone down.
				 */
				close(errorpipeG[0]);
				BITCLEAR(allactivefdsG, errorpipeG[0]);
				BITCLEAR(readfds, errorpipeG[0]);
				errorpipeG[0] = -1;
			    }
			    break;
			}
		    }

		    if (tmpBuffer) {

			if (!tmpProgName) {
			    tmpProgName = (char *) malloc (strlen (argv[0]) + 
							   strlen (cmdLine[0]) +
							   5);
			    if (!tmpProgName)
				tmpProgName = argv[0];
			    else {
				/*
				 * To identify the process for this stderr,
				 * use both argv[0] and the name of the
				 * process that was execvp'd
				 */
				(void) strcpy (tmpProgName, "(");
			        (void) strcat (tmpProgName, argv[0]);
				(void) strcat (tmpProgName, ") ");
				(void) strcat (tmpProgName, cmdLine[0]);
			    }
			}
			DtMsgLogMessage( tmpProgName, DtMsgLogStderr, "%s", 
					 tmpBuffer );
			free( tmpBuffer );
		    }

		    if (errorpipeG[0] != -1)
			BITCLEAR(readfds, errorpipeG[0]);
		}
	    }
	    /*
	     * So that select() data cannot dominate, now behave as
	     * though only a timeout had occured.
	     */
	    nfound = 0;
	}

	if (nfound == 0) {
	    /*
	     * Timeout.  We are probably rediscovering and have entered
	     * a shutdown phase.   The following rediscover handlers are
	     * in priority order.
	     *
	     * Note that by way of timeouts and events, we will make
	     * multiple passes through this block of code.
	     */

	    if (rediscoverUrgentSigG) {
		/*
		 * Handle urgent signal.
		 *
		 * Tact: wait awhile and see if a SIGCLD will happen.
		 * If it does, then a normal shutdown will suffice.
		 * If a SIGCLD does not happen, then do a raw exit(0).
		 * Exit is required for BBA anyway.
		 */

		if (rediscoverSigCldG)
		    /*
		     * Rather than act on the Urgent Signal, defer to the
		     * SIGCLD Signal shutdown process.
		     */
		    rediscoverUrgentSigG = 0;
		else
		    /*
		     * Still in a mode where we have an outstanding
		     * Urgent Signal but no SIGCLD.  Bump a counter
		     * which moves us closer to doing an exit().
		     */
		    rediscoverUrgentSigG++;

		/*
		 * After 5 seconds (add select timeout too) waiting for
		 * a SIGCLD, give up and exit.
		 */
		if (rediscoverUrgentSigG > ((1000/SHORT_SELECT_TIMEOUT)*5) ) {
#if defined(__aix) || defined (__osf__) || defined(CSRG_BASED) || defined(linux)
		    PanicSignal(0);
#else
		    PanicSignal();
#endif
		}
	    }

	    if (rediscoverSigCldG) {
		/*
		 * Handle SIGCLD signal.
		 *
		 * Under SIGCLD, we will make multiple passes through the
		 * following, implementing a phased shutdown.
		 */
		if (shutdownPhaseG == SDP_DONE_STARTING) {
		    /*
		     * Send Done(Request) for starters.
		     */
		    if (dtSvcProcIdG) DoneRequest(_DtActCHILD_DONE);

		    if (dtSvcProcIdG) {
			/*
			 * Sit and wait for the Done Reply in select()
			 */
			shutdownPhaseG = SDP_DONE_REPLY_WAIT;
		    }
		    else {
			/*
			 * Unable to send Done Reply.  Assume we're on
			 * our own from now on.
			 */
			shutdownPhaseG = SDP_DONE_PANIC_CLEANUP;
		    }
		}

		if (shutdownPhaseG == SDP_DONE_REPLY_WAIT) {
		    /*
		     * After 5 minutes of passing through REPLY_WAIT,
		     * assume the Done(Reply) will never come in and
		     * move on.
		     */
		    rediscoverSigCldG++;
		    if (rediscoverSigCldG > ((1000/SHORT_SELECT_TIMEOUT)*300)) {

			if (dtSvcProcIdG) {
			    /*
			     * Try to detatch from Tooltalk anyway.
			     */
			    DetachFromTooltalk(NULL);
			}

			shutdownPhaseG = SDP_DONE_PANIC_CLEANUP;
		    }

		    /*
		     * See if the Tooltalk connection is still alive.   If
		     * not, then no reason to wait around.
		     */
		    else if (!dtSvcProcIdG) {
			shutdownPhaseG = SDP_DONE_PANIC_CLEANUP;
		    }

		}

		if (shutdownPhaseG == SDP_DONE_REPLIED) {
		    /*
		     * We have our Done(Reply), so proceed.
		     */

		    if (dtSvcProcIdG)
			shutdownPhaseG = SDP_FINAL_LINGER;
		    else
			shutdownPhaseG = SDP_DONE_PANIC_CLEANUP;
		}

		if (shutdownPhaseG == SDP_DONE_PANIC_CLEANUP) {
		    /*
		     * We cannot talk with caller, so do cleanup
		     * of tmp files.
		     */
		    for (i = 0; i < tmpFileCntG; i++ ) {
			chmod( tmpFilesG[i], (S_IRUSR|S_IWUSR) );
			unlink( tmpFilesG[i] );
		    }

		    shutdownPhaseG = SDP_FINAL_LINGER;
		}

		if (shutdownPhaseG == SDP_FINAL_LINGER) {
		    /*
		     * All done.
		     */
		    static int skipFirst = 1;

		    if (skipFirst) {
			/*
			 * Rather than a quick departure from the select()
			 * loop, make one more pass.  If the child has gone
			 * down quickly, the SIGCLD may have caused us to
			 * get here before any errorPipeG information has
			 * had a chance to reach us.
			 */
			skipFirst = 0;
		    }
		    else {
			FinalLinger();
		    }
		}
	    }
	}
    }
}
Esempio n. 17
0
void
CreateWellKnownSockets() {
	int		request, i;
	int		whichbyte;	    /* used to figure out whether this is
   					 LSB or MSB */
#ifdef TCPCONN
	struct sockaddr_in insock;
	int		tcpportReg;	    /* port with same byte order as server */

#ifdef SO_LINGER
	static int linger[2] = { 0, 0 };
#endif /* SO_LINGER */

#endif /* TCPCONN */

#ifdef DNETCONN
	struct sockaddr_dn dnsock;
#endif /* DNETCONN */

#ifdef ISOCONN
	struct TSAPdisconnect tds;
	struct TSAPdisconnect *td = &tds;
	struct TSAPaddr tas;
	struct TSAPaddr *ta = &tas;
	struct PSAPaddr *pa;
	AEI   aei;
#endif /* ISOCONN */
	int retry;

#ifdef ISOCONN
#ifdef ISODEBUG
	isodetcpath = ISODEPATH;
#endif
#endif /* ISOCONN */

	CLEARBITS(AllSockets);
	CLEARBITS(AllClients);
	CLEARBITS(LastSelectMask);
	CLEARBITS(ClientsWithInput);

	for (i=0; i<MAXSOCKS; i++) ConnectionTranslation[i] = (ClientPtr)NULL;

#ifdef	hpux
	lastfdesc = _NFILE - 1;
#else
	lastfdesc = getdtablesize() - 1;
#endif	/* hpux */

	if (lastfdesc > MAXSOCKS) {
		lastfdesc = MAXSOCKS;
		if (debug_conns)
			ErrorF( "GOT TO END OF SOCKETS %d\n", MAXSOCKS);
	}

	WellKnownConnections = 0;
	whichbyte = 1;

	if (*(char *) &whichbyte)
		whichByteIsFirst = 'l';
	else
		whichByteIsFirst = 'B';


#ifdef TCPCONN

	tcpportReg = atoi (display);
	tcpportReg += X_TCP_PORT;

	if ((request = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
		Notice ("Creating TCP socket");
	} else {
		bzero ((char *)&insock, sizeof (insock));
		insock.sin_family = AF_INET;
		insock.sin_port = htons (tcpportReg);
		insock.sin_addr.s_addr = htonl(INADDR_ANY);
		retry = 20;
		while (i = bind(request, (struct sockaddr *) &insock, sizeof (insock))) {
#ifdef hpux
			/* Necesary to restart the server without a reboot */
			if (errno == EADDRINUSE)
				set_socket_option (request, SO_REUSEADDR);
			if (--retry == 0)
				Error ("Binding TCP socket");
			sleep (1);
#else
			if (--retry == 0)
				Error ("Binding MSB TCP socket");
			sleep (10);
#endif /* hpux */
		}
#ifdef hpux
		/* return the socket option to the original */
		if (errno)
			unset_socket_option (request, SO_REUSEADDR);
#endif /* hpux */
#ifdef SO_LINGER
		if(setsockopt (request, SOL_SOCKET, SO_LINGER,
					   (char *)linger, sizeof(linger)))
			Notice ("Setting TCP SO_LINGER\n");
#endif /* SO_LINGER */
		if (listen (request, 5))
			Error ("Reg TCP Listening");
		WellKnownConnections |= (1 << request);
		DefineSelf (request);
#ifdef ISOCONN
		fd2family[request] = UNIX_IO;
#endif /* ISOCONN */
	}

#endif /* TCPCONN */

#ifdef UNIXCONN
	if ((request = open_unix_socket ()) != -1) {
		WellKnownConnections |= (1L << request);
		unixDomainConnection = request;
#ifdef ISOCONN
		fd2family[request] = UNIX_IO;
#endif /* ISOCONN */
	}
#endif /*UNIXCONN */

#ifdef DNETCONN
	if ((request = socket (AF_DECnet, SOCK_STREAM, 0)) < 0) {
		Notice ("Creating DECnet socket");
	} else {
		bzero ((char *)&dnsock, sizeof (dnsock));
		dnsock.sdn_family = AF_DECnet;
		sprintf(dnsock.sdn_objname, "X$X%d", atoi (display));
		dnsock.sdn_objnamel = strlen(dnsock.sdn_objname);
		if (bind (request, (struct sockaddr *) &dnsock, sizeof (dnsock)))
			Error ("Binding DECnet socket");
		if (listen (request, 5)) Error ("DECnet Listening");
		WellKnownConnections |= (1 << request);
		DefineSelf (request);
#ifdef ISOCONN
		fd2family[request] = UNIX_IO;
#endif /* ISOCONN */
	}
#endif /* DNETCONN */
#ifdef ISOCONN
	/*
	 * If display is set, its the string after the Colon:
	 * i.e. X0 or X1 or T0 or T1...
	 */
	if ((display == NULLCP) || (atoi(display) == 0))
		aei = str2aei(TLocalHostName(), DEFAULTTSERVICE);
	else
		aei = str2aei(TLocalHostName(), display);

	if (aei == NULLAEI) {
		ErrorF("No AEI for me:");
		FatalError(TLocalHostName());
	}

	/*
	 * This hack only works if the PSAPaddr and SSAP addrsd are null!!
	 */
	if ((pa = aei2addr (aei)) == NULLPA)
		FatalError("address translation failed");

	ta = (struct TSAPaddr *)&(pa->pa_addr.sa_addr);

	/*
	 * Just put out a listen for now
	 */
	if ((request = TNetListen(ta, td)) != OK) {
		Error(TErrString(td->td_reason));
		FatalError("TNetListen");
	}

	WellKnownConnections |= (1 << request);
	DefineSelf (request);
	fd2family[request] = ISODE_IO;
#endif /*  ISOCONN */
	if (WellKnownConnections == 0)
		Error ("No Listeners, nothing to do");
	signal (SIGPIPE, SIG_IGN);
	signal (SIGHUP, AutoResetServer);
	signal (SIGINT, GiveUp);
	signal (SIGTERM, GiveUp);
	FirstClient = request + 1;
	AllSockets[0] = WellKnownConnections;
	ResetHosts(display);

	for (i=0; i<MaxClients; i++) {
		inputBuffers[i].buffer = (char *) NULL;
		inputBuffers[i].bufptr = (char *) NULL;
		inputBuffers[i].bufcnt = 0;
		inputBuffers[i].lenLastReq = 0;
		inputBuffers[i].size = 0;
	}
}
Esempio n. 18
0
void io_sequencer_presync(uint8_t cycle)
{
    // Leds aus
    CLEARBITS(SEQUENCER_PORT, BIT(SEQUENCER_PD_LED1) | BIT(SEQUENCER_PD_LED2));
}