1*d90bee97SLionel Sambuc /* $NetBSD: parser.h,v 1.18 2013/10/02 19:52:58 christos Exp $ */ 2*d90bee97SLionel Sambuc 3*d90bee97SLionel Sambuc /*- 4*d90bee97SLionel Sambuc * Copyright (c) 1991, 1993 5*d90bee97SLionel Sambuc * The Regents of the University of California. All rights reserved. 6*d90bee97SLionel Sambuc * 7*d90bee97SLionel Sambuc * This code is derived from software contributed to Berkeley by 8*d90bee97SLionel Sambuc * Kenneth Almquist. 9*d90bee97SLionel Sambuc * 10*d90bee97SLionel Sambuc * Redistribution and use in source and binary forms, with or without 11*d90bee97SLionel Sambuc * modification, are permitted provided that the following conditions 12*d90bee97SLionel Sambuc * are met: 13*d90bee97SLionel Sambuc * 1. Redistributions of source code must retain the above copyright 14*d90bee97SLionel Sambuc * notice, this list of conditions and the following disclaimer. 15*d90bee97SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright 16*d90bee97SLionel Sambuc * notice, this list of conditions and the following disclaimer in the 17*d90bee97SLionel Sambuc * documentation and/or other materials provided with the distribution. 18*d90bee97SLionel Sambuc * 3. Neither the name of the University nor the names of its contributors 19*d90bee97SLionel Sambuc * may be used to endorse or promote products derived from this software 20*d90bee97SLionel Sambuc * without specific prior written permission. 21*d90bee97SLionel Sambuc * 22*d90bee97SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23*d90bee97SLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24*d90bee97SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25*d90bee97SLionel Sambuc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26*d90bee97SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27*d90bee97SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28*d90bee97SLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29*d90bee97SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30*d90bee97SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31*d90bee97SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32*d90bee97SLionel Sambuc * SUCH DAMAGE. 33*d90bee97SLionel Sambuc * 34*d90bee97SLionel Sambuc * @(#)parser.h 8.3 (Berkeley) 5/4/95 35*d90bee97SLionel Sambuc */ 36*d90bee97SLionel Sambuc 37*d90bee97SLionel Sambuc /* control characters in argument strings */ 38*d90bee97SLionel Sambuc #define CTL_FIRST '\201' /* first 'special' character */ 39*d90bee97SLionel Sambuc #define CTLESC '\201' /* escape next character */ 40*d90bee97SLionel Sambuc #define CTLVAR '\202' /* variable defn */ 41*d90bee97SLionel Sambuc #define CTLENDVAR '\203' 42*d90bee97SLionel Sambuc #define CTLBACKQ '\204' 43*d90bee97SLionel Sambuc #define CTLQUOTE 01 /* ored with CTLBACKQ code if in quotes */ 44*d90bee97SLionel Sambuc /* CTLBACKQ | CTLQUOTE == '\205' */ 45*d90bee97SLionel Sambuc #define CTLARI '\206' /* arithmetic expression */ 46*d90bee97SLionel Sambuc #define CTLENDARI '\207' 47*d90bee97SLionel Sambuc #define CTLQUOTEMARK '\210' 48*d90bee97SLionel Sambuc #define CTLQUOTEEND '\211' /* only inside ${...} */ 49*d90bee97SLionel Sambuc #define CTL_LAST '\211' /* last 'special' character */ 50*d90bee97SLionel Sambuc 51*d90bee97SLionel Sambuc /* variable substitution byte (follows CTLVAR) */ 52*d90bee97SLionel Sambuc #define VSTYPE 0x0f /* type of variable substitution */ 53*d90bee97SLionel Sambuc #define VSNUL 0x10 /* colon--treat the empty string as unset */ 54*d90bee97SLionel Sambuc #define VSLINENO 0x20 /* expansion of $LINENO, the line number 55*d90bee97SLionel Sambuc follows immediately */ 56*d90bee97SLionel Sambuc #define VSQUOTE 0x80 /* inside double quotes--suppress splitting */ 57*d90bee97SLionel Sambuc 58*d90bee97SLionel Sambuc /* values of VSTYPE field */ 59*d90bee97SLionel Sambuc #define VSNORMAL 0x1 /* normal variable: $var or ${var} */ 60*d90bee97SLionel Sambuc #define VSMINUS 0x2 /* ${var-text} */ 61*d90bee97SLionel Sambuc #define VSPLUS 0x3 /* ${var+text} */ 62*d90bee97SLionel Sambuc #define VSQUESTION 0x4 /* ${var?message} */ 63*d90bee97SLionel Sambuc #define VSASSIGN 0x5 /* ${var=text} */ 64*d90bee97SLionel Sambuc #define VSTRIMLEFT 0x6 /* ${var#pattern} */ 65*d90bee97SLionel Sambuc #define VSTRIMLEFTMAX 0x7 /* ${var##pattern} */ 66*d90bee97SLionel Sambuc #define VSTRIMRIGHT 0x8 /* ${var%pattern} */ 67*d90bee97SLionel Sambuc #define VSTRIMRIGHTMAX 0x9 /* ${var%%pattern} */ 68*d90bee97SLionel Sambuc #define VSLENGTH 0xa /* ${#var} */ 69*d90bee97SLionel Sambuc 70*d90bee97SLionel Sambuc 71*d90bee97SLionel Sambuc /* 72*d90bee97SLionel Sambuc * NEOF is returned by parsecmd when it encounters an end of file. It 73*d90bee97SLionel Sambuc * must be distinct from NULL, so we use the address of a variable that 74*d90bee97SLionel Sambuc * happens to be handy. 75*d90bee97SLionel Sambuc */ 76*d90bee97SLionel Sambuc extern int tokpushback; 77*d90bee97SLionel Sambuc #define NEOF ((union node *)&tokpushback) 78*d90bee97SLionel Sambuc extern int whichprompt; /* 1 == PS1, 2 == PS2 */ 79*d90bee97SLionel Sambuc 80*d90bee97SLionel Sambuc 81*d90bee97SLionel Sambuc union node *parsecmd(int); 82*d90bee97SLionel Sambuc void fixredir(union node *, const char *, int); 83*d90bee97SLionel Sambuc int goodname(char *); 84*d90bee97SLionel Sambuc const char *getprompt(void *); 85