예제 #1
0
void			ft_env(char **command, t_env *e)
{
	t_opt		opt;
	char		**tmp;
	int			i;

	ft_memset(&opt, 0, sizeof(opt));
	e->ret = 0;
	if ((opt.env = ft_tabdup(e->env)) == NULL)
		return (ft_error("malloc failed", &opt, e));
	if (!command[1])
		ft_puttab(opt.env);
	else
	{
		if ((i = check(command, &opt)) < 0)
			return (ft_error(NULL, &opt, e));
		if (command[i])
		{
			tmp = e->env;
			e->env = opt.env;
			check_and_exec(&command[i], e);
			e->env = tmp;
		}
		else
			ft_puttab(opt.env);
	}
	free_opt(&opt);
}
예제 #2
0
/*
** csh
*/
void	buil_env(int ac, char **av, char **env, int opt_end)
{
	(void)ac;
	(void)av;
	(void)opt_end;
	ft_puttab(env);
}
예제 #3
0
static void test_puttab_1(void)
{
	write(1, "\n\t1. check if array of string is null : \n", strlen("\n\t1. check if array of string is null : \n"));
	char	**array = 0;
	write(1, "\t\tarray = 0 => ft_puttab : ", strlen("\t\tarray = 0 => ft_puttab : "));
	ft_puttab(array);
}
예제 #4
0
static void	test_puttab_2(void)
{
	write(1, "\n\t2. check array of strings : \n", strlen("\n\t2. check array of strings : \n"));
	char	**array;
	array = malloc(sizeof(char*) * 4);
	array[0] = "abc";
	array[1] = "def";
	array[2] = "ghi";
	array[3] = "jkl";

	write(1, "\t\tarray = {\"abc\", \"def\", \"ghi\", \"jkl\"} => ft_puttab : ", strlen("\t\tarray = {\"abc\", \"def\", \"ghi\", \"jkl\"} => ft_puttab : "));
	ft_puttab(array);
	free(array);
}
예제 #5
0
void	tab_mult(char *str)
{
	int mult;
	int	nb;
	int result;

	mult = 1;
	nb = ft_atoi(str);
	result = 0;
	while (mult <= 9)
	{
		result = mult * nb;
		ft_puttab(mult, nb, result);
		mult ++;
	}
}
예제 #6
0
파일: env.c 프로젝트: Liliaze/Projets
int		ft_env(char ***env, char **args)
{
	int		i;
	int		i_opt;

	i = 1;
	i_opt = 0;
	while (args[i] && args[i][0] == '-')
	{
		if (!opt_env(&i, env, args))
			return (-1);
		i++;
	}
	while (args[i] && ft_strchr(args[i], '='))
	{
		if (!opt_env2(&i, env, args))
			return (-1);
		i++;
	}
	if (!args[i])
		ft_puttab(*env);
	return (i);
}
예제 #7
0
int		main(int argc, char **argv)
{
	int fd;
	int ret;
	char buf[22];
	char **tab;
	char ***tetro_tab = NULL;
	char **map;
	int i;

	argc= argc+1;
	i = 0;
	tab = (char**)malloc(sizeof(char*) * 27);
	fd = open(argv[1], O_RDONLY);
	if (fd == -1)
	{
		ft_putstr("open() error\n");
		return (0);
	}

	while (((ret = read(fd, buf, 21)) > 20) && i < 27)
	{
		buf[ret] = '\0';
		tab[i] = (char*)malloc(sizeof(char) * (ft_strlen(buf) + 1));
		tab[i] = ft_strcpy(tab[i], buf);
		if (ft_verif_tetro(tab[i]) == 0 || ft_stick_verif(tab[i]) == 0)
		{
			ft_putnbr(i);
			ft_putstr("tetromino error");
			return (0);
		}
		i++;
	}
	buf[ret] = '\0';
	tab[i] = (char*)malloc(sizeof(char) * (ft_strlen(buf) + 1));
	tab[i] = ft_strcpy(tab[i], buf);
	tab[i + 1] = NULL;
	if (ft_verif_tetro(tab[i]) == 1 && ft_stick_verif(tab[i]) == 1 && i < 27)
	{
	up_left_pieces(tab);
	ft_to_letters(tab, i);
	i++;
	tetro_tab = ft_bigger_tab(tab, i);
	// printf("\n\n\n\n");
	ft_print_grid(ft_sqrt_rounded_up(i * 4));
	map = ft_print_grid(ft_sqrt_rounded_up(i * 4));
	while (!backtracking(map, tetro_tab, 0))
	{
		ft_putstr("COUCOU JE SUIS ENTRE");
		ft_puttab(map);
		ft_putchar(10);
		map = up_map(map);
		ft_puttab(map);
	}
	printf("COUCOU JE SUIS SORTI\n");
	ft_puttab(map);
		ft_putchar(10);
	return (1);
	}
	return (0);
}