-
Notifications
You must be signed in to change notification settings - Fork 0
/
minishell.h
executable file
·283 lines (255 loc) · 7.44 KB
/
minishell.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
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zwalad <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/04 17:08:11 by zwalad #+# #+# */
/* Updated: 2022/08/25 17:56:33 by zwalad ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINISHELL_H
# define MINISHELL_H
# include <unistd.h>
# include <stdlib.h>
# include <stdlib.h>
# include <stdio.h>
# include <fcntl.h>
# include <readline/readline.h>
# include <readline/history.h>
# include <signal.h>
# include <dirent.h>
typedef enum s_token
{
APPENDD,
OUTFILEE,
}t_token;
typedef enum s_type
{
NAADA,
HERDO,
INPU
}t_types;
typedef enum s_open
{
ZERO,
INFF,
OUFF
}t_open;
typedef struct s_var
{
char *key;
char *value;
int len;
char *content;
struct s_var *next;
} t_var;
typedef struct s_glo
{
int exit;
int k;
int ffdd;
} t_glo;
typedef struct s_mini
{
char **inf;
char **ouf;
char **val;
t_token *otype;
int itype;
char **her;
int j;
int *open;
int op;
int oo;
int ii;
int hr;
int hflag;
struct s_mini *next;
} t_mini;
typedef struct t_list
{
char *line;
char *line2;
char *valo;
int error;
int errorx;
int doll;
int ext;
int wn;
int l;
int k;
int i;
t_var *var;
t_mini *m;
int on;
struct t_list *nextt;
} t_list;
typedef struct s_pipe
{
char **paths;
char *path;
char **envr;
int size;
int i;
int *pid_proc;
int *pip_fd;
int fd[2];
int save_inp_out[2];
} t_pipe;
t_glo g_glo;
void han_her(int num);
t_pipe *pi_init(t_pipe *pi, t_list *b);
void signalat(void);
void handler(int num);
void freee_more(t_mini *m);
int skip_quots(char *str, int i, char sign);
t_list *qts_help(t_list *p);
int check_piipe(t_list *p);
int pr_wnb2(char *str, char c);
int pr_wnbb(char *str, char c);
t_mini *goto_last(t_mini *m);
t_mini *addlast_node(t_mini **m, t_mini *new);
t_mini *new_node(t_list *p);
char *put_char(char *s, char c);
int skip_space(char *str, int i);
int check_cmd(char c, int i);
t_list *grep_command(t_list *p);
t_list *grep_files(t_list *p);
int single_inqts(char *line);
int double_inqts(char *line);
t_list *qts_check(t_list *p);
int struct_init(t_list *p);
t_list *grep_files(t_list *p);
t_list *grep_cmarg(t_list *p);
t_list *grep_cmddd(t_list *p);
t_list *grep_cmdqts(t_list *p);
t_list *north_face(t_list *p);
t_list *south_face(t_list *p);
t_list *north_errors(t_list *p);
t_list *south_errors(t_list *p);
t_list *grep_file(t_list *p);
int pr_strlen(char *str);
char *pr_strdup( char *s1);
t_list *pipe_pipe(t_list *p);
t_list *l_quotes(t_list *p);
int pr_counterr(char *str, char c);
int pr_isalnum(int c);
t_list *grep_dollar(t_list *p);
int pr_strncmpp(char *str1, char *str2);
int check_dollar(t_list *p, char *dollo);
t_list *parser(t_var *var, t_list *p);
t_list *dollar_init(t_list *p);
t_list *dollar_init1(t_list *p);
t_list *dollar_init2(t_list *p);
int check_ffile(char c);
int check_mfile(char c);
t_list *struct_builtins(t_list *p, t_var *var);
int *wnbb_beta(int *ij, char *str);
t_list *struct_beta(t_list *p);
t_list *dollar_help(t_list *p);
int pr_alph(int c);
int wnb_check(char *str, int *ij, char c);
t_list *erorat(char *str, t_list *p);
t_list *north_help(t_list *p, int type);
t_list *north_help2(t_list *p, int type);
t_list *north_help22(t_list *p);
t_list *south_inpu(t_list *p);
t_list *south_inpu2(t_list *p);
t_list *south_herdo(t_list *p);
t_list *south_herdo2(t_list *p);
t_list *parser_v2(t_list *p);
t_mini *sf_salaw(t_mini *tmp, t_list *p);
t_list *south_north(t_list *p);
t_list *dollar_init_h(t_list *p);
t_list *dollar_init1_h(t_list *p);
t_list *dollar_init2_h(t_list *p);
t_list *grep_dollar_h(t_list *p);
int check_dollar_h(t_list *p, char *dollo);
t_list *dollar_help_h(t_list *p);
void free_the_m(t_mini *m);
void free_the_pi(t_pipe *p);
//I'm here =============>
void cpy_env(t_var **t_env, t_var **t_exp, char **env);
void update_pwd_env_exp(t_var **env, t_var **exp);
void ft_update_old_exp(t_var **var);
void ft_update_exp(t_var **var);
//Utils export
int check_name_key(char *key);
int is_existed(t_var **list, char *key);
void write_again(t_var **list, char *key, char *value);
void search_key(t_var **list, char *key_val);
void print_exp(t_var *tmp);
void sort_env(t_var **t_exp);
void key_value_only_equal(t_var **t_env, t_var **t_exp, char *key_val);
void key_value_plus_equal_in(t_var **list, char *key_val);
int key_value_plus_equal(t_var **t_env, t_var **t_exp, \
char *key_val, int len);
//Utils Builtins
void no_need_proccess(t_pipe *pi, t_list *b, t_var **t_env, t_var **t_exp);
void ft_is_directory(char *value);
void need_new_proccess(t_var **var, t_pipe *pi, t_list *b);
//Get_Paths
char *cmdwpath(t_var **var, t_list *b);
void ft_close(t_pipe *pi);
//File ft_builtins
void builtins(t_var **t_env, t_var **t_exp, t_list *b);
int check_builtins(char *cmd);
int other_cmds(t_pipe *pi, t_list *b, t_var **t_env, t_var **t_exp);
void my_envr(t_var **t_env, t_pipe *pi);
//Her_doc
int her_doc(t_list *b, t_pipe *pi, t_var *t_env);
//Pipex
int ft_multiple_node(t_pipe *pi, t_list *b, t_var **t_env, t_var **t_exp);
void ft_one_node(t_pipe *pi, t_list *b, t_var **t_env, t_var **t_exp);
int ft_connect_proccess(t_pipe *pi);
//Redirection
int count_files(char **files);
int ft_redirection(t_var **t_env, t_pipe *pi, t_list *b);
//Builtins
void ft_echo(t_list *b);
void ft_cd(t_list *b, t_var **t_env, t_var **exp);
char *ft_pwd(void);
void ft_env(t_var **var);
void ft_exit(t_list *b);
void ft_unset(t_var **t_env, t_var **t_exp, t_list *b);
void ft_export(t_var **t_env, t_var **t_exp, t_list *b);
//Execution
void execution(t_var **t_env, t_var **t_exp, t_list *b);
//Utils libft
void ft_err(char *minishell, char *name, char *msg, int exit);
void ft_putstr_fd(char *s, int fd);
int ft_isalpha(int c);
int ft_isalphanum(int c);
char *ft_itoa(int n);
int ft_atoi(char *str);
int ft_isdigit(int c);
char **ft_split(char *s, char c);
char *ft_strchr(const char *s, int c);
char *ft_strdup(char *s1);
char *ft_strjoin(char *s1, char *s2);
size_t ft_strlen(const char *s);
int ft_len(char *s);
int ft_strcmp(const char *s1, const char *s2);
char *ft_substr(char *s, unsigned int start, size_t len);
void ft_putstr_fd(char *s, int fd);
t_var *ft_lstnew(char *content);
void ft_lstadd_back(t_var **lst, t_var *new);
void ft_lstadd_front(t_var **lst, t_var *new);
t_var *ft_lstlast(t_var *lst);
int ft_lstsize(t_mini *m);
void delete_node_in_list(t_var **list, char *key);
void the_free(char **str);
void free_the_m(t_mini *m);
int herror(char *str);
char *ft_access(char **str);
char *one_line(char *path, char *str, char *sstr);
// get Path
char *get_pathss(t_var *env, char *cmd);
void key_value(t_var **t_env, t_var **t_exp, char *key_val);
void ft_first_and_last_nodes(t_pipe *pi, t_list *b);
void ft_middle_nodes(t_pipe *pi, t_list *b);
int ft_strncmp( char *str1, char *str2, size_t n);
void free_e(t_var **var);
#endif