-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparse.h
45 lines (30 loc) · 890 Bytes
/
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
#ifndef PARSE_H
#define PARSE_H
#define MAX_VAR_NUM 10
#define PIPE_MAX_NUM 10
#define free_and_null(x) free(x); (x) = NULL;
#define check_and_free(x) if ((x) != NULL) { free_and_null(x) }
typedef struct {
char *command;
char *VarList[MAX_VAR_NUM];
int VarNum;
char *inFile;
char *outFile;
int boolInfile;
int boolOutfile;
} commandType;
/* parsing information structure */
typedef struct {
// run process in background
int boolBackground;
commandType CommArray[PIPE_MAX_NUM];
int pipeNum;
} parseInfo;
/* the function prototypes */
parseInfo *parse(char *);
void free_info(parseInfo *);
int parse_command(commandType *result, char *cmd, char **res_space, int space_delims);
char **split_string(char *cmdline, int *n_delims, char *delim);
void error_check(parseInfo *info, char **res_pipe, char **res_space, int type);
parseInfo *init_info(parseInfo *info);
#endif