示例#1
0
文件: main.c 项目: jlange91/Fillit
void	ft_main2(int fd)
{
	char		*file;
	t_map		map;
	t_tetri		*tetri;

	if (!(file = ft_getfile(fd, &map)) ||
			!(ft_check_file(file)))
		ft_putstr("error\n");
	else
	{
		tetri = ft_create_tetri(map);
		ft_fill(tetri, file, map);
		ft_init_map(&map);
		map.ret = 1;
		ft_solve(tetri, &map);
		while (map.ret == 0)
		{
			map.size++;
			ft_solve(tetri, &map);
		}
		ft_print_map(tetri, map);
		ft_free(&tetri);
	}
}
示例#2
0
文件: ft_pipe.c 项目: vikingeff/pipex
void	ft_begin(t_cmd *arg)
{
	int		childpid;
	int		fd;
	int		fd2;

	pipe(arg->fd);
	if ((childpid = fork()) == -1)
		ft_fork_error();
	if (childpid == 0)
	{
		fd = ft_check_file(arg->av[1], R_OK);
		dup2(fd, 0);
		dup2(arg->fd[1], 1);
		close(arg->fd[0]);
		ft_execute(arg);
	}
	if (childpid > 0)
	{
		fd2 = ft_check_file_exist(arg);
		dup2(fd2, 1);
		dup2(arg->fd[0], 0);
		close(arg->fd[1]);
		ft_execute_2(arg);
	}
}
示例#3
0
文件: main.c 项目: knzeng-e/fill-it
int		main(int ac, char **av)
{
	int		nb_pieces;
	t_piece	pieces[MAX_PIECES + 1];
	t_map	*map;

	if (ac == 2)
	{
		nb_pieces = ft_check_file(av[1], pieces);
		if (nb_pieces > 0)
		{
			if (!(map = (t_map *)malloc(sizeof(t_map))))
				return (ERROR_MALLOC);
			if (ft_init_map(map, 3, 'A', nb_pieces) < 0)
			{
				free(map);
				return (ERROR_MALLOC);
			}
			ft_resolve(pieces, map, nb_pieces);
		}
		else
			ft_putstr("error");
	}
	else
		ft_putstr("error");
	return (0);
}
示例#4
0
void        parse_user_input(t_state *state, char **argv, int count)
{
    int     i;
    
    i = 1;
    parse_champ_count(state, argv, count);
    parse_champ_number(state, argv, i, count);
    parse_dump(state, argv, i, count);
    check_if_champs_assigned(state, argv);
    ft_check_file(state, argv, count);
}
示例#5
0
文件: parse_obj.c 项目: alexfofo/42
int				ft_parse_obj(char *file, t_obj *tobj)
{
	tobj->nb = (int *)malloc(sizeof(int) * 6);
	ft_check_file(file);
	ft_count_obj(file, tobj);
	ft_init_type3(tobj);
	if (ft_fill_objs(file, tobj) == -1)
	{
		ft_putendl_fd("Problem at parsing", 2);
		exit(0);
	}
	return (0);
}
示例#6
0
void			son_process(char *path, char *arg[], t_dlist *line)
{
	int			test;

	if (ft_check_file(path))
	{
		test = execve(path, arg, ft_tab_from_list(line));
		if (test == -1)
		{
			ft_putstr_fd(" error on performing this operation \n", 2);
			ft_putstr(" error on performing this operation \n");
			exit(EXIT_FAILURE);
		}
	}
}
示例#7
0
文件: parse_file.c 项目: randrini/BSQ
char	*parse_file(char *file)
{
	int			fd;
	int			ret;
	static char	buf[BUFFER_SIZE];

	fd = open(file, O_RDONLY);
	if (fd == -1)
		ft_error();
	ret = read(fd, buf, BUFFER_SIZE);
	buf[ret] = '\0';
	close(fd);
	ft_check_file(buf);
	ft_check_char(buf);
	ft_check_full_o(buf);
	ft_check_grid(buf);
	return (buf);
}
示例#8
0
文件: fillit.c 项目: adpdsr/fillit
int			main(int ac, char **av)
{
	char	*buffer;
	int		cnt_tetri;
	int		***tetri;
	int		**map;

	ft_check_ac(ac);
	buffer = ft_get_file(av[1]);
	ft_check_file(buffer);
	cnt_tetri = ft_count_tetri(buffer);
	tetri = ft_split_tetri(buffer);
	map = ft_resol(tetri, cnt_tetri);
	ft_print_map(map);
	ft_free_map(map);
	map = NULL;
	ft_free_tetri(tetri, cnt_tetri);
	tetri = NULL;
	return (0);
}
示例#9
0
void		ft_save_map(int ac, char **av, t_gen *gen)
{
	int		fd;
	char	*line;
	int		i;

	i = 0;
	if (ac != 2)
		ft_error_files(ac);
	if ((fd = open(av[1], O_RDONLY)) < 0 || !ft_isfile(av[1]) || ft_isdir(av[1]))
		ft_error_pass();
	gen->filename = ft_strdup(av[1]);
	ft_check_file(gen);
	gen->map = malloc(sizeof(t_point**) * gen->y);
	gen->y = 0;
	while (get_next_line(fd, &line))
	{
		ft_save_line(line, gen);
		free(line);
		gen->y++;
	}
	close(fd);
}