-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminishell_data.h
More file actions
173 lines (156 loc) · 3.14 KB
/
minishell_data.h
File metadata and controls
173 lines (156 loc) · 3.14 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell_data.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ochouati <ochouati@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/11 16:47:55 by ochouati #+# #+# */
/* Updated: 2024/06/27 20:57:37 by ochouati ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINISHELL_DATA_H
# define MINISHELL_DATA_H
# define COL_RED "\033[0;91m"
# define END_COL "\033[0m"
# define EXIT_ERR ": numeric argument required\n"
# define M_IGNORE -2
# define M_FAIL -1
int g_status;
/* -- ENUMS -- */
typedef enum e_token
{
W_SPACE = ' ',
QUOTE = '\'',
DOUBLE_QUOTE = '"',
PIPELINE = '|',
REDIR_IN = '<',
REDIR_OUT = '>',
HEREDOC,
APPEND,
WORD = -1,
ENV = '$',
} t_token;
typedef enum s_status
{
GENERAL = 'G',
IN_D_QUOTE = 'D',
IN_S_QUOTE = 'S',
END = 'E'
} t_status;
/* -- ENVIRONEMNT STRUCT -- */
typedef struct s_env
{
char *key;
char *value;
struct s_env *next;
} t_env;
/* -- LEXER -- */
typedef struct s_lex
{
char *string;
int len;
t_status status;
t_token type;
struct s_lex *next;
struct s_lex *prev;
} t_lex;
typedef struct s_lex_helper
{
int in_s_quote;
int in_d_quote;
t_lex *lexer;
t_lex *lex;
} t_lex_helper;
/* -- PARSING STRUCT -- */
typedef struct s_quote
{
int nb_s_quote;
int nb_d_quote;
int in_s_quote;
int in_d_quote;
t_lex *tmp;
} t_quote;
typedef struct s_expand
{
t_lex *tmp_lex;
t_env *found;
char *key;
char *tmp;
} t_expand;
typedef struct s_lex_env
{
char *str;
char *ch;
} t_lex_env;
/* -- REDIRECTION STRUCT -- */
typedef struct s_redir
{
t_token type;
int index;
int is_last;
bool to_expand;
bool is_ambiguous;
char *file;
char *delim;
char *path;
struct s_redir *next;
struct s_redir *prev;
} t_redir;
typedef struct s_red_help
{
t_token tp;
char *file;
char *delim;
bool expand;
bool ambiguous;
int index;
int is_last;
} t_red_help;
/* -- COMMAND STRUCT -- */
typedef struct s_cmd
{
t_redir *redire;
t_env *env;
char *path;
char *cmd;
char **args;
bool is_builtin;
int red_fd[2];
struct s_cmd *next;
} t_cmd;
typedef struct s_cmd_utils
{
t_cmd *cmd;
t_redir *redir;
char **args;
char **tmp_args;
char *str;
bool is_ambiguous;
bool is_builtin;
bool heredoc_expand;
char *file;
char *delim;
t_token type;
} t_cmd_utils;
typedef struct s_exec
{
t_cmd *cmd;
int fd[2];
int count;
int fd_stdin;
int i;
int fails;
} t_exec;
/* -- GLOBAL DATA STRUCT -- */
typedef struct s_data
{
t_env *env;
t_lex *lexer;
int last_exit;
uint32_t npipes;
int *childs;
t_cmd *command;
int sigint;
} t_data;
#endif