exec.h 2.7 KB

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