1 /*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kenneth Almquist. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)parser.h 8.3 (Berkeley) 05/04/95 11 */ 12 13 /* control characters in argument strings */ 14 #define CTLESC '\201' 15 #define CTLVAR '\202' 16 #define CTLENDVAR '\203' 17 #define CTLBACKQ '\204' 18 #define CTLQUOTE 01 /* ored with CTLBACKQ code if in quotes */ 19 /* CTLBACKQ | CTLQUOTE == '\205' */ 20 #define CTLARI '\206' 21 #define CTLENDARI '\207' 22 23 /* variable substitution byte (follows CTLVAR) */ 24 #define VSTYPE 0x0f /* type of variable substitution */ 25 #define VSNUL 0x10 /* colon--treat the empty string as unset */ 26 #define VSQUOTE 0x80 /* inside double quotes--suppress splitting */ 27 28 /* values of VSTYPE field */ 29 #define VSNORMAL 0x1 /* normal variable: $var or ${var} */ 30 #define VSMINUS 0x2 /* ${var-text} */ 31 #define VSPLUS 0x3 /* ${var+text} */ 32 #define VSQUESTION 0x4 /* ${var?message} */ 33 #define VSASSIGN 0x5 /* ${var=text} */ 34 #define VSTRIMLEFT 0x6 /* ${var#pattern} */ 35 #define VSTRIMLEFTMAX 0x7 /* ${var##pattern} */ 36 #define VSTRIMRIGHT 0x8 /* ${var%pattern} */ 37 #define VSTRIMRIGHTMAX 0x9 /* ${var%%pattern} */ 38 #define VSLENGTH 0xa /* ${#var} */ 39 40 41 /* 42 * NEOF is returned by parsecmd when it encounters an end of file. It 43 * must be distinct from NULL, so we use the address of a variable that 44 * happens to be handy. 45 */ 46 extern int tokpushback; 47 #define NEOF ((union node *)&tokpushback) 48 extern int whichprompt; /* 1 == PS1, 2 == PS2 */ 49 50 51 union node *parsecmd __P((int)); 52 void fixredir __P((union node *, const char *, int)); 53 int goodname __P((char *)); 54 char *getprompt __P((void *)); 55