|
|
1.1 ! root 1: /* ! 2: * command trees for compile/execute ! 3: */ ! 4: ! 5: /* $Header: tree.h,v 3.1 88/11/03 09:14:02 egisin Exp $ */ ! 6: ! 7: #define NOBLOCK ((struct op *)NULL) ! 8: #define NOWORD ((char *)NULL) ! 9: #define NOWORDS ((char **)NULL) ! 10: ! 11: /* ! 12: * Description of a command or an operation on commands. ! 13: */ ! 14: struct op { ! 15: int type; /* operation type, see below */ ! 16: char **args; /* arguments to a command */ ! 17: char **vars; /* variable assignments */ ! 18: struct ioword **ioact; /* IO actions (eg, < > >>) */ ! 19: struct op *left, *right; /* descendents */ ! 20: char *str; /* identifier for case and for (use vars[0]) */ ! 21: }; ! 22: ! 23: /* Tree.type values */ ! 24: #define TEOF 0 ! 25: #define TCOM 1 /* command */ ! 26: #define TPAREN 2 /* (c-list) */ ! 27: #define TPIPE 3 /* a | b */ ! 28: #define TLIST 4 /* a [&;] b */ ! 29: #define TOR 5 /* || */ ! 30: #define TAND 6 /* && */ ! 31: #define TFOR 7 ! 32: #define TCASE 9 ! 33: #define TIF 10 ! 34: #define TWHILE 11 ! 35: #define TUNTIL 12 ! 36: #define TELIF 13 ! 37: #define TPAT 14 /* pattern in case */ ! 38: #define TBRACE 15 /* {c-list} */ ! 39: #define TASYNC 16 /* c & */ ! 40: #define TFUNCT 17 /* function name { command; } */ ! 41: #define TTIME 18 /* time pipeline */ ! 42: #define TEXEC 19 /* fork/exec eval'd TCOM */ ! 43: ! 44: /* ! 45: * prefix codes for words in command tree ! 46: */ ! 47: #define EOS 0 /* end of string */ ! 48: #define CHAR 1 /* unquoted character */ ! 49: #define QCHAR 2 /* quoted character */ ! 50: #define COMSUB 3 /* $() substitution (0 terminated) */ ! 51: #define OQUOTE 4 /* opening " or ' */ ! 52: #define CQUOTE 5 /* closing " or ' */ ! 53: #define OSUBST 6 /* opening ${ substitution */ ! 54: #define CSUBST 7 /* closing } of above */ ! 55: ! 56: /* ! 57: * IO redirection ! 58: */ ! 59: struct ioword { ! 60: short unit; /* unit affected */ ! 61: short flag; /* action (below) */ ! 62: char *name; /* file name */ ! 63: }; ! 64: ! 65: /* ioword.flag */ ! 66: #define IOREAD BIT(0) /* < */ ! 67: #define IOHERE BIT(1) /* << (here file) */ ! 68: #define IOWRITE BIT(2) /* > */ ! 69: #define IOCAT BIT(3) /* >> */ ! 70: #define IOXHERE BIT(4) /* expand in << */ ! 71: #define IODUP BIT(5) /* [<>]& */ ! 72: ! 73: /* values for E_LOOP longjmp */ ! 74: #define LBREAK 1 ! 75: #define LCONTIN 2 ! 76: ! 77: /* execute/exchild flags */ ! 78: #define XEXEC BIT(0) /* execute without forking */ ! 79: #define XFORK BIT(5) /* fork before executing */ ! 80: #define XBGND BIT(1) /* command & */ ! 81: #define XPIPEI BIT(2) /* input is pipe */ ! 82: #define XPIPEO BIT(3) /* output is pipe */ ! 83: #define XPIPE (XPIPEI|XPIPEO) /* member of pipe */ ! 84: #define XXCOM BIT(4) /* dup2 xcomfd to 1 */ ! 85: ! 86: /* ! 87: * flags to control expansion of words ! 88: */ ! 89: #define DOBLANK BIT(1) /* perform blank interpretation */ ! 90: #define DOGLOB BIT(2) /* expand [?* */ ! 91: #define DOPAT BIT(3) /* quote *?[ */ ! 92: #define DOTILDE BIT(5) /* expand ~ */ ! 93: ! 94: /* job.c: job control primatives */ ! 95: int execute ARGS((struct op *, int flags)); /* execute tree */ ! 96: int exchild ARGS((struct op *, int flags)); /* execute tree as child */ ! 97: int waitfor ARGS((int job)); /* wait for job completion */ ! 98: int waitlast ARGS((void)); /* wait for last job */ ! 99: ! 100: /* eval.c: word expansion */ ! 101: char **eval ARGS((char **wv, int flag)); /* expand words */ ! 102: char *evalstr ARGS((char *wp, int flags)); /* expand word */ ! 103: char *substitute ARGS((Const char *s, int flags)); /* compile and expand string */ ! 104: ! 105: /* tree.c: command trees */ ! 106: void ptree ARGS((struct op *t, FILE *f)); /* print tree */ ! 107: char *wdscan ARGS((char *wp, int c)); /* scan word for prefix */ ! 108: char *wdcopy ARGS((char *wp, Area *)); /* copy word */ ! 109: struct op *tcopy ARGS((struct op *t, Area *)); /* copy tree */ ! 110: void tfree ARGS((struct op *t, Area *)); /* free tree */ ! 111:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.