Example #1
0
char doRegular(char expand, char c)
{
    char toReturn;
    int i;
    int done = 0;
    label doorinfo;

    toReturn = FALSE;

    for (i = 0; !expand && i < MAXEXTERN && extCmd[i].name[0]; ++i) {
        if (c == toupper(extCmd[i].name[0]) && (onConsole || !extCmd[i].local)) {
            done = 1;
            mPrintf("\b%s", extCmd[i].name);
            doCR();
            if (changedir(cfg.aplpath) == ERROR) {
                mPrintf("  -- Can't find application directory.\n\n");
                changedir(cfg.homepath);
            }
        /* apsystem(extCmd[i].command); */
            sprintf(doorinfo, "DORINFO%d.DEF", onConsole ? 0 : userdat.apl_com);
            extFmtRun(extCmd[i].command, doorinfo);
        }
    }
    if (!done) {
        switch (c) {

            case 'S':
                if (gl_user.sysop && expand) {
                    mPrintf("\b\bSysop Menu");
                    doCR();
                    doSysop();
                } else {
                    toReturn = TRUE;
                }
                break;

            case 'A':
                if (gl_user.aide) {
                    doAide(expand, 'E');
                } else {
                    toReturn = TRUE;
                }
                break;

            case 'C':
                doChat(expand, '\0');
                break;
            case 'D':
                doDownload(expand);
                break;
            case 'E':
                doEnter(expand, 'm');
                break;
            case 'F':
                doRead(expand, 'f');
                break;
            case 'G':
                doGoto(expand, FALSE);
                break;
            case 'H':
                doHelp(expand);
                break;
            case 'I':
                doIntro();
                break;
            case 'J':
                mPrintf("\bJump back to ");
                unGotoRoom();
                break;
            case 'K':
                doKnown(expand, 'r');
                break;
            case 'L':
                if (!loggedIn) {
                    doLogin(expand);
                } else {
                    if (!getYesNo(confirm, 0))
                        break;
                    doLogout(expand, 's');
                    doLogin(expand);
                }
                break;
            case 'N':
            case 'O':
            case 'R':
                doRead(expand, tolower(c));
                break;

            case 'B':
                doGoto(expand, TRUE);
                break;
            case 'T':
                doLogout(expand, 'q');
                break;
            case 'U':
                doUpload(expand);
                break;
            case 'X':
                if (!expand) {
                    doEnter(expand, 'x');
                } else {
                    doXpert();
                }
                break;

            case '=':
            case '+':
                doNext();
                break;
            case '\b':
                mPrintf("  ");
            case '-':
                doPrevious();
                break;

            case ']':
            case '>':
                doNextHall();
                break;
            case '[':
            case '<':
                doPreviousHall();
                break;
            case '~':
                mPrintf("\bAnsi %s\n ", gl_term.ansiOn ?
					gl_str.off : gl_str.on);
                gl_term.ansiOn = !gl_term.ansiOn;
                break;

            case '!':
                mPrintf("\bIBM Graphics %s\n ", gl_term.IBMOn ?
					gl_str.off:gl_str.on);
                gl_term.IBMOn = !gl_term.IBMOn;
                break;

            case '?':
                nextmenu("mainopt", &(cfg.cnt.mainopttut), 1);
				listExterns();
                break;

            case 0:     /* never gets here in shell mode... */
                if (newCarrier) {
                    greeting();

                    if (cfg.forcelogin) {
                        doCR();
                        doCR();
                        i = 0;
                        while (!loggedIn && gotCarrier()) {
                            doLogin(2);
                            if (++i > 3) {
                                Initport();
                                toReturn = TRUE;
                                break;
                            }
                        }
                    }
                    newCarrier = FALSE;
                }
                if (logBuf.lbflags.NODE && loggedIn) {
                    net_slave();

                    haveCarrier = FALSE;
                    modStat = FALSE;
                    newCarrier = FALSE;
                    justLostCarrier = FALSE;
                    onConsole = FALSE;
                    disabled = FALSE;
                    callout = FALSE;

                    delay(2000);

                    Initport();

                    cfg.callno++;
                    terminate(FALSE, FALSE);
                }
                if (justLostCarrier || ExitToMsdos) {
                    justLostCarrier = FALSE;
                    if (loggedIn)
                        terminate(FALSE, FALSE);
                }
                break;      /* irrelevant value */

            default:
                toReturn = TRUE;
                break;
        }
    }
    /* if they get unverified online */
    if (logBuf.VERIFIED)
        terminate(FALSE, FALSE);

    /* update25();	*/
	do_idle(0);
    return toReturn;
}
Example #2
0
//=============================================================================
// METHOD    : SPELLcontroller::executeCommand()
//=============================================================================
void SPELLcontroller::executeCommand( const ExecutorCommand& cmd )
{
	// If a (repeatable) command is being executed, discard this one
	if (isCommandPending() &&
	    (cmd.id != CMD_ABORT) &&
	    (cmd.id != CMD_FINISH) &&
	    (cmd.id != CMD_INTERRUPT) &&
	    (cmd.id != CMD_PAUSE) &&
	    (cmd.id != CMD_CLOSE))
	{
		LOG_WARN("Discarding command " + cmd.id);
		return;
	}

	LOG_INFO("Now executing command " + cmd.id);

    startCommandProcessing();

    if (cmd.id == CMD_ABORT)
    {
        doAbort();
    }
    else if (cmd.id == CMD_FINISH)
    {
        doFinish();
    }
    else if (cmd.id == CMD_ACTION)
    {
        doUserAction();
    }
    else if (cmd.id == CMD_STEP)
    {
        doStep( false );
    }
    else if (cmd.id == CMD_STEP_OVER)
    {
        doStep( true );
    }
    else if (cmd.id == CMD_RUN)
    {
        doPlay();
    }
    else if (cmd.id == CMD_SKIP)
    {
        doSkip();
    }
    else if (cmd.id == CMD_GOTO)
    {
        if (cmd.earg == "line")
        {
            DEBUG("[C] Processing go-to-line " + cmd.arg);
            try
            {
                int line = STRI(cmd.arg);
                doGoto( line );
            }
            catch(...) {};
        }
        else if (cmd.earg == "label")
        {
            DEBUG("[C] Processing go-to-label " + cmd.arg);
            doGoto( cmd.arg );
        }
        else
        {
        	SPELLexecutor::instance().getCIF().error("Unable to process Go-To command, no target information", LanguageConstants::SCOPE_SYS );
        }
    }
    else if (cmd.id == CMD_PAUSE)
    {
        doPause();
    }
    else if (cmd.id == CMD_INTERRUPT)
    {
        doInterrupt();
    }
    else if (cmd.id == CMD_SCRIPT)
    {
    	/** \todo determine when to override */
        doScript(cmd.arg,false);
    }
    else if (cmd.id == CMD_CLOSE)
    {
        m_recover = false;
        m_reload = false;
        doClose();
    }
    else if (cmd.id == CMD_RELOAD)
    {
        doReload();
    }
    else if (cmd.id == CMD_RECOVER)
    {
        doRecover();
    }
    else
    {
        LOG_ERROR("[C] UNRECOGNISED COMMAND: " + cmd.id)
    }
	m_mailbox.commandProcessed();

	// The command has finished, release the dispatcher
	setCommandFinished();
	DEBUG("[C] Command execution finished " + cmd.id);

	//TEMPORARILY DISABLED: it creates deadlocks.
	// notifyCommandToCore( cmd.id );
}