-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathminishell_hr.h
More file actions
349 lines (337 loc) · 9.82 KB
/
Copy pathminishell_hr.h
File metadata and controls
349 lines (337 loc) · 9.82 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell_hr.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fbouibao <fbouibao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/20 11:38:42 by ssamadi #+# #+# */
/* Updated: 2021/06/12 13:09:53 by fbouibao ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINISHELL_HR_H
# define MINISHELL_HR_H
# include <stdio.h>
# include <sys/types.h>
# include <sys/uio.h>
# include <unistd.h>
# include <string.h>
# include <stdlib.h>
# include <signal.h>
# include <dirent.h>
# include <errno.h>
# include <sys/stat.h>
# include <stdbool.h>
# include <termios.h>
# include <termcap.h>
# include "libft1/libft.h"
# define KEY_UP 183
# define KEY_DOWN 184
# define ENTER 10
# define KEY_REMOVE 127
# define CTRL_D 4
typedef struct s_history{
char *cmd;
struct s_history *preview;
struct s_history *next;
} t_history;
typedef struct s_tmp{
char *s1;
char *s2;
int i;
int j;
char *ss;
char *rstr;
int k;
char *test;
int z;
char *s;
int lenp;
char *buff;
char *fsf;
int dl;
} t_tmp;
typedef struct s_libf
{
long x;
int n;
int i;
char *str;
int i2;
int j;
char **pm;
size_t i3;
size_t x3;
size_t j3;
char *p;
} t_libftn;
typedef struct s_filerdr
{
char *name;
int type;
int error;
struct s_filerdr *next;
} t_filerdr;
typedef struct s_commands
{
char *command;
char *type;
char *path;
int pid;
int option;
char **arguments;
int multiple;
pid_t resul;
char **all;
t_filerdr *filerdr;
struct s_commands *next_p;
struct s_commands *next;
} t_commands;
typedef struct s_env
{
char **my_env;
char *save;
int start;
int i;
char *buf;
t_commands *tpp;
char *ptr;
char *check_term;
char *test;
} t_env;
typedef struct s_rdr
{
int i;
int start;
int k;
int b;
char *rdr_cmd;
char *str;
char *t;
t_filerdr *tmp;
} t_rdr;
typedef struct s_commandg
{
char *line;
int staus_code;
int ctrl_c;
char *ret;
int ctrl_quit;
char *type;
char *old_pwd;
int redir_fd_in;
int redir_fd;
int yesdup;
int pipe_err;
int option;
int termcap_mod;
} t_commandg;
typedef struct s_nor
{
int lenp;
char *nameenv;
int j;
int i;
int len;
char *s;
char *v;
int t;
int tee;
char *te;
char *buff;
char *fsf;
int o;
int h;
int b;
int c;
char *varibale;
char *ef;
int fd;
int fd_check;
char *sh;
char *n_tmp;
char *newsh;
int lenarg;
int k;
int z;
char **tprr;
int fs;
int ck;
char **com_path;
char *path;
int saved_stdout;
int saved_input;
int fd_in;
int fd_o;
char *ptr2;
int g;
int fd_l;
int read_fd;
int fd_pipe[2];
int write_fd;
int file;
int fd_input;
int fd_out;
int pipe_ch;
int start;
t_commands *tmp;
char *cmd;
char *cmd_tmp;
t_env *evp;
char *tmp33;
int ck2;
} t_norm;
t_commandg *g_all;
int err_handling(t_commands *tmp);
int err_half_command(t_commands *tmp);
void err_this_command(t_commands *tmp, int pipe);
int check_syntax_number(char *av, int i, int r);
int half_check_syn_r(int *i, char *av);
int check_pipp_sy(char *s);
void errr_r2(void);
int valid_rdr(char c);
int check_fname(int r, char *s, int *i);
int check_rdr(char *s, int i);
void parssing_shell(char *ptr, t_env *evp, char *cmds);
int our_command(t_commands *tmp, char *ptr, t_env *evp);
void ur_command_pipe(t_commands *tmp, char *ptr, char **envp);
int check_this_command(t_commands *tmp, t_env *evp, int pipe);
int valid_type(char c0, char c1, char c2);
int err_b(int b);
int nbr_argts2(char *command);
int my_strcmp(char *s1, char *s2);
int nbr_argts(t_commands *commands);
char *search_in_env2(char *variable, char **envp);
void sort_algo(t_env *evp);
int len_of_args(char **args);
char *get_env_name(char *envp);
char **copy_envp(char **envp);
int chck_sntx(char *str);
void command_cd(char *ptr, t_commands *tmp, t_env *evp);
void command_pwd(char *ptr, t_env *evp);
void command_exit(t_commands *tmp, int pipe);
void command_env(char **envp);
void command_export(t_commands *tmp, t_env *evp);
void command_unset(t_commands *tmp, t_env *evp);
void command_echo(t_commands *tmp);
void pipe_commmand_c(t_commands *tmp, char *ptr, t_env *evp);
void se_execute_command(t_commands *tmp, char *ptr, t_env *evp);
char *my_substr(char *s, int start, int end);
int skip_double_coats(char *cmds, int *i);
int skip_single_coats(char *cmds, int *i);
void free_no(t_norm *norm);
int check_syntax_rederction(char *av);
void check_syntax(t_commands *tmp, int k, char e_u);
void mini_redrection(t_commands *tmp, char *ptr, t_env *evp);
char *ft_strjoin1(char *s1, char *s2);
char **edit_envp_pwd(char *ptr, char **envp_c);
int check_if_command_is_exist(char *path_file, int exute, int pipe);
int loop_add_env(t_norm norm, char **envp, char *s);
void key_down(t_history **h_tmp, int d);
void key_remove(int d);
int half_termcap(int d);
int key_up(t_history **history, int d, t_history **h_tmp, int a);
int key_enter(int d, t_history **history, t_history **h_tmp);
char *ft_strjoinchar(char *s, char c);
int half_join_char(char *s, char c, char **str);
char *loop_termcap(t_history **history, t_history **h_tmp,
int tm, int a);
char *termcap_khedma(t_history *history);
void write_key_up(t_history **h_tmp);
void free_n_enter(void);
int spcle_chr(char c);
char *ft_strjoinchar(char *s, char c);
int get_char(void);
int ft_putc(int s);
char *termcap_khedma(t_history *history);
int half_check_fn(int *i, int *b, char *s);
int half_check_name(char *s, int *i, int *b);
t_history *new_commnd(char *cmd);
t_filerdr *last_name_func(t_commands *tmp);
int half_loop(char *av, int i, int v, int r);
int half_r4(int *i, char *av);
int half_syn_r3(char *av, int *i, int r);
int half_check_syn_r2(int *i, char *av);
void command_c(int signum);
int output_ret(t_commands *tmp);
int input_ret(t_commands *tmp);
int check_two_red(t_commands *tmp);
int is_equl(int i, char **envp);
int count_arg_2(t_commands *tmp);
void ft_putchar(char *str);
void command_in_the_sys(t_commands *tmp, char **envp);
void error_execve(t_commands *tmp);
char **edit_evp_new_oldpwd(char *ptr, char **envp_c);
char **edit_envp_shlvl(char **envp_c);
void print_error_check_commd(t_commands *tmp, int pipe);
char **edit_envp_old_pwd(char **envp_c);
char **edit_envp_v(char **envp_c);
void ok_write(char **my_env, int i, int j);
void add_double_quotes(char **my_env);
int check_syntax_export_true(t_commands *tmp, int k);
int check_syntax_export_false(t_commands *tmp, int k);
int ft_isdigit2(char number);
void add_in_env(t_commands *tmp, int k, char **envp);
int our_command(t_commands *tmp, char *ptr, t_env *evp);
void mini_redrection(t_commands *tmp, char *ptr, t_env *evp);
void cntrol_quit(int quit);
int syntax_true(t_commands *tmp, char **envp, int k);
void add_in_exp(t_commands *tmp, int k, char **my_env);
int check_file_or_dit(char *path_file);
int check_permissions(char *path_file, struct stat stats, int exute);
int check_file_or_dit(char *path_file);
void command_unset(t_commands *tmp, t_env *evp);
t_norm *new_norm(char **envp_c);
char **set_norm(t_norm *norm, char *ptr, char **envp_c);
int half_check_c_2(t_commands *tmp, t_norm norm, int pipe);
void free_cmds(char **cmd);
int half_check_commad(t_commands *tmp, char *path, int pipe);
t_filerdr *last_name_func(t_commands *tmp);
void half_rid_zerot_commands(t_filerdr *lastnamef, t_norm *norm);
void half_pip_rid_one(t_norm *norm, t_filerdr *lastnamef);
void normal_pipe(t_norm *norm);
void reset(t_norm *norm, char *ptr);
void parent(t_norm *norm, t_commands *tmp);
int half_else_exu(t_commands *tmp, t_env *evp);
void pip_rid_one(t_commands *tmp, t_filerdr *lastnamef,
t_norm *norm);
void start_pipe(t_norm *norm);
int get_commands(t_env *evp,
t_commands **commands, char *cmds);
t_commands *new_commands(void);
char *deletespace(char *str);
int split_pipe(t_env *evp, t_commands *commands);
t_commands *norm_commands1(char *cmds, t_env *evp,
t_commands *commands, int i);
void trait_command(t_env *envp, t_commands *commands);
void split_command_rdr(t_env *envp,
t_commands *commands, int nbr_args);
char *deleterdr(char *command);
void add_null(t_commands *cmd, int nbr);
int check_echo_n(char *s);
int files_rdr(t_env *envp, t_commands *commands);
t_filerdr *new_files_rdr(void);
int get_type_rdr(char *command, int i);
char *get_rdr_file(char *command, int i);
int skip_filename(char *cmds, int *i);
char *deleterdr(char *command);
char *deletecoats(char *str);
char *getdblcoat(char *rstr, char *str, t_tmp *tmp);
char *getsglcoat(char *rstr, char *str, t_tmp *tmp);
char *add_vrbs(char **envp, char *str, t_tmp *tmp, char *typ);
char *my_substr2(char *s, int start, int end);
int syntax(char ch, int i);
char *search_in_env(char *variable, char **envp);
int len_many(int lenarg, t_commands *tmp, int i);
void free_all(void);
void err_number(t_commands *tmp);
int check_number(t_commands *tmp, int i);
int check_cmd(char *cmnd);
t_tmp *new_tmp_search(char **envp);
char *convert_vrbs(char *cmds, t_env *evp);
void old_pwd(t_env *evp);
t_rdr *newcmd_rdr(void);
void get_last_cmd(t_history **history, t_history **h_tmp);
void get_last_cmd2(t_history **h_tmp);
void key_down_cnt(void);
#endif