Beispiel #1
0
void			ft_alloc_hcontrol(t_hcontrol **control)
{
	extern char		**environ;

	if ((*control = (t_hcontrol*)malloc(sizeof(t_hcontrol))) != NULL)
	{
		(*control)->head = NULL;
		(*control)->tail = NULL;
		(*control)->length = 0;
		(*control)->env = environ;
		*control = ft_add_history(*control, "\0");
	}
}
Beispiel #2
0
void	ft_create_history(char *ptr, t_history **history)
{
	int		fd;
	char	*line;
	char	*str;

	if (ptr)
	{
		str = ft_strjoin(ptr + 5, "/.42sh_history");
		free(ptr);
		fd = open(str, O_RDONLY);
		free(str);
		if (fd != -1)
		{
			while (get_next_line(fd, &line))
			{
				ft_add_history(history, line);
				ft_strdel(&line);
			}
		}
	}
}