exec.h 2.7 KB

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