Exemplo n.º 1
0
static char	*cmp_line(t_lst *node, char **arg, char *save)
{
	t_lst	*tmp;

	tmp = node;
	while (node)
	{
		if (ft_strccmp(node->line, *arg, '=') == 0)
		{
			save = ft_strdup(node->line);
			node->line = ft_strdup(*arg);
			return (save);
		}
		node = node->next;
	}
	node = tmp;
	save = NULL;
	if (!save)
	{
		if (check_caract(*arg, '=') == 1)
			add_elem(node, *arg);
		else if (check_caract(*arg, '=') != 1)
			deal_with_command(node, arg);
		else
			print_error_opt(*arg);
	}
	return (save);
}
Exemplo n.º 2
0
Arquivo: ft_env.c Projeto: Sconso/42SH
char		*ft_get_key(char **env, char *key)
{
	while (*env)
	{
		if (!ft_strccmp(*env, key, '='))
			return (*(env) + ft_strlen(key) + 1);
		++env;
	}
	return (NULL);
}
Exemplo n.º 3
0
Arquivo: env.c Projeto: Zethir/42sh
static int	cmp_line(char **arg, char **env_cpy)
{
	int		i;

	i = 0;
	while (env_cpy[i])
	{
		if (ft_strccmp(env_cpy[i], *arg, '=') == 0)
		{
			free(env_cpy[i]);
			env_cpy[i] = ft_strdup(*arg);
			return (1);
		}
		i++;
	}
	return (0);
}
Exemplo n.º 4
0
t_lst		*init_lst(char **env)
{
	t_lst	*node;
	t_lst	*head;

	head = NULL;
	while (*env)
	{
		node = (t_lst *)malloc(sizeof(t_lst));
		if (!node)
			return (NULL);
		node->next = NULL;
		node->line = ft_strdup(*env);
		node->name = ft_strsub(*env, 0, ft_strlen_char(*env, '='));
		if (ft_strccmp(*env, "USER="******"HOME=", 5) == 0)
			node->home = ft_strchr(*env, '/');
		push_node(node, &head);
		env++;
	}
	return (head);
}