rc.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. struct var{
  76. char *name; /* ascii name */
  77. word *val; /* value */
  78. int changed;
  79. code *fn; /* pointer to function's code vector */
  80. int fnchanged;
  81. int pc; /* pc of start of function */
  82. var *next; /* next on hash or local list */
  83. };
  84. var *vlook(char*), *gvlook(char*), *newvar(char*, var*);
  85. #define NVAR 521
  86. var *gvar[NVAR]; /* hash for globals */
  87. #define new(type) ((type *)emalloc(sizeof(type)))
  88. char *emalloc(long);
  89. void *Malloc(ulong);
  90. void efree(char*);
  91. #define NOFILE 128 /* should come from <param.h> */
  92. struct here{
  93. tree *tag;
  94. char *name;
  95. struct here *next;
  96. };
  97. int mypid;
  98. /*
  99. * Glob character escape in strings:
  100. * In a string, GLOB must be followed by *?[ or GLOB.
  101. * GLOB* matches any string
  102. * GLOB? matches any single character
  103. * GLOB[...] matches anything in the brackets
  104. * GLOBGLOB matches GLOB
  105. */
  106. #define GLOB ((char)0x01)
  107. /*
  108. * onebyte(c), twobyte(c), threebyte(c)
  109. * Is c the first character of a one- two- or three-byte utf sequence?
  110. */
  111. #define onebyte(c) ((c&0x80)==0x00)
  112. #define twobyte(c) ((c&0xe0)==0xc0)
  113. #define threebyte(c) ((c&0xf0)==0xe0)
  114. char **argp;
  115. char **args;
  116. int nerror; /* number of errors encountered during compilation */
  117. int doprompt; /* is it time for a prompt? */
  118. /*
  119. * Which fds are the reading/writing end of a pipe?
  120. * Unfortunately, this can vary from system to system.
  121. * 9th edition Unix doesn't care, the following defines
  122. * work on plan 9.
  123. */
  124. #define PRD 0
  125. #define PWR 1
  126. char Rcmain[], Fdprefix[];
  127. #define register
  128. /*
  129. * How many dot commands have we executed?
  130. * Used to ensure that -v flag doesn't print rcmain.
  131. */
  132. int ndot;
  133. char *getstatus(void);
  134. int lastc;
  135. int lastword;