Annotation of researchv10no/cmd/basic/bite/src/basic.c, revision 1.1

1.1     ! root        1: /* Copyright Bell Telephone Laboratories Whippany, N.J.
        !             2: 
        !             3:  *     ***********************************
        !             4:  *     ***********************************
        !             5:  *     ****** MAIN PROGRAM FOR BITE ******
        !             6:  *     *** R. B. Drake WH 8C-005 X4163 ***
        !             7:  *     **** Fri Aug 24 14:38:50 1979 *****
        !             8:  *     ***********************************
        !             9:  *     ***********************************
        !            10:  *
        !            11:  * mod,J.P.Hawkins,17-SEP-79, encode "else" and "endif"
        !            12: 
        !            13:  * MOD,J.P.Hawkins to read environment for BITEPATH
        !            14:  */
        !            15: /*   "@(#) basic.c:  V 1.3  6/17/81" */
        !            16: 
        !            17: /*
        !            18:  * THIS IS THE CALL INTERFACE TO BASIC
        !            19:  *
        !            20:  * the cmd format is
        !            21:  * bite [-] prog1 prog2 ......
        !            22:  *
        !            23:  * where - causes the programs to load without executing
        !            24:  *
        !            25:  */
        !            26: #include "bas.h"
        !            27: extern int     endfcnt;
        !            28: extern char    bpath[];
        !            29: static int nquit;
        !            30: quit()
        !            31: {
        !            32:        signal(2,quit);
        !            33:        nquit = 1;
        !            34:        printf("\n?\n");
        !            35:        return(0);
        !            36: }
        !            37: int rem;
        !            38: int atad;
        !            39: int tv;
        !            40: int tel;
        !            41: int nxt;
        !            42: int _sub;
        !            43: int _fi;
        !            44: int _togo;
        !            45: int tospgo;
        !            46: int subog;
        !            47: int tsil;
        !            48: int no;
        !            49: int daol;
        !            50: int evas;
        !            51: int dlo;
        !            52: int bat;
        !            53: int esle;      /* else code */
        !            54: int fidne;     /* endif code */
        !            55: int rof;       /* for code */
        !            56: int mr;
        !            57: int sl;
        !            58: /*
        !            59:  *
        !            60:  *
        !            61:  */
        !            62: char txtbuf[NMPAG*PGSIZ];
        !            63: main(argc,argv,envp)
        !            64: int argc;
        !            65: char *argv[];
        !            66: char *envp[];
        !            67: {
        !            68:        int     seed = 1;
        !            69:        int     i;
        !            70:        int     loadgo, j;
        !            71:        endfcnt = 0;    /* initialize structured "if" nest count */
        !            72:        loadgo = 0;     /* init load and go flag */
        !            73:        /*
        !            74:         * Look for BITEPATH in environment and
        !            75:         * append to end of internal search path.
        !            76:         * Users can define their own searchpath for BITE
        !            77:         * by adding BITEPATH=:path1:path2: etc. in their profile
        !            78:         */
        !            79:        for(i=0; envp[i] != 0; i++)
        !            80:        {
        !            81:                if(strncmp("BITEPATH",envp[i],8) == 0)
        !            82:                {
        !            83:                        strcat(bpath,&envp[i][9]);
        !            84:                        break;
        !            85:                }
        !            86:        }
        !            87:        linptr=lbdptr=curptr=txtbuf;
        !            88:        signal(2,quit);
        !            89:        rem=encode("rem");
        !            90:        tv=encode("n");
        !            91:        tospgo=encode("go to");
        !            92:        tsil=encode("list");
        !            93:        atad=encode("data");
        !            94:        daol = encode("load");
        !            95:        evas = encode("save");
        !            96:        dlo = encode("old");
        !            97:        bat = encode("!");
        !            98:        nxt=encode("next");
        !            99:        _sub=encode("s");
        !           100:        _fi=encode("if");
        !           101:        subog=encode("gosub");
        !           102:        no = encode("on");
        !           103:        _togo=encode("goto");
        !           104:        tel=encode("\010");
        !           105:        esle=encode("else");
        !           106:        fidne=encode("endif");
        !           107:        rof=encode("for");
        !           108:        sl=encode("ls");
        !           109:        mr=encode("mr");
        !           110:        initvar();
        !           111:        srand(seed);    /* init random number gen */
        !           112: #ifdef TEST
        !           113:        ibinit(); /* IEEE bus init */
        !           114:        bdvminit(); /* digital voltmeter init */
        !           115: #endif
        !           116: #ifdef LSX
        !           117:        iinit(); /* keyboard interrupt enable */
        !           118: #endif
        !           119:        if(argc > 1)
        !           120:        {
        !           121:                j = 1;                  /* init arg index to 1 */
        !           122:                if(argc > 2 && *argv[1] == '-') /* run flag? */
        !           123:                {
        !           124:                        j = 2;          /* load starting at arg 2 */
        !           125:                        --argc;         /* decrement arg count */
        !           126:                }
        !           127:                else
        !           128:                {
        !           129:                        loadgo = 1;     /* set run flag */
        !           130:                }
        !           131:                for(i=j;--argc;i++)
        !           132:                {
        !           133:                        expr = argv[i];
        !           134:                        load();
        !           135:                }
        !           136:                if(loadgo)      /* run? */
        !           137:                {
        !           138:                        expr = linbuf;
        !           139:                        *expr = '\0';
        !           140:                        run();
        !           141:                }
        !           142:        }
        !           143:        while(1)
        !           144:        {
        !           145:                nquit = 0;
        !           146:                if(bed(stdin) < 0 && nquit != 1) break;
        !           147:        }
        !           148: }
        !           149: nocode(code)
        !           150: int    code;
        !           151: {
        !           152:        int i;
        !           153:        static int *list[] =
        !           154:                { &daol,
        !           155:                &evas,
        !           156:                &dlo,
        !           157:                &rem,
        !           158:                &bat,
        !           159:                &_sub,
        !           160:                &mr,
        !           161:                &sl,
        !           162:                0 };
        !           163:        for(i=0;list[i] !=0;i++)
        !           164:        {
        !           165:                if(code == *list[i])
        !           166:                return(1);
        !           167:        }
        !           168:                return(0);
        !           169: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.