blob: d1bb237b953c85bc09162bfd0154ec1d6dd2a6dc (
plain)
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/26 15:33:51 by cacharle #+# #+# */
/* Updated: 2020/02/28 15:30:10 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINISHELL_H
# define MINISHELL_H
# include <stdlib.h>
# include <string.h>
# include <unistd.h>
# include <fcntl.h>
# include <dirent.h>
# include <sys/wait.h>
# include <signal.h>
# include <sys/stat.h>
# include <stdbool.h>
# include "libft.h"
# include "libft_ht.h"
# include "libft_lst.h"
# include "libft_util.h"
# include "ms_parse.h"
# define MS_PATH_KEY "PATH"
# define MS_PIPE_WRITE 1
# define MS_PIPE_READ 0
typedef struct
{
t_ftht *commands;
t_ftlst *dirs;
} t_path;
typedef struct
{
t_path *path;
t_ftht *environment;
} t_state;
typedef struct
{
int pipe_in[2];
int pipe_out[2];
} t_command_frame;
/*
** state.c
*/
int ms_state_init(t_state *state, const char **envp);
void ms_state_destroy(t_state *state);
/*
** eval.c
*/
int ms_eval(t_parsing *parsing);
/*
** path.c
*/
t_path *ms_path_update(t_path *path, const char *path_str);
void ms_path_destroy(t_path *path);
/*
** environment.c
*/
t_ftht *ms_environment_from_array(const char **envp);
char **ms_environment_to_array(t_ftht *environment);
/*
** builtin*.c
*/
// typedef int (*t_builtin_func)(t_state *state);
int ms_echo(char **argv);
int ms_cd(t_state *state, char **argv);
int ms_pwd(t_state *state);
int ms_export(t_state *state, char **argv);
int ms_unset(t_state *state, char **argv);
int ms_env(t_state *state);
// int ms_exit(t_state *state);
/*
** util.c
*/
void ms_ht_del_str_entry(t_ftht_content *content);
#endif
|