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