14887Schin /***********************************************************************
24887Schin *                                                                      *
34887Schin *               This software is part of the ast package               *
4*8462SApril.Chin@Sun.COM *          Copyright (c) 1982-2008 AT&T Intellectual Property          *
54887Schin *                      and is licensed under the                       *
64887Schin *                  Common Public License, Version 1.0                  *
7*8462SApril.Chin@Sun.COM *                    by AT&T Intellectual Property                     *
84887Schin *                                                                      *
94887Schin *                A copy of the License is available at                 *
104887Schin *            http://www.opensource.org/licenses/cpl1.0.txt             *
114887Schin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
124887Schin *                                                                      *
134887Schin *              Information and Software Systems Research               *
144887Schin *                            AT&T Research                             *
154887Schin *                           Florham Park NJ                            *
164887Schin *                                                                      *
174887Schin *                  David Korn <dgk@research.att.com>                   *
184887Schin *                                                                      *
194887Schin ***********************************************************************/
204887Schin #pragma prototyped
214887Schin #ifndef ARG_RAW
224887Schin /*
234887Schin  *	struct to hold a word argument
244887Schin  *	Written by David Korn
254887Schin  *
264887Schin  */
274887Schin 
284887Schin #include	<stak.h>
294887Schin 
304887Schin struct ionod
314887Schin {
324887Schin 	unsigned	iofile;
334887Schin 	char		*ioname;
344887Schin 	struct ionod	*ionxt;
354887Schin 	struct ionod	*iolst;
364887Schin 	char		*iodelim;
374887Schin 	off_t		iooffset;
384887Schin 	long		iosize;
394887Schin 	char		*iovname;
404887Schin };
414887Schin 
424887Schin struct comnod
434887Schin {
444887Schin 	int		comtyp;
454887Schin 	struct ionod	*comio;
464887Schin 	struct argnod	*comarg;
474887Schin 	struct argnod	*comset;
484887Schin 	void		*comnamp;
494887Schin 	void		*comnamq;
504887Schin 	void		*comstate;
514887Schin 	int		comline;
524887Schin };
534887Schin 
544887Schin #define COMBITS		4
554887Schin #define COMMSK		((1<<COMBITS)-1)
564887Schin #define COMSCAN		(01<<COMBITS)
574887Schin #define COMFIXED	(02<<COMBITS)
584887Schin 
594887Schin struct slnod 	/* struct for link list of stacks */
604887Schin {
614887Schin 	struct slnod	*slnext;
624887Schin 	struct slnod	*slchild;
634887Schin 	Stak_t		*slptr;
644887Schin };
654887Schin 
664887Schin /*
674887Schin  * This struct is use to hold $* lists and arrays
684887Schin  */
694887Schin 
704887Schin struct dolnod
714887Schin {
72*8462SApril.Chin@Sun.COM 	int		dolrefcnt;	/* reference count */
73*8462SApril.Chin@Sun.COM 	int		dolmax;		/* size of dolval array */
74*8462SApril.Chin@Sun.COM 	int		dolnum;		/* number of elements */
75*8462SApril.Chin@Sun.COM 	int		dolbot;		/* current first element */
764887Schin 	struct dolnod	*dolnxt;	/* used when list are chained */
774887Schin 	char		*dolval[1];	/* array of value pointers */
784887Schin };
794887Schin 
804887Schin /*
814887Schin  * This struct is used to hold word arguments of variable size during
824887Schin  * parsing and during expansion.  The flags indicate what processing
834887Schin  * is required on the argument.
844887Schin  */
854887Schin 
864887Schin struct argnod
874887Schin {
884887Schin 	union
894887Schin 	{
904887Schin 		struct argnod	*ap;
914887Schin 		char		*cp;
924887Schin 	}		argnxt;
934887Schin 	union
944887Schin 	{
954887Schin 		struct argnod	*ap;
964887Schin 		char		*cp;
974887Schin 		int		len;
984887Schin 	}		argchn;
994887Schin 	unsigned char	argflag;
1004887Schin 	char		argval[4];
1014887Schin };
1024887Schin 
1034887Schin 
1044887Schin 
1054887Schin /* The following should evaluate to the offset of argval in argnod */
1064887Schin #define ARGVAL		offsetof(struct argnod,argval[0])
1074887Schin #define sh_argstr(ap)	((ap)->argflag&ARG_RAW?sh_fmtq((ap)->argval):(ap)->argval)
1084887Schin #define ARG_SPARE 1
1094887Schin 
1104887Schin 
1114887Schin /* legal argument flags */
1124887Schin #define ARG_RAW		0x1	/* string needs no processing */
1134887Schin #define ARG_MAKE	0x2	/* bit set during argument expansion */
1144887Schin #define ARG_COMSUB	0x2	/* command sub */
1154887Schin #define ARG_MAC		0x4	/* string needs macro expansion */
1164887Schin #define	ARG_EXP		0x8	/* string needs file expansion */
1174887Schin #define ARG_ASSIGN	0x10	/* argument is an assignment */
1184887Schin #define ARG_QUOTED	0x20	/* word contained quote characters */
1194887Schin #define ARG_MESSAGE	0x40	/* contains international string */
1204887Schin #define ARG_APPEND	0x80	/* for += assignment */
1214887Schin /*  The following can be passed as options to sh_macexpand() */
1224887Schin #define ARG_ARITH	0x100	/* arithmetic expansion */
1234887Schin #define ARG_OPTIMIZE	0x200	/* try to optimize */
1244887Schin #define ARG_NOGLOB	0x400	/* no file name expansion */
1254887Schin #define ARG_LET		0x800	/* processing let command arguments */
126*8462SApril.Chin@Sun.COM #define ARG_ARRAYOK	0x1000	/* $x[sub] ==> ${x[sub]} */
1274887Schin 
1284887Schin extern struct dolnod	*sh_argcreate(char*[]);
129*8462SApril.Chin@Sun.COM extern char 		*sh_argdolminus(void*);
130*8462SApril.Chin@Sun.COM extern int		sh_argopts(int,char*[],void*);
131*8462SApril.Chin@Sun.COM 
1324887Schin 
1334887Schin extern const char	e_heading[];
1344887Schin extern const char	e_off[];
1354887Schin extern const char	e_on[];
1364887Schin extern const char	e_sptbnl[];
1374887Schin extern const char	e_subst[];
1384887Schin extern const char	e_option[];
1394887Schin extern const char	e_exec[];
1404887Schin extern const char	e_devfdNN[];
1414887Schin extern const char	e_devfdstd[];
1424887Schin 
1434887Schin #endif /* ARG_RAW */
144