Ejemplo n.º 1
0
/*
 * FindBaud()
 *
 * This finds the baud from sysop and user supplied data.
 */
int FindBaud()
{
    char noGood = NO_GOOD;
    int  Time = 0;
    int  baudRunner;		/* Only try for 60 seconds      */
    extern FILE *netLog;
    extern int  BaudRate;
    extern UNS_16 intrates[];

    if ((LastBaudIndex = baudRunner = getModemId()) != ERROR) {
	setNetCallBaud(baudRunner);
	BaudRate = intrates[baudRunner] * 10;
	pause((baudRunner != 4) ? 75 : 300);      /* To clear line noise */
	return BaudRate;
    }
    if (cfg.DepData.LockPort != -1) {
	return -1;
    }
    while (MIReady())   Citinp();	/* Clear garbage	*/
    baudRunner = 0;
    while (gotCarrier() && noGood == NO_GOOD && Time < 120) {
	Time++;
	setNetCallBaud(baudRunner);
	noGood = check_CR();
	if (noGood == NO_GOOD)
	    baudRunner = (baudRunner + 1) % (cfg.sysBaud + 1);
    }
    if (noGood == NET_CAUGHT) {
	LastBaudIndex = baudRunner;
	netController(0, 0, NO_NETS, ANY_CALL, 0);
	return -1;       /* pretend nothing happened */
    }
    if (noGood == STROLL_CAUGHT) {
	LastBaudIndex = baudRunner;
	StrollIt();
	return -1;       /* pretend nothing happened */
    }
    BaudRate = intrates[baudRunner] * 10;
    if (noGood == CR_CAUGHT) return BaudRate;
    return -1;
}
Ejemplo n.º 2
0
/*
 * FigureEvent()
 *
 * This function handles an event becoming active and takes action.
 */
int FigureEvent(int index)
{
    long ThisAbs, temp, InSeconds, EndIt = -1l, CalcEnd;
    EvDoorRec *EvDoor;

    temp = (long) Cur->EvMinutes;
    InSeconds = temp * 60l;
    ThisAbs = ThisAbsolute - WeekDiff(ThisSecond, InSeconds);
    CalcEnd = ThisAbs + (Cur->EvDur * 60l);

    switch (Cur->EvClass) {
    case CL_UNTIL_NET:
    case CLNET:
	netController(Cur->EvMinutes % 1440, Cur->EvDur,
			Cur->EvExitVal,
			(Cur->EvClass == CLNET) ? NORMAL_NET : UNTIL_NET,
			REPORT_FAILURE | LEISURELY);
	startTimer(NEXT_ANYNET);
	break;
    case CLEXTERN:
	ExitToMsdos = TRUE;
	exitValue = (int) Cur->EvExitVal;
	return TRUE;	/* force it */
    case CL_DL_TIME:
	EndIt = CalcEnd;
	Dl_Limit = Cur->EvExitVal;
	ResolveDLStuff();
	DlMsgPtr = cfg.codeBuf + Cur->EvWarn;
	break;
    case CL_ANYTIME_NET:
	EndIt = CalcEnd;
			/* gets eligible nets */
	AnyTimeNets = Cur->EvExitVal;
	DeadTime    = Cur->vars.Anytime.EvDeadTime;
	AnyNetLen   = Cur->vars.Anytime.EvAnyDur;
	break;
    case CL_DOOR_TIME:
	EndIt = CalcEnd;
	Door_Limit = Cur->EvExitVal;
	break;
    case CL_AUTODOOR:
    case CL_REDIRECT:
	EvDoor = GetDynamic(sizeof *EvDoor);
	EvDoor->Evt = Cur;
	EvDoor->finish = CalcEnd;
	AddData((Cur->EvClass == CL_AUTODOOR) ? &AutoDoors : &Redirected,
						EvDoor, NULL, TRUE);
	break;
    case CL_CHAT_ON:
    case CL_CHAT_OFF:
	cfg.BoolFlags.noChat = (Cur->EvClass != CL_CHAT_ON);
	ScrNewUser();
	EndIt = CalcEnd;
	break;
    case CL_NEWUSERS_ALLOWED:
    case CL_NEWUSERS_DISALLOWED:
	cfg.BoolFlags.unlogLoginOk = (Cur->EvClass == CL_NEWUSERS_ALLOWED);
	EndIt = CalcEnd;
	break;
    case CL_NETCACHE:
	CacheMessages(Cur->EvExitVal, FALSE);
	break;
    default:	/* do nothing */
	;       /* required by ANSI */
    }

    if (EndIt != -1l) {
	AddData(&EventEnds, MakeTwo(Cur->EvClass, EndIt), NULL, TRUE);
	ClassActive[Cur->EvClass] = TRUE;       /* turn it on, baby! */
    }

    if (!(Cur->EvFlags & EV_DAY_BASE))
	FrontToEnd(&Types[index].List);	/* put event on end of list */
    else
	KillData(&Types[index].List, GetFirst(&Types[index].List));

    Types[index].LastAbs = ThisAbs;
    SetAbs(&Types[index], Types[index].LastAbs);

    return Types[index].toReturn;
}
Ejemplo n.º 3
0
/*
 * DoTimeouts()
 *
 * This is the function responsible for actual checking of timeouts.  It
 * returns TRUE if you want modIn to break out, too.  It should only be called
 * from modIn().
 */
char DoTimeouts()
{
    int  yr, dy, hr, mn, temp, mon, secs, milli;
    static char   warned = FALSE;
#ifdef SYSTEM_CLOCK
    static int LastMinute = -1;
#endif
    static int LastDay = 0;
    extern int PriorityMail;
    TwoNumbers *tmp;
    EvDoorRec  *evtmp;
    extern SListBase UntilNetSessions;
    void Activate();
    char Oldpage;

    getRawDate(&yr, &mon, &dy, &hr, &mn, &secs, &milli);

#ifdef SYSTEM_CLOCK
    if (LastMinute != mn) {
	ScrTimeUpdate(hr, mn);
	LastMinute = mn;
    }
#endif

    if (LastDay != dy) {
	LastDay = dy;
	RunListA(&DayBased, Activate, (void *) &LastDay);
    }

    ThisMinute = (WhatDay() * 1440) + (hr * 60) + mn;
    ThisAbsolute = (long) ThisMinute;
    ThisSecond = ThisAbsolute * 60 + secs;

    ThisAbsolute = CurAbsolute();

    /* First we deal with events which are deactivating */
    if ((tmp = GetFirst(&EventEnds)) != NULL) {
	if (ThisAbsolute >= tmp->second) {      /* event is ending! */
	    ClassActive[tmp->first] = FALSE;
	    KillData(&EventEnds, tmp);		/* take it off the list */
	    if (tmp->first == CL_DL_TIME)
		ResolveDLStuff();
	}
    }

    if ((evtmp = GetFirst(&AutoDoors)) != NULL) {
	if (ThisAbsolute >= evtmp->finish) {    /* autodoor finish */
	    KillData(&AutoDoors, evtmp);
	}
    }

    if ((evtmp = GetFirst(&Redirected)) != NULL) {
	if (ThisAbsolute >= evtmp->finish) {    /* redirection finish */
	    KillData(&Redirected, evtmp);
	}
    }

    /* Next we deal with preemptive events, which are Type 0 */

    /* give a warning at T-5 */
    if ((Cur = GetFirst(&Types[0].List)) != NULL &&
	    !warned && Types[0].NextAbs - ThisAbsolute < 300l && onLine()) {
	temp = Cur->EvMinutes % 1440;
	warned = TRUE;
	outFlag = IMPERVIOUS;
	Oldpage = Pageable;
	Pageable = FALSE;

	mPrintf("\n %cWARNING: System going down at %d:%02d for %s.\n ",
	    BELL, temp/60, temp%60, Cur->EvWarn + cfg.codeBuf);
	outFlag = OUTOK;
	Pageable = Oldpage;
	return FALSE;
    }
    else if (Cur != NULL && Types[0].NextAbs < ThisAbsolute) {
	if (onLine()) {		/* first boot off user, next time do event */
	    outFlag = IMPERVIOUS;
	    PagingOff();
	    mPrintf("\n %cGoing to %s, bye!\n ", BELL,
						Cur->EvWarn + cfg.codeBuf);

	    if (onConsole) {		/* Ugly cheat */
		onConsole = FALSE;
		whichIO = MODEM;
		justLostCarrier = TRUE;
		EnableModem(FALSE);
	    }
	    else
		HangUp(FALSE);

	    outFlag = OUTOK;
	    return TRUE;
	}
	warned = FALSE;
	return FigureEvent(0);
    }

    if (!onLine() && (Cur = GetFirst(&Types[1].List)) != NULL &&
			Types[1].NextAbs < ThisAbsolute)
	return FigureEvent(1);

    if ((Cur = GetFirst(&Types[2].List)) != NULL &&
			Types[2].NextAbs < ThisAbsolute)
	return FigureEvent(2);

    /* check priority mail -- odd place for the check, but wotthehell */
    if (PriorityMail) {
	if (!onLine()) {
	    netController((hr*60) + mn, 0, PRIORITY_MAIL, ANYTIME_NET, 0);
	    PriorityMail = 0;
	}
    }

    /* handle anytime netting here - is special type of thing */
    if (chkTimeSince(NEXT_ANYNET) > DeadTime || ForceNet) {
	if (ClassActive[CL_ANYTIME_NET]) {
	    if (!onLine()) {
		netController((hr * 60) + mn, AnyNetLen,
				AnyTimeNets, ANYTIME_NET, 0);
		ScrNewUser();
	 	ForceNet = FALSE;
	    }
	}
	else ForceNet = FALSE;
	startTimer(NEXT_ANYNET);
    }

    /*
     * now see if we have any other net sessions due to be run.  These are
     * sessions scheduled by the user from the Net menu. If so, run each of
     * them by killing the list (the kill function should run each).
     */
    if (!onLine() && GetFirst(&UntilNetSessions) != NULL) {
	KillList(&UntilNetSessions);
    }

    return ExitToMsdos;
}