/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1982-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* David Korn <[email protected]> *17* *18***********************************************************************/19#pragma prototyped20#ifndef ARG_RAW21/*22* struct to hold a word argument23* Written by David Korn24*25*/2627#include <stak.h>2829struct ionod30{31unsigned iofile;32char *ioname;33struct ionod *ionxt;34struct ionod *iolst;35char *iodelim;36off_t iooffset;37long iosize;38char *iovname;39};4041struct comnod42{43int comtyp;44struct ionod *comio;45struct argnod *comarg;46struct argnod *comset;47void *comnamp;48void *comnamq;49void *comstate;50int comline;51};5253#define COMBITS 454#define COMMSK ((1<<COMBITS)-1)55#define COMSCAN (01<<COMBITS)56#define COMFIXED (02<<COMBITS)5758struct slnod /* struct for link list of stacks */59{60struct slnod *slnext;61struct slnod *slchild;62Stak_t *slptr;63/* slpad aligns struct functnod = struct slnod + 1 on some architectures */64struct slnod *slpad;65};6667/*68* This struct is use to hold $* lists and arrays69*/7071struct dolnod72{73int dolrefcnt; /* reference count */74int dolmax; /* size of dolval array */75int dolnum; /* number of elements */76int dolbot; /* current first element */77struct dolnod *dolnxt; /* used when list are chained */78char *dolval[1]; /* array of value pointers */79};8081/*82* This struct is used to hold word arguments of variable size during83* parsing and during expansion. The flags indicate what processing84* is required on the argument.85*/8687struct argnod88{89union90{91struct argnod *ap;92char *cp;93} argnxt;94union95{96struct argnod *ap;97char *cp;98int len;99} argchn;100unsigned char argflag;101char argval[4];102};103104105106/* The following should evaluate to the offset of argval in argnod */107#define ARGVAL offsetof(struct argnod,argval[0])108#define sh_argstr(ap) ((ap)->argflag&ARG_RAW?sh_fmtq((ap)->argval):(ap)->argval)109#define ARG_SPARE 1110111112/* legal argument flags */113#define ARG_RAW 0x1 /* string needs no processing */114#define ARG_MAKE 0x2 /* bit set during argument expansion */115#define ARG_COMSUB 0x2 /* command sub */116#define ARG_MAC 0x4 /* string needs macro expansion */117#define ARG_EXP 0x8 /* string needs file expansion */118#define ARG_ASSIGN 0x10 /* argument is an assignment */119#define ARG_QUOTED 0x20 /* word contained quote characters */120#define ARG_MESSAGE 0x40 /* contains international string */121#define ARG_APPEND 0x80 /* for += assignment */122/* The following can be passed as options to sh_macexpand() */123#define ARG_ARITH 0x100 /* arithmetic expansion */124#define ARG_OPTIMIZE 0x200 /* try to optimize */125#define ARG_NOGLOB 0x400 /* no file name expansion */126#define ARG_LET 0x800 /* processing let command arguments */127#define ARG_ARRAYOK 0x1000 /* $x[sub] ==> ${x[sub]} */128129extern struct dolnod *sh_argcreate(char*[]);130extern char *sh_argdolminus(void*);131extern int sh_argopts(int,char*[],void*);132133134extern const char e_heading[];135extern const char e_off[];136extern const char e_on[];137extern const char e_sptbnl[];138extern const char e_subst[];139extern const char e_option[];140extern const char e_exec[];141extern const char e_devfdNN[];142extern const char e_devfdstd[];143144#endif /* ARG_RAW */145146147