xref: /plan9/sys/src/cmd/rc/exec.h (revision 219b2ee8daee37f4aad58d63f21287faa8e4ffdc)
1 /*
2  * Definitions used in the interpreter
3  */
4 extern void Xappend(void), Xasync(void), Xbackq(void), Xbang(void), Xclose(void);
5 extern void Xconc(void), Xcount(void), Xdelfn(void), Xdol(void), Xqdol(void), Xdup(void);
6 extern void Xexit(void), Xfalse(void), Xfn(void), Xfor(void), Xglob(void);
7 extern void Xjump(void), Xmark(void), Xmatch(void), Xpipe(void), Xread(void);
8 extern void Xrdfn(void), Xunredir(void), Xstar(void), Xreturn(void), Xsubshell(void);
9 extern void Xtrue(void), Xword(void), Xwrite(void), Xpipefd(void), Xcase(void);
10 extern void Xlocal(void), Xunlocal(void), Xassign(void), Xsimple(void), Xpopm(void);
11 extern void Xrdcmds(void), Xwastrue(void), Xif(void), Xifnot(void), Xpipewait(void);
12 extern void Xdelhere(void), Xpopredir(void), Xsub(void), Xeflag(void), Xsettrue();
13 extern void Xerror(char*), Xperror(char*);
14 /*
15  * word lists are in correct order,
16  * i.e. word0->word1->word2->word3->0
17  */
18 struct word{
19 	char *word;
20 	word *next;
21 };
22 struct list{
23 	word *words;
24 	list *next;
25 };
26 word *newword(char *, word *), *copywords(word *, word *);
27 struct redir{
28 	char type;			/* what to do */
29 	short from, to;			/* what to do it to */
30 	struct redir *next;		/* what else to do (reverse order) */
31 };
32 #define	NSTATUS	64			/* length of status (from plan 9) */
33 /*
34  * redir types
35  */
36 #define	ROPEN	1			/* dup2(from, to); close(from); */
37 #define	RDUP	2			/* dup2(from, to); */
38 #define	RCLOSE	3			/* close(from); */
39 struct thread{
40 	union code *code;		/* code for this thread */
41 	int pc;				/* code[pc] is the next instruction */
42 	struct list *argv;		/* argument stack */
43 	struct redir *redir;		/* redirection stack */
44 	struct redir *startredir;	/* redir inheritance point */
45 	struct var *local;		/* list of local variables */
46 	char *cmdfile;			/* file name in Xrdcmd */
47 	struct io *cmdfd;		/* file descriptor for Xrdcmd */
48 	int iflast;			/* static `if not' checking */
49 	int eof;			/* is cmdfd at eof? */
50 	int iflag;			/* interactive? */
51 	int lineno;			/* linenumber */
52 	int pid;			/* process for Xpipewait to wait for */
53 	char status[NSTATUS];		/* status for Xpipewait */
54 	tree *treenodes;		/* tree nodes created by this process */
55 	thread *ret;		/* who continues when this finishes */
56 };
57 thread *runq;
58 code *codecopy(code*);
59 code *codebuf;				/* compiler output */
60 int ntrap;				/* number of outstanding traps */
61 int trap[NSIG];				/* number of outstanding traps per type */
62 struct builtin{
63 	char *name;
64 	void (*fnc)(void);
65 }Builtin[];
66 int eflagok;			/* kludge flag so that -e doesn't exit in startup */
67 void execcd(void), execwhatis(void), execeval(void), execexec(void);
68 void execexit(void), execshift(void);
69 void execwait(void), execumask(void), execdot(void), execflag(void);
70 void execfunc(var*), execcmds(io *);
71