Repository navigation
Expand file tree
/
Copy pathminishell.h
More file actions
120 lines (94 loc) · 3.82 KB
/
Copy pathminishell.h
File metadata and controls
120 lines (94 loc) · 3.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aykrifa <aykrifa@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/13 09:46:21 by aykrifa #+# #+# */
/* Updated: 2025/05/06 09:05:15 by cbordeau ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINISHELL_H
# define MINISHELL_H
# include <fcntl.h>
# include <sys/stat.h>
# include <stdlib.h>
# include <stdio.h>
# include <unistd.h>
# include <stdio.h>
# include <sys/types.h>
# include <readline/readline.h>
# include <readline/history.h>
# include <signal.h>
# include <dirent.h>
# include "libft/libft.h"
# include "minishell_struct.h"
# include "minishell_define.h"
// CONSTRUCTORS
t_cmd *execcmd(int *error);
t_cmd *redircmd(t_cmd *subcmd, t_file *file, t_open mode, int *error);
t_cmd *pipecmd(t_cmd *left, t_cmd *right, int *error);
t_cmd *linecmd(t_cmd *left, t_cmd *right, int mode, int *error);
// UTILS
int singleton(int value);
void dup_env(char *env[], char *new_env[MAXENV]);
int wait2pid(pid_t pid1, pid_t pid2, int *status);
int fork1(int *pid);
void close2(int *fd1, int *fd2);
void perror1(char *message, int *status);
int open1(char *file, int option, int access);
void free1(void **tofree);
struct dirent *readdir1(DIR *rep, struct dirent **ent);
void free_error(t_shell *shell, t_cmd *exec);
void iterate_expand_unquote(char **argv, t_shell shell);
char *expand_unquote(char *s, t_quote quote, t_shell *shell);
char *get_cmd(char *str, char **env, int *error);
void print_fd(int fd, char *first,
char *second, char *third);
int tablen(char *tab[]);
char **realloc_buffer(char **buf, int new_size);
int get_quote_info(char **s, t_quote *quote);
// EXEC
void run_tree(t_cmd *branch, t_shell *shell);
void run_pipe(t_pipe *pipe, t_shell *shell);
int here_doc(t_redir *heredoc);
int is_builtin(t_exec *exec, t_shell *shell);
void exec_cmd(t_shell *shell, t_exec *exec);
int open_mode(t_redir *redir);
void no_pipe_execution(t_exec *exec, t_shell *shell);
char **wildcard_allocation(char **argv, char **args);
int right_pattern(char *str, char *pattern);
// SIGNAL
void control_back(int signum);
void new_line(int signum);
void new_line_no_redisplay(int signum);
void set_sig_handler(void);
// PARSER
t_cmd *parsecmd(char *s, t_shell *shell);
t_cmd *parseline(t_parser *parser);
t_cmd *parsepipe(t_parser *parser);
t_cmd *parseredirs(t_cmd *cmd, t_parser *parser);
char *fill_here_doc(char *file, char *efile);
t_cmd *parseblock(t_parser *parser);
t_cmd *parseexec(t_parser *parser);
//SH
int getcmdline(char *buf, int nbuf, int status);
int peek(t_parser *parser, char *toks);
int skip_quotes(char *s, char c, int *error);
int gettoken(t_parser *parser, char **q, char **eq);
t_cmd *nulterminate(t_cmd *cmd, t_shell *shell);
t_cmd *fill_argv(t_parser *parser,
t_cmd *ret, t_exec *cmd, t_file *exec);
void *panic(int *error, int code);
void print_error(int error);
//FREE TREE
void free_tree(t_cmd *branch);
void free_pipe(t_pipe *pipe);
void free_redir(t_redir *redir);
void free_exec(t_exec *exec);
void fallargs(char *tab[], int size);
void fall(char **dest);
// ASCII_minishell -->patorjk.com
void display_ascii(void);
#endif