Beispiel #1
0
void			ft_free_tab(t_list **begin_list)
{
	int			size;
	char		**tab;
	int			i;

	size = ft_tab_len(begin_list);
	tab = ft_init_tab(size);
	i = 0;
	while (!ft_backtraking(begin_list, tab))
	{
		while (tab[i])
		{
			free(tab[i++]);
		}
		free(tab);
		size++;
		tab = ft_init_tab(size);
	}
	ft_print_tab(tab);
	i = 0;
	while (tab[i])
	{
		free(tab[i++]);
	}
	free(tab);
}
Beispiel #2
0
void		ft_treat_sst(t_env *env, int cs, char *rcv)
{
	char	**split;
	char	*str;
	int		timer;

	str = NULL;
	split = NULL;
	split = ft_super_split(rcv);
	if (ft_tab_len(split) == 2)
	{
		timer = ft_atoi(split[1]);
		if (timer > 0)
		{
			env->time = timer;
			str = ft_graphic_sgt(env);
			if (env->graphic != -1)
				ft_reply_in_buff(env, env->graphic, str);
			ft_memdel((void **)&str);
		}
		else
			ft_graphic_reply(env, cs, ft_graphic_sbp);
	}
	else
		ft_graphic_reply(env, cs, ft_graphic_sbp);
}
Beispiel #3
0
Datei: main.c Projekt: zhasni/FDF
int		main(int ac, char **av, char **environ)
{
	t_env	env;
	int		fd;
	int		j;

	j = 0;
	fd = 0;
	if (!environ[0])
		return (-1);
	ft_init_env(&env);
	if (ac == 2)
	{
		env.len_y = ft_tab_len(fd, &j, av[1]);
		if (env.len_y == 0 && j == 0)
			return (-1);
		env.grid = ft_mallogrid(env.grid, env.len_y, j);
		if (!env.grid)
			return (-1);
		if ((fd = open(av[1], O_RDONLY)) == -1)
			return (-1);
		env.grid = ft_writegrid(env.grid, fd, &env);
		if (close(fd) == -1)
			return (-1);
		ft_fdf(&env);
	}
	return (0);
}
Beispiel #4
0
int				completion_search_path(t_comp *comp)
{
	t_env		*env;
	t_env_list	*path;
	char		**paths;

	env = &get_shell_data()->env;
	if (!(path = ft_getenv(env->env_list, "PATH")))
		return (0);
	if (!(paths = ft_strsplit(path->value, ':')))
		return (MALLOC_FAIL);
	if (ft_tab_len(paths) > MAX_PATH_COMPONENTS)
	{
		ft_dprintf(STDERR_FILENO, "42sh: Max path components reached");
		reset_buffer(&get_shell_data()->input);
		ft_free_string_tab(&paths);
		return (1);
	}
	if ((comp->matches = open_path_dirs(comp, paths)) == NULL
			&& comp->nb_matches == -1)
	{
		ft_free_string_tab(&paths);
		return (MALLOC_FAIL);
	}
	ft_free_string_tab(&paths);
	return (0);
}