rc.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Plan9 is defined for plan 9
  3. * V9 is defined for 9th edition
  4. * Sun is defined for sun-os
  5. * Please don't litter the code with ifdefs. The three below (and one in
  6. * getflags) should be enough.
  7. */
  8. #define Plan9
  9. #ifdef Plan9
  10. #include <u.h>
  11. #include <libc.h>
  12. #define NSIG 32
  13. #define SIGINT 2
  14. #define SIGQUIT 3
  15. #endif
  16. #ifdef V9
  17. #include <signal.h>
  18. #include <libc.h>
  19. #endif
  20. #ifdef Sun
  21. #include <signal.h>
  22. #endif
  23. #define YYMAXDEPTH 500
  24. #ifndef PAREN
  25. #include "x.tab.h"
  26. #endif
  27. typedef struct tree tree;
  28. typedef struct word word;
  29. typedef struct io io;
  30. typedef union code code;
  31. typedef struct var var;
  32. typedef struct list list;
  33. typedef struct redir redir;
  34. typedef struct thread thread;
  35. typedef struct builtin builtin;
  36. #pragma incomplete word
  37. #pragma incomplete io
  38. struct tree{
  39. int type;
  40. int rtype, fd0, fd1; /* details of REDIR PIPE DUP tokens */
  41. char *str;
  42. int quoted;
  43. int iskw;
  44. tree *child[3];
  45. tree *next;
  46. };
  47. tree *newtree(void);
  48. tree *token(char*, int), *klook(char*), *tree1(int, tree*);
  49. tree *tree2(int, tree*, tree*), *tree3(int, tree*, tree*, tree*);
  50. tree *mung1(tree*, tree*), *mung2(tree*, tree*, tree*);
  51. tree *mung3(tree*, tree*, tree*, tree*), *epimung(tree*, tree*);
  52. tree *simplemung(tree*), *heredoc(tree*);
  53. void freetree(tree*);
  54. tree *cmdtree;
  55. /*
  56. * The first word of any code vector is a reference count.
  57. * Always create a new reference to a code vector by calling codecopy(.).
  58. * Always call codefree(.) when deleting a reference.
  59. */
  60. union code{
  61. void (*f)(void);
  62. int i;
  63. char *s;
  64. };
  65. char *promptstr;
  66. int doprompt;
  67. #define NTOK 8192
  68. char tok[NTOK];
  69. #define APPEND 1
  70. #define WRITE 2
  71. #define READ 3
  72. #define HERE 4
  73. #define DUPFD 5
  74. #define CLOSE 6
  75. #define RDWR 7
  76. struct var{
  77. char *name; /* ascii name */
  78. word *val; /* value */
  79. int changed;
  80. code *fn; /* pointer to function's code vector */
  81. int fnchanged;
  82. int pc; /* pc of start of function */
  83. var *next; /* next on hash or local list */
  84. };
  85. var *vlook(char*), *gvlook(char*), *newvar(char*, var*);
  86. #define NVAR 521
  87. var *gvar[NVAR]; /* hash for globals */
  88. #define new(type) ((type *)emalloc(sizeof(type)))
  89. char *emalloc(long);
  90. void *Malloc(ulong);
  91. void efree(char*);
  92. #define NOFILE 128 /* should come from <param.h> */
  93. struct here{
  94. tree *tag;
  95. char *name;
  96. struct here *next;
  97. };
  98. int mypid;
  99. /*
  100. * Glob character escape in strings:
  101. * In a string, GLOB must be followed by *?[ or GLOB.
  102. * GLOB* matches any string
  103. * GLOB? matches any single character
  104. * GLOB[...] matches anything in the brackets
  105. * GLOBGLOB matches GLOB
  106. */
  107. #define GLOB ((char)0x01)
  108. /*
  109. * onebyte(c), twobyte(c), threebyte(c)
  110. * Is c the first character of a one- two- or three-byte utf sequence?
  111. */
  112. #define onebyte(c) ((c&0x80)==0x00)
  113. #define twobyte(c) ((c&0xe0)==0xc0)
  114. #define threebyte(c) ((c&0xf0)==0xe0)
  115. char **argp;
  116. char **args;
  117. int nerror; /* number of errors encountered during compilation */
  118. int doprompt; /* is it time for a prompt? */
  119. /*
  120. * Which fds are the reading/writing end of a pipe?
  121. * Unfortunately, this can vary from system to system.
  122. * 9th edition Unix doesn't care, the following defines
  123. * work on plan 9.
  124. */
  125. #define PRD 0
  126. #define PWR 1
  127. char Rcmain[], Fdprefix[];
  128. #define register
  129. /*
  130. * How many dot commands have we executed?
  131. * Used to ensure that -v flag doesn't print rcmain.
  132. */
  133. int ndot;
  134. char *getstatus(void);
  135. int lastc;
  136. int lastword;