/* ************************************************************************** */
/*                                                                            */
/*                                                        ::::::::            */
/*   environment_add.c                                  :+:    :+:            */
/*                                                     +:+                    */
/*   By: whaffman <whaffman@student.codam.nl>         +#+                     */
/*                                                   +#+                      */
/*   Created: 2025/02/04 16:13:33 by whaffman      #+#    #+#                 */
/*   Updated: 2025/03/03 12:00:19 by whaffman      ########   odam.nl         */
/*                                                                            */
/* ************************************************************************** */

#include "minishell.h"

void	environment_add(t_minishell *msh, char *name, char *value)
{
	t_environment	*new_environment;
	t_list			*new_node;
	t_list			**environment;

	environment = &msh->environment;
	if (name != NULL && value != NULL)
	{
		new_environment = malloc_safe(msh, sizeof(t_environment));
		new_environment->name = ft_strdup_safe(msh, name);
		new_environment->value = ft_strdup_safe(msh, value);
		new_node = ft_lstnew_safe(msh, new_environment);
		ft_lstadd_back(environment, new_node);
	}
}
