-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathminishell_info.h
185 lines (162 loc) · 3.29 KB
/
minishell_info.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell_info.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jaesjeon <jaesjeon@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/17 20:40:53 by jaesjeon #+# #+# */
/* Updated: 2022/09/23 11:17:07 by jaesjeon ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINISHELL_INFO_H
# define MINISHELL_INFO_H
# include <dirent.h>
# define A 0
# define B 1
# define F_READ 0
# define F_WRITE 1
# define CHILD_PID 0
# define BACKUP 1
# define RESTORE 2
# define EXPORT_HEAD_MSG "declare -x "
# define IDX_ONE_OR_MORE 1
# define DICT_MAX 53
# include <dirent.h>
# include <unistd.h>
typedef struct s_pipe
{
int fd[2][2];
int pipe_cnt;
int fork_cnt;
} t_pipe;
typedef struct s_pid_list
{
pid_t pid;
struct s_pid_list *next;
} t_pid_list;
typedef struct s_pipe_info
{
struct s_pipe pipe;
struct s_pid_list *pid_list;
} t_pipe_info;
typedef struct s_heredoc_info
{
int option;
char *limiter;
} t_heredoc_info;
typedef struct s_dict
{
char *name;
char *value;
struct s_dict *next;
struct s_dict *prev;
} t_dict;
typedef struct s_lx_token
{
char *token_str;
int token_type;
char interpret_symbol;
char *interpreted_str;
int pass_flag;
struct s_lx_token *prev;
struct s_lx_token *next;
} t_lx_token;
typedef struct s_file
{
int n;
DIR *dirp;
char *name;
int type;
int match_flag;
} t_file;
typedef struct s_tree
{
unsigned char type;
t_lx_token *token_data;
struct s_tree *parent_tree;
struct s_tree *left;
struct s_tree *right;
} t_tree;
typedef struct s_oflag
{
int quote;
int parentheses;
int and_if;
} t_oflag;
enum e_interpreted_type
{
UNDEFINED = 0b00000000,
QUOTE = 0b00000001,
DQUOTE = 0b00000010,
DOLLAR = 0b00000100,
WILDCARD = 0b00001000,
TILDE = 0b00010000,
NEED_TRANSLATE = 0b01000000
};
enum e_tree_type
{
TREE_UNDEFINED = 0b00000001,
TREE_AND = 0b00000010,
TREE_OR = 0b00000100,
TREE_PIPE = 0b00001000,
TREE_CMD = 0b00010000,
TREE_REDI = 0b00100000,
TREE_SIMPLE_CMD = 0b01000000,
TREE_SUBSHELL = 0b10000000,
TREE_ALL = 0b11111111
};
enum e_token_type
{
WORD = 100,
NEW_LINE,
AND_IF,
OR_IF,
PIPE,
RED_IN,
RED_OUT,
HERE_DOC,
RED_APD_OUT,
PARENTHESES_OPEN,
PARENTHESES_CLOSE,
SPACE_SET,
};
enum e_builtin_idx
{
BI_ECHO = 10,
BI_CD,
BI_PWD,
BI_EXPORT,
BI_UNSET,
BI_ENV,
BI_EXIT
};
enum e_exit_code
{
SUCCESS_EXIT_CODE = 0,
GENERAL_EXIT_CODE = 1,
PERMISSION_EXIT_CODE = 2,
INVALID_OPTION_EXIT_CODE = 2,
SIG_DEFAULT_EXIT_CODE = 128,
NONE_NUMERIC_EXIT_CODE = 255,
SYNTAX_ERROR_EXIT_CODE = 258
};
enum e_sperate
{
NOT_SPERATE,
SPERATE,
};
enum e_return
{
ERROR = -1,
FALSE,
SUCCESS,
TRUE = 1
};
enum e_order
{
LESS_THAN = -1,
EQUAL,
GREATER_THAN,
};
#endif