]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/rc/rc.h
audiohda: fix syntax error
[plan9front.git] / sys / src / cmd / rc / rc.h
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
37 #pragma incomplete word
38 #pragma incomplete io
39
40 struct tree{
41         int     type;
42         int     rtype, fd0, fd1;        /* details of REDIR PIPE DUP tokens */
43         char    *str;
44         int     quoted;
45         int     iskw;
46         int     line;
47         tree    *child[3];
48         tree    *next;
49 };
50 tree *newtree(void);
51 tree *token(char*, int), *klook(char*), *tree1(int, tree*);
52 tree *tree2(int, tree*, tree*), *tree3(int, tree*, tree*, tree*);
53 tree *mung1(tree*, tree*), *mung2(tree*, tree*, tree*);
54 tree *mung3(tree*, tree*, tree*, tree*), *epimung(tree*, tree*);
55 tree *simplemung(tree*), *heredoc(tree*);
56 void freetree(tree*);
57 tree *cmdtree;
58
59 /*
60  * The first word of any code vector is a reference count.
61  * Always create a new reference to a code vector by calling codecopy(.).
62  * Always call codefree(.) when deleting a reference.
63  */
64 union code{
65         void    (*f)(void);
66         int     i;
67         char    *s;
68 };
69
70 int newwdir;
71 char *promptstr;
72 int doprompt;
73
74 #define NTOK    8192
75
76 char tok[NTOK];
77
78 #define APPEND  1
79 #define WRITE   2
80 #define READ    3
81 #define HERE    4
82 #define DUPFD   5
83 #define CLOSE   6
84 #define RDWR    7
85
86 struct var{
87         char    *name;          /* ascii name */
88         word    *val;           /* value */
89         int     changed;
90         code    *fn;            /* pointer to function's code vector */
91         int     fnchanged;
92         int     pc;             /* pc of start of function */
93         var     *next;          /* next on hash or local list */
94 };
95 var *vlook(char*), *gvlook(char*), *newvar(char*, var*);
96
97 #define NVAR    521
98
99 var *gvar[NVAR];                                /* hash for globals */
100
101 #define new(type)       ((type *)emalloc(sizeof(type)))
102
103 void *emalloc(long);
104 void *erealloc(void *, long);
105 char *estrdup(char*);
106
107 #define NOFILE  128             /* should come from <param.h> */
108
109 struct here{
110         tree    *tag;
111         char    *name;
112         struct here *next;
113 };
114 int mypid;
115
116 /*
117  * Glob character escape in strings:
118  *      In a string, GLOB must be followed by *?[ or GLOB.
119  *      GLOB* matches any string
120  *      GLOB? matches any single character
121  *      GLOB[...] matches anything in the brackets
122  *      GLOBGLOB matches GLOB
123  */
124 #define GLOB    ((char)0x01)
125 /*
126  * onebyte(c)
127  * Is c the first character of a one-byte utf sequence?
128  */
129 #define onebyte(c)      ((c&0x80)==0x00)
130
131 extern char **argp;
132 extern char **args;
133 extern int nerror;              /* number of errors encountered during compilation */
134 extern int doprompt;            /* is it time for a prompt? */
135
136 /*
137  * Which fds are the reading/writing end of a pipe?
138  * Unfortunately, this can vary from system to system.
139  * 9th edition Unix doesn't care, the following defines
140  * work on plan 9.
141  */
142 #define PRD     0
143 #define PWR     1
144 char Rcmain[], Fdprefix[];
145 /*
146  * How many dot commands have we executed?
147  * Used to ensure that -v flag doesn't print rcmain.
148  */
149 extern int ndot;
150 extern int lastc;
151 extern int lastword;
152 char *getstatus(void);