diff options
Diffstat (limited to 'src/state.c')
| -rw-r--r-- | src/state.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/state.c b/src/state.c new file mode 100644 index 0000000..61d8d41 --- /dev/null +++ b/src/state.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* state.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/28 11:51:54 by cacharle #+# #+# */ +/* Updated: 2020/02/28 12:36:10 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int ms_state_init(t_state *state, const char **envp) +{ + if ((state->environment = ms_environment_from_array(envp)) == NULL) + return (-1); + state->path = NULL; + if ((state->path = ms_path_update(state->path, ft_htget(state->environment, MS_PATH_KEY))) == NULL) + return (-1); + return (0); +} + +void ms_state_destroy(t_state *state) +{ + if (state == NULL) + return ; + ms_path_destroy(state->path); + ft_htdestroy(state->environment, ms_ht_del_str_entry); +} |
