Ejemplo n.º 1
0
int
SetUpChildIO (int to_prog[2], int from_prog[2])
{
    char pty_name[MSG_SIZ];

    if ((to_prog[1] = PseudoTTY(pty_name)) == -1) {
	DisplayFatalError("Can't open pseudo-tty", errno, 1);
	ExitEvent(1);
    }
    from_prog[0] = to_prog[1];
    to_prog[0] = from_prog[1] = open(pty_name, O_RDWR, 0);

#if HAVE_STROPTS_H /* do we really need this??  pipe-like behavior is fine */
    if (ioctl (to_prog[0], I_PUSH, "ptem") == -1 ||
	ioctl (to_prog[0], I_PUSH, "ldterm") == -1 ||
	ioctl (to_prog[0], I_PUSH, "ttcompat") == -1) {
# ifdef NOTDEF /* seems some systems don't have or need ptem and ttcompat */
	DisplayFatalError("Can't ioctl pseudo-tty", errno, 1);
	ExitEvent(1);
# endif /*NOTDEF*/
    }
#endif /* HAVE_STROPTS_H */

}
TBool CT_ActiveRConsoleRead::VerifyDataAndKick(const TInt aAsyncErrorIndex, RConsole& aConsole)
	{
	TInt	eventType=iKey.Type();
	iDataWrapperBase.INFO_PRINTF2(KLogEvent, eventType);

	//	Do we ignore the event
	TBool			moreToDo=!ExitEvent();
	TBool			eventOk=EFalse;

	TEventConfig	config=iEvent[iEventIndex];
	while ( iEventIndex<iEvent.Count() && !eventOk && moreToDo )
		{
		config=iEvent[iEventIndex];
		if ( eventType==config.iEventType )
			{
			++iEventCount;
			eventOk=ETrue;
			iDataWrapperBase.INFO_PRINTF3(_L("Events type match Expected=%d, Actual=%d"), config.iEventType,eventType);
			}
		else
			{
			switch(config.iEventOccurance)
				{
			case EEventOccuranceOnce:
				iDataWrapperBase.ERR_PRINTF4(KLogUnexpectedEvent, config.iEventType, eventType, iEventIndex);
				iDataWrapperBase.SetBlockResult(EFail);
				moreToDo=EFalse;
				break;
			case EEventOccuranceZeroOrMore:
				//	If the event may not occur then go to the next one
				++iEventIndex;
				iEventCount=0;
				break;
			case EEventOccuranceOneOrMore:
				if(iEventCount==0)
					{
					iDataWrapperBase.ERR_PRINTF4(KLogUnexpectedEvent, config.iEventType, eventType, iEventIndex);
					iDataWrapperBase.SetBlockResult(EFail);
					moreToDo=EFalse;
					}
				else
					{
					++iEventIndex;
					iEventCount=0;
					}
				break;
				}
			}
		}
	
	if ( eventOk )
		{
		if ( config.iDataDraw )
			{
			DrawData();
			}

		if ( config.iDataVerify )
			{
			if ( iHasExpectedRectangle )
				{
				TPoint	point=iKey.MousePos();
				if ( !iExpectedRectangle.Contains(point) )
					{
					iDataWrapperBase.ERR_PRINTF3(KLogUnexpectedPoint, point.iX, point.iY);
					iDataWrapperBase.SetBlockResult(EFail);
					}
				}

			if ( iHasExpectedKeyCode )
				{
				TKeyCode	keyCode=iKey.Code();
				if ( keyCode!=iExpectedKeyCode )
					{
					iDataWrapperBase.ERR_PRINTF2(KLogUnexpectedKeyCode, keyCode);
					iDataWrapperBase.SetBlockResult(EFail);
					}
				else
					{
					iDataWrapperBase.INFO_PRINTF3(_L("keycodes match as expected:%d, actual:%d"), iExpectedKeyCode,keyCode);
					}
				}
			}

		if ( config.iEventOccurance==EEventOccuranceOnce )
			{
			++iEventIndex;
			iEventCount=0;
			}
		if ( iEventIndex>=iEvent.Count() )
			{
			moreToDo=KickNext(aAsyncErrorIndex, aConsole);
			}
		else
			{
			//	Event can occur multiple times
			Kick(aAsyncErrorIndex, aConsole);
			}
		}

	return	moreToDo;
	}
Ejemplo n.º 3
0
void
QuitProc ()
{
    ExitEvent(0);
}