minishell/src/environment/environment_parse.c
2025-02-11 17:22:11 +01:00

31 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* :::::::: */
/* environment_parse.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/02/05 15:52:33 by whaffman #+# #+# */
/* Updated: 2025/02/11 17:18:43 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
#include "minishell.h"
int environment_parse(char **envp, t_list **environment)
{
char **env;
*environment = NULL;
if (envp == NULL)
return (FAILURE);
while (*envp != NULL)
{
env = ft_split(*envp, '=');
environment_add(environment, env[0], env[1]);
ft_free_arr(env);
envp++;
}
return (SUCCESS);
}