1da2e3ebdSchin /***********************************************************************
2da2e3ebdSchin *                                                                      *
3da2e3ebdSchin *               This software is part of the ast package               *
4*b30d1939SAndy Fiddaman *          Copyright (c) 1982-2011 AT&T Intellectual Property          *
5da2e3ebdSchin *                      and is licensed under the                       *
6*b30d1939SAndy Fiddaman *                 Eclipse Public License, Version 1.0                  *
77c2fbfb3SApril Chin *                    by AT&T Intellectual Property                     *
8da2e3ebdSchin *                                                                      *
9da2e3ebdSchin *                A copy of the License is available at                 *
10*b30d1939SAndy Fiddaman *          http://www.eclipse.org/org/documents/epl-v10.html           *
11*b30d1939SAndy Fiddaman *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12da2e3ebdSchin *                                                                      *
13da2e3ebdSchin *              Information and Software Systems Research               *
14da2e3ebdSchin *                            AT&T Research                             *
15da2e3ebdSchin *                           Florham Park NJ                            *
16da2e3ebdSchin *                                                                      *
17da2e3ebdSchin *                  David Korn <dgk@research.att.com>                   *
18da2e3ebdSchin *                                                                      *
19da2e3ebdSchin ***********************************************************************/
20da2e3ebdSchin #pragma prototyped
21da2e3ebdSchin #ifndef ARG_RAW
22da2e3ebdSchin /*
23da2e3ebdSchin  *	struct to hold a word argument
24da2e3ebdSchin  *	Written by David Korn
25da2e3ebdSchin  *
26da2e3ebdSchin  */
27da2e3ebdSchin 
28da2e3ebdSchin #include	<stak.h>
29da2e3ebdSchin 
30da2e3ebdSchin struct ionod
31da2e3ebdSchin {
32da2e3ebdSchin 	unsigned	iofile;
33da2e3ebdSchin 	char		*ioname;
34da2e3ebdSchin 	struct ionod	*ionxt;
35da2e3ebdSchin 	struct ionod	*iolst;
36da2e3ebdSchin 	char		*iodelim;
37da2e3ebdSchin 	off_t		iooffset;
38da2e3ebdSchin 	long		iosize;
39da2e3ebdSchin 	char		*iovname;
40da2e3ebdSchin };
41da2e3ebdSchin 
42da2e3ebdSchin struct comnod
43da2e3ebdSchin {
44da2e3ebdSchin 	int		comtyp;
45da2e3ebdSchin 	struct ionod	*comio;
46da2e3ebdSchin 	struct argnod	*comarg;
47da2e3ebdSchin 	struct argnod	*comset;
48da2e3ebdSchin 	void		*comnamp;
49da2e3ebdSchin 	void		*comnamq;
50da2e3ebdSchin 	void		*comstate;
51da2e3ebdSchin 	int		comline;
52da2e3ebdSchin };
53da2e3ebdSchin 
54da2e3ebdSchin #define COMBITS		4
55da2e3ebdSchin #define COMMSK		((1<<COMBITS)-1)
56da2e3ebdSchin #define COMSCAN		(01<<COMBITS)
57da2e3ebdSchin #define COMFIXED	(02<<COMBITS)
58da2e3ebdSchin 
59da2e3ebdSchin struct slnod 	/* struct for link list of stacks */
60da2e3ebdSchin {
61da2e3ebdSchin 	struct slnod	*slnext;
62da2e3ebdSchin 	struct slnod	*slchild;
63da2e3ebdSchin 	Stak_t		*slptr;
6434f9b3eeSRoland Mainz 	/* slpad aligns struct functnod = struct slnod + 1 on some architectures */
6534f9b3eeSRoland Mainz 	struct slnod	*slpad;
66da2e3ebdSchin };
67da2e3ebdSchin 
68da2e3ebdSchin /*
69da2e3ebdSchin  * This struct is use to hold $* lists and arrays
70da2e3ebdSchin  */
71da2e3ebdSchin 
72da2e3ebdSchin struct dolnod
73da2e3ebdSchin {
747c2fbfb3SApril Chin 	int		dolrefcnt;	/* reference count */
757c2fbfb3SApril Chin 	int		dolmax;		/* size of dolval array */
767c2fbfb3SApril Chin 	int		dolnum;		/* number of elements */
777c2fbfb3SApril Chin 	int		dolbot;		/* current first element */
78da2e3ebdSchin 	struct dolnod	*dolnxt;	/* used when list are chained */
79da2e3ebdSchin 	char		*dolval[1];	/* array of value pointers */
80da2e3ebdSchin };
81da2e3ebdSchin 
82da2e3ebdSchin /*
83da2e3ebdSchin  * This struct is used to hold word arguments of variable size during
84da2e3ebdSchin  * parsing and during expansion.  The flags indicate what processing
85da2e3ebdSchin  * is required on the argument.
86da2e3ebdSchin  */
87da2e3ebdSchin 
88da2e3ebdSchin struct argnod
89da2e3ebdSchin {
90da2e3ebdSchin 	union
91da2e3ebdSchin 	{
92da2e3ebdSchin 		struct argnod	*ap;
93da2e3ebdSchin 		char		*cp;
94da2e3ebdSchin 	}		argnxt;
95da2e3ebdSchin 	union
96da2e3ebdSchin 	{
97da2e3ebdSchin 		struct argnod	*ap;
98da2e3ebdSchin 		char		*cp;
99da2e3ebdSchin 		int		len;
100da2e3ebdSchin 	}		argchn;
101da2e3ebdSchin 	unsigned char	argflag;
102da2e3ebdSchin 	char		argval[4];
103da2e3ebdSchin };
104da2e3ebdSchin 
105da2e3ebdSchin 
106da2e3ebdSchin 
107da2e3ebdSchin /* The following should evaluate to the offset of argval in argnod */
108da2e3ebdSchin #define ARGVAL		offsetof(struct argnod,argval[0])
109da2e3ebdSchin #define sh_argstr(ap)	((ap)->argflag&ARG_RAW?sh_fmtq((ap)->argval):(ap)->argval)
110da2e3ebdSchin #define ARG_SPARE 1
111da2e3ebdSchin 
112da2e3ebdSchin 
113da2e3ebdSchin /* legal argument flags */
114da2e3ebdSchin #define ARG_RAW		0x1	/* string needs no processing */
115da2e3ebdSchin #define ARG_MAKE	0x2	/* bit set during argument expansion */
116da2e3ebdSchin #define ARG_COMSUB	0x2	/* command sub */
117da2e3ebdSchin #define ARG_MAC		0x4	/* string needs macro expansion */
118da2e3ebdSchin #define	ARG_EXP		0x8	/* string needs file expansion */
119da2e3ebdSchin #define ARG_ASSIGN	0x10	/* argument is an assignment */
120da2e3ebdSchin #define ARG_QUOTED	0x20	/* word contained quote characters */
121da2e3ebdSchin #define ARG_MESSAGE	0x40	/* contains international string */
122da2e3ebdSchin #define ARG_APPEND	0x80	/* for += assignment */
123da2e3ebdSchin /*  The following can be passed as options to sh_macexpand() */
124da2e3ebdSchin #define ARG_ARITH	0x100	/* arithmetic expansion */
125da2e3ebdSchin #define ARG_OPTIMIZE	0x200	/* try to optimize */
126da2e3ebdSchin #define ARG_NOGLOB	0x400	/* no file name expansion */
127da2e3ebdSchin #define ARG_LET		0x800	/* processing let command arguments */
1287c2fbfb3SApril Chin #define ARG_ARRAYOK	0x1000	/* $x[sub] ==> ${x[sub]} */
129da2e3ebdSchin 
130da2e3ebdSchin extern struct dolnod	*sh_argcreate(char*[]);
1317c2fbfb3SApril Chin extern char 		*sh_argdolminus(void*);
1327c2fbfb3SApril Chin extern int		sh_argopts(int,char*[],void*);
1337c2fbfb3SApril Chin 
134da2e3ebdSchin 
135da2e3ebdSchin extern const char	e_heading[];
136da2e3ebdSchin extern const char	e_off[];
137da2e3ebdSchin extern const char	e_on[];
138da2e3ebdSchin extern const char	e_sptbnl[];
139da2e3ebdSchin extern const char	e_subst[];
140da2e3ebdSchin extern const char	e_option[];
141da2e3ebdSchin extern const char	e_exec[];
142da2e3ebdSchin extern const char	e_devfdNN[];
143da2e3ebdSchin extern const char	e_devfdstd[];
144da2e3ebdSchin 
145da2e3ebdSchin #endif /* ARG_RAW */
146