-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminishell.h
executable file
·117 lines (112 loc) · 3.46 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: darodrig <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/24 12:52:22 by darodrig #+# #+# */
/* Updated: 2020/07/01 09:08:39 by darodrig ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINISHELL_H
# define MINISHELL_H
# include <stdio.h>
# include <unistd.h>
# include <stdlib.h>
# include <string.h>
# include <sys/param.h>
# include <sys/mount.h>
# include "srcs/libft/libft.h"
# include <signal.h>
# include <fcntl.h>
# include <sys/errno.h>
# define POS_PATHS 3
# define STDIN 0
# define STDOUT 1
# define SIDEOUT 0
# define SIDEIN 1
typedef struct s_comm
{
char *command;
char *parstr;
char **params;
char *file_in;
int flag_file_in;
char *file_out;
int flag_file_out;
char **pipesplit;
char **redir;
struct s_comm *sub;
int pipes[2];
} t_comm;
typedef struct s_shell
{
int exit;
char *commands[7];
char *string;
char **split;
int argc;
char **argv;
char **envp;
char *path;
char *possible_paths[POS_PATHS];
char **pos_paths;
t_comm *com;
int dquotes;
int squotes;
int bar;
int pipe;
int stdi;
int stdo;
int exitvalue;
int fdin;
int fdout;
int bckin;
int bckout;
int status;
int ok;
int pid;
int pathcount;
} t_sh;
char *add_char(char b, char *str);
int ft_echo(char **args, t_sh *sh);
int ft_cd(t_sh *sh, char **args);
int ft_exit(t_sh *sh, char **args);
int ft_env(t_sh *sh, t_comm *sub);
int ft_export(t_sh *sh, t_comm *sub);
int ft_unset(t_sh *sh, t_comm *com);
int commands(const char *s, t_sh *sh);
int get_commands(t_sh *sh);
void init_function(t_sh *sh);
int ft_pwd(t_sh *sh);
int ft_parse(t_sh *sh);
char *get_var(char *var, char **env);
int parse_com(t_comm *com, int n);
int array_counter(char **arr);
void envp_dup(t_sh *sh, char **envp);
void swap_var(t_comm *com, t_sh *sh);
int set_special_chars(t_sh *sh, char c);
void free_vars(t_sh *sh);
char **add_var(t_sh *sh, char *var);
int search_str_in_arr(char *str, char **arr);
int substitute_var_in_env(t_sh *sh, char *var);
void print_array(char **arr);
void set_var(char **s, t_sh *sh);
int run_built_in(t_comm *com, t_sh *sh, int i);
void array_trim(char **arr, char *set);
void find_redirections(t_comm *com);
void redir_open(t_sh *sh, t_comm *com);
void redir_close(t_sh *sh, t_comm *com);
int init_com(t_comm *com);
char **new_params(t_comm *com, int i, int n);
int print_not_found(t_sh *sh, const char *s);
int run_comms(t_comm *com, t_sh *sh, int i);
void ft_son(t_sh *sh, t_comm *com, int len, int i);
void ft_father(t_sh *sh, t_comm *com, int len, int i);
void init_paths(t_sh *sh);
void append_toall(char **arr, char *str);
void add_str_to_arr(char **arr, char *str);
void ft_debug(const char *str, int n);
int run_ours(t_sh *sh, t_comm *com, int i);
#endif