exec.h 3.2 KB

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