-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.h
48 lines (41 loc) · 1.29 KB
/
parse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/******************************************************************************
*
* File Name........: parse.h
*
* Description......: header file for the ash shell parser.
*
* Author...........: Vincent W. Freeh
*
*****************************************************************************/
#ifndef PARSE_H
#define PARSE_H
/* list of all tokens */
typedef enum {Terror, Tword, Tamp, Tpipe, Tsemi, Tin, Tout,
Tapp, TpipeErr, ToutErr, TappErr, Tnl, Tnil, Tend} Token;
/* cmd data structure
* linked list, one cmd_T for each cmd in a pipe
*/
struct cmd_t {
Token exec; /* whether background or foreground */
Token in, out; /* determines where input/output comes/goes*/
char *infile, *outfile; /* set if file redirection */
int nargs, maxargs; /* num args in args array below (and size) */
char **args; /* argv array -- suitable for execv(1) */
struct cmd_t *next;
};
typedef struct cmd_t *Cmd;
/* pipe type -- either: | or |& */
typedef enum {Pout, PoutErr} Ptype;
/* pipe data structure
* linked list, one pipe_t for each pipe on a line.
*/
struct pipe_t {
Ptype type;
Cmd head;
struct pipe_t *next;
};
typedef struct pipe_t *Pipe;
void freePipe(Pipe);
Pipe parse();
#endif /* PARSE_H */
/*........................ end of parse.h ...................................*/