Annotation of researchv10no/cmd/spitbol/cint/syshs.c, revision 1.1

1.1     ! root        1: /*
        !             2: /   syshs - host functions
        !             3: */
        !             4: 
        !             5: #include "osint.h"
        !             6: #include "spitblks.h"
        !             7: 
        !             8: extern WORD    gblargc;
        !             9: extern char    *gblargv[];
        !            10: extern char    *uarg;
        !            11: extern WORD    cmdcnt;
        !            12: 
        !            13: extern struct icblk    ticblk;
        !            14: extern struct scblk    tscblk;
        !            15: 
        !            16: extern WORD    ic_type;
        !            17: extern WORD    sc_type;
        !            18: 
        !            19: syshs()
        !            20: {
        !            21:        WORD    retval;
        !            22:        register struct icblk *icp = WA (struct icblk *);
        !            23:        register struct scblk *scp;
        !            24: 
        !            25: /*
        !            26: /   If argument one is an integer ...
        !            27: */
        !            28:        if ( icp->typ == ic_type )
        !            29:            switch( icp->val )
        !            30:            {
        !            31: 
        !            32: /*
        !            33: /          HOST( 0 ) returns the -u command line option argument
        !            34: */
        !            35:            case 0:
        !            36:                if ( uarg )
        !            37:                {
        !            38:                    cpys2sc( uarg, 0, &tscblk, tscblk.len );
        !            39:                    SET_XL( &tscblk );
        !            40:                    return  EXIT_3;
        !            41:                }
        !            42:                else
        !            43:                    return  EXIT_4;
        !            44: 
        !            45: /*
        !            46: /          HOST( 1, "command" ) executes "command"
        !            47: */
        !            48:            case 1:
        !            49:                scp = XL( struct scblk * );
        !            50:                if ( scp->typ == sc_type )
        !            51:                {
        !            52:                    if ( scp->len != 0 )
        !            53:                        dosys( scp );
        !            54:                    return  EXIT_4;
        !            55:                }
        !            56:                else
        !            57:                    return  EXIT_1;
        !            58: 
        !            59: /*
        !            60: /          HOST( 2, n ) returns command line argument n
        !            61: */
        !            62:            case 2:
        !            63:                icp = XL( struct icblk * );
        !            64:                if ( icp->typ == ic_type )
        !            65:                {
        !            66:                    retval = arg2scb( icp->val, gblargc, gblargv, &tscblk );
        !            67:                    if ( retval < 0 )
        !            68:                        return  EXIT_6;
        !            69:                    if ( retval == 0 )
        !            70:                        return  EXIT_1;
        !            71:                    SET_XL( &tscblk );
        !            72:                    return  EXIT_3;
        !            73:                }               
        !            74:                else
        !            75:                    return  EXIT_1;
        !            76: 
        !            77: /*
        !            78: /          HOST( 3 ) returns the command count
        !            79: */
        !            80:            case 3:
        !            81:                if ( cmdcnt )
        !            82:                {
        !            83:                    ticblk.val = cmdcnt;
        !            84:                    SET_XR( &ticblk );
        !            85:                    return  EXIT_5;
        !            86:                }
        !            87:                else
        !            88:                    return  EXIT_6;
        !            89: 
        !            90: /*
        !            91: /          HOST( 4, "env-var" ) returns the value of "env-var" from
        !            92: /          the environment.
        !            93: */
        !            94:            case 4:
        !            95:                scp = XL( struct scblk * );
        !            96:                if ( scp->typ == sc_type )
        !            97:                {
        !            98:                    if ( scp->len == 0 )
        !            99:                        return  EXIT_1;
        !           100:                    if ( rdenv( scp, &tscblk ) < 0 )
        !           101:                        return  EXIT_6;
        !           102:                    SET_XL( &tscblk );
        !           103:                    return  EXIT_3;
        !           104:                }
        !           105:                else
        !           106:                    return  EXIT_1;
        !           107: 
        !           108: /*
        !           109: /          Any other integer value is an error
        !           110: */
        !           111:            default:
        !           112:                return  EXIT_1;
        !           113:            }           
        !           114: 
        !           115: 
        !           116: /*
        !           117: /    ... else just return the host string
        !           118: */
        !           119:        else
        !           120:        {
        !           121:            gethost( &tscblk, TSCBLK_LENGTH );
        !           122:            if ( tscblk.len == 0 )
        !           123:                return  EXIT_4;
        !           124:            SET_XL( &tscblk );
        !           125:            return  EXIT_3;
        !           126:        }
        !           127: 
        !           128: /*
        !           129: /   Control SHOULD NEVER GET HERE!!
        !           130: */
        !           131:        return  EXIT_1;
        !           132: }

unix.superglobalmegacorp.com

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