-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructs.h
More file actions
87 lines (76 loc) · 2.13 KB
/
structs.h
File metadata and controls
87 lines (76 loc) · 2.13 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* structs.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tafanasi <tafanasi@student.42warsaw.pl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/27 11:10:24 by tafanasi #+# #+# */
/* Updated: 2025/08/27 12:46:25 by tafanasi ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STRUCTS_H
# define STRUCTS_H
typedef struct s_shell t_shell;
typedef enum e_redirect_type
{
REDIR_NONE,
REDIR_IN,
REDIR_OUT,
REDIR_APPEND,
HEREDOC
} t_redirect_type;
typedef struct s_redirect
{
t_redirect_type type;
char *file;
int expand;
int fd;
struct s_redirect *next;
} t_redirect;
typedef struct s_cmd
{
char *name;
char **args;
t_redirect *in_redir;
t_redirect *out_redir;
struct s_cmd *next;
struct s_cmd *prev;
int pipe_read;
int in_fd;
} t_cmd;
typedef struct s_shell_input
{
t_cmd *first_cmd;
t_cmd *last_cmd;
int cmds_count;
int is_valid;
int incomplete_pipe;
char *input;
t_redirect *pending_in_redir;
t_redirect *pending_out_redir;
} t_shell_input;
// Shell
typedef int (*t_builtin_fn)(t_shell *shell, char **args);
typedef struct s_builtin
{
char *name;
t_builtin_fn fn;
} t_builtin;
typedef struct s_builtins_unified
{
t_builtin *builtins_child;
t_builtin *builtins_parent;
} t_builtins_unified;
typedef struct s_shell
{
char **history;
t_shell_input *parsed_input;
t_builtins_unified *builtins;
char **envp;
char *path;
int env_count;
int env_capacity;
int exit_code;
} t_shell;
#endif