Annotation of coherent/a/usr/bob/korn/table.h, revision 1.1

1.1     ! root        1: /* $Header: table.h,v 3.1 88/11/03 09:13:56 egisin Exp $ */
        !             2: 
        !             3: /*
        !             4:  * generic hashed associative table for commands and variables.
        !             5:  */
        !             6: 
        !             7: struct table {
        !             8:        Area   *areap;          /* area to allocate enties */
        !             9:        short   size, free;     /* hash size (always 2^^n), free entries */
        !            10:        struct  tbl **tbls;     /* hashed table items */
        !            11: };
        !            12: 
        !            13: struct tbl {                   /* table item */
        !            14:        short   flag;           /* flags */
        !            15:        short   type;           /* command type or base, see below */
        !            16:        union {
        !            17:                char *s;        /* string */
        !            18:                long i;         /* integer */
        !            19:                int (*f)();     /* int function */
        !            20:                struct op *t;   /* "function" tree */
        !            21:        } val;                  /* value */
        !            22:        char    name[4];        /* name -- variable length */
        !            23: };
        !            24: 
        !            25: /* flag bits */
        !            26: #define        ALLOC   BIT(0)          /* val.s has been allocated */
        !            27: #define        DEFINED BIT(1)          /* is defined in block */
        !            28: #define        ISSET   BIT(2)          /* has value, vp->val.[si] */
        !            29: #define        SPECIAL BIT(3)          /* PATH, IFS, SECONDS, etc */
        !            30: #define        INTEGER BIT(4)          /* val.i contains integer value */
        !            31: #define        RDONLY  BIT(8)          /* read-only variable */
        !            32: #define        EXPORT  BIT(9)          /* exported variable */
        !            33: #define        LOCAL   BIT(10)         /* for local typeset() */
        !            34: #define        TRACE   BIT(11)         /* trace (-t) */
        !            35: #define        FUNCT   BIT(12)         /* function */
        !            36: 
        !            37: /* command types */
        !            38: #define        CNONE   0               /* undefined */
        !            39: #define        CSHELL  1               /* built-in */
        !            40: #define        CFUNC   2               /* function */
        !            41: #define        CEXEC   4               /* executable command */
        !            42: #define        CALIAS  5               /* alias */
        !            43: #define        CKEYWD  6               /* keyword */
        !            44: 
        !            45: void tinit ARGS((struct table *, Area *)); /* initialize table */
        !            46: unsigned int hash();           /* name hash function */
        !            47: struct tbl *tsearch();         /* table lookup primative */
        !            48: struct tbl *tenter();          /* table lookup/enter primative */
        !            49: void tdelete();                        /* mark tbl entry for deletion */
        !            50: void twalk();                  /* initialize walk of table */
        !            51: struct tbl *tnext();           /* walk table returning table time */
        !            52: struct tbl **tsort();          /* sort table entries by name */
        !            53: 
        !            54: /*
        !            55:  * activation record for function blocks
        !            56:  */
        !            57: struct block {
        !            58:        Area    area;           /* area to allocate things */
        !            59:        int     argc;           /* current $# */
        !            60:        char ** argv;           /* current $* */
        !            61:        struct  table vars;     /* local variables */
        !            62:        struct  table funs;     /* local functions */
        !            63: #if 1
        !            64:        char *  error;          /* error handler */
        !            65:        char *  exit;           /* exit handler */
        !            66: #else
        !            67:        struct  trap error, exit;
        !            68: #endif
        !            69:        struct  block *next;    /* enclosing block */
        !            70: };
        !            71: 
        !            72: Extern struct block globals;   /* global variables and functions */
        !            73: Extern struct table commands;  /* hashed commands */
        !            74: Extern struct table builtins;  /* built-in commands */
        !            75: Extern struct table lexicals;  /* keywords and aliases */
        !            76: Extern struct table homedirs;  /* homedir() cache */
        !            77: 
        !            78: struct builtin {
        !            79:        char   *name;
        !            80:        int  (*func)();
        !            81: };
        !            82: Extern Const struct builtin shbuiltins[1], kshbuiltins[1];
        !            83: 
        !            84: /* var spec values */
        !            85: #define        V_NONE  0
        !            86: #define        V_PATH  1
        !            87: #define        V_IFS   2
        !            88: #define        V_SECONDS 3
        !            89: #define        V_OPTIND 4
        !            90: 
        !            91: Extern Area   *lastarea;       /* area of last variable/function looked up */
        !            92: Extern char   *path;           /* PATH value */
        !            93: Extern char   *prompt;         /* PS1 or PS2 */
        !            94: 
        !            95: void   newblock();
        !            96: void   popblock();
        !            97: struct tbl *global(/* char *s */);
        !            98: struct tbl *local(/* char *s */);
        !            99: struct tbl *typeset(/* char *var; int set, clr */);
        !           100: struct tbl *setvar(/* struct tbl *vdst, *vsrc */);
        !           101: struct tbl *strint(/* struct tbl *vdst, *vsrc */);
        !           102: long   intval(/* struct tbl *vp */);
        !           103: void   setint(/* struct tbl *vp; long n */);
        !           104: char   *strval(/* struct tbl *vp */);
        !           105: void   setstr(/* struct tbl *vp; char *s */);
        !           106: void   unset(/* struct tbl *vp */);
        !           107: int    import(/* char *s */);
        !           108: char  **makenv();
        !           109: int    isassign(/* char *s */);
        !           110: 

unix.superglobalmegacorp.com

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