|
|
1.1 ! root 1: /* ! 2: * Plan9 is defined for plan 9 ! 3: * V9 is defined for 9th edition ! 4: * Sun is defined for sun-os ! 5: * Please don't litter the code with ifdefs. The three below (and one in ! 6: * getflags) should be enough. ! 7: */ ! 8: #define Plan9 ! 9: #ifdef Plan9 ! 10: #include <u.h> ! 11: #include <libc.h> ! 12: #define NSIG 32 ! 13: #define SIGINT 2 ! 14: #define SIGQUIT 3 ! 15: #endif ! 16: #ifdef V9 ! 17: #include <signal.h> ! 18: #include <libc.h> ! 19: #endif ! 20: #ifdef Sun ! 21: #include <signal.h> ! 22: #endif ! 23: #define YYMAXDEPTH 500 ! 24: #ifndef PAREN ! 25: #include "x.tab.h" ! 26: #endif ! 27: typedef struct tree tree; ! 28: typedef struct word word; ! 29: typedef struct io io; ! 30: typedef union code code; ! 31: typedef struct var var; ! 32: typedef struct list list; ! 33: typedef struct redir redir; ! 34: typedef struct thread thread; ! 35: typedef struct builtin builtin; ! 36: ! 37: struct tree{ ! 38: int type; ! 39: int rtype, fd0, fd1; /* details of REDIR PIPE DUP tokens */ ! 40: char *str; ! 41: int quoted; ! 42: int iskw; ! 43: tree *child[3]; ! 44: tree *next; ! 45: }; ! 46: tree *newtree(void); ! 47: tree *token(char*, int), *klook(char*), *tree1(int, tree*); ! 48: tree *tree2(int, tree*, tree*), *tree3(int, tree*, tree*, tree*); ! 49: tree *mung1(tree*, tree*), *mung2(tree*, tree*, tree*); ! 50: tree *mung3(tree*, tree*, tree*, tree*), *epimung(tree*, tree*); ! 51: tree *simplemung(tree*), *heredoc(tree*); ! 52: void freetree(tree*); ! 53: tree *cmdtree; ! 54: /* ! 55: * The first word of any code vector is a reference count. ! 56: * Always create a new reference to a code vector by calling codecopy(.). ! 57: * Always call codefree(.) when deleting a reference. ! 58: */ ! 59: union code{ ! 60: void (*f)(void); ! 61: int i; ! 62: char *s; ! 63: }; ! 64: char *promptstr; ! 65: int doprompt; ! 66: #define NTOK 8192 ! 67: char tok[NTOK]; ! 68: #define APPEND 1 ! 69: #define WRITE 2 ! 70: #define READ 3 ! 71: #define HERE 4 ! 72: #define DUPFD 5 ! 73: #define CLOSE 6 ! 74: struct var{ ! 75: char *name; /* ascii name */ ! 76: word *val; /* value */ ! 77: int changed; ! 78: code *fn; /* pointer to function's code vector */ ! 79: int fnchanged; ! 80: int pc; /* pc of start of function */ ! 81: var *next; /* next on hash or local list */ ! 82: }; ! 83: var *vlook(char*), *gvlook(char*), *newvar(char*, var*); ! 84: #define NVAR 521 ! 85: var *gvar[NVAR]; /* hash for globals */ ! 86: #define new(type) ((type *)emalloc(sizeof(type))) ! 87: char *emalloc(long); ! 88: void *Malloc(ulong); ! 89: void efree(char*); ! 90: #define NOFILE 128 /* should come from <param.h> */ ! 91: struct here{ ! 92: tree *tag; ! 93: char *name; ! 94: struct here *next; ! 95: }; ! 96: int mypid; ! 97: /* ! 98: * Glob character escape in strings: ! 99: * In a string, GLOB must be followed by *?[ or GLOB. ! 100: * GLOB* matches any string ! 101: * GLOB? matches any single character ! 102: * GLOB[...] matches anything in the brackets ! 103: * GLOBGLOB matches GLOB ! 104: */ ! 105: #define GLOB ((char)0x01) ! 106: /* ! 107: * onebyte(c), twobyte(c), threebyte(c) ! 108: * Is c the first character of a one- two- or three-byte utf sequence? ! 109: */ ! 110: #define onebyte(c) ((c&0x80)==0x00) ! 111: #define twobyte(c) ((c&0xe0)==0xc0) ! 112: #define threebyte(c) ((c&0xf0)==0xe0) ! 113: char **argp; ! 114: char **args; ! 115: int nerror; /* number of errors encountered during compilation */ ! 116: int doprompt; /* is it time for a prompt? */ ! 117: /* ! 118: * Which fds are the reading/writing end of a pipe? ! 119: * Unfortunately, this can vary from system to system. ! 120: * 9th edition Unix doesn't care, the following defines ! 121: * work on plan 9. ! 122: */ ! 123: #define PRD 0 ! 124: #define PWR 1 ! 125: char Rcmain[], Fdprefix[]; ! 126: #define register ! 127: /* ! 128: * How many dot commands have we executed? ! 129: * Used to ensure that -v flag doesn't print rcmain. ! 130: */ ! 131: int ndot; ! 132: char *getstatus(void); ! 133: int lastc;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.