Exemplo n.º 1
0
t_piece	*ft_read(char *file, int *s, int caca)
{
	int		ret;
	int		fd;
	char	buff[BUFF_SIZE + 1];
	int		z;
	t_piece	*tetriminos;

	z = 0;
	tetriminos = malloc(sizeof(tetriminos) * 25);
	ft_bzero(buff, sizeof(buff));
	fd = ft_open_file(file);
	while ((ret = read(fd, buff, BUFF_SIZE)))
	{
		z >= 26 ? ft_error() : 0;
		ft_put_piece(buff, &tetriminos[z]);
		caca = ret;
		tetriminos[z].name = 'A' + z;
		ft_strclr(buff);
		z++;
	}
	caca == 21 ? ft_error() : 0;
	!tetriminos[0].piece[0][0] ? ft_error() : 0;
	*s = z;
	close(fd);
	ft_check_struct(tetriminos, z);
	return (tetriminos);
}
Exemplo n.º 2
0
Arquivo: ft_fdf.c Projeto: hqro/Fdf
int			ft_start(int argc, char **argv, char **str, int *ver)
{
	if (argc != 2)
	{
		ft_putstr("usage: ./fdf file1\n");
		return (0);
	}
	if ((ver[0] = open(argv[1], O_RDONLY)) == -1)
	{
		perror(argv[1]);
		return (0);
	}
	if ((ver[1] = ft_open_file(ver[0], str)) == -1)
	{
		perror(argv[1]);
		return (0);
	}
	return (1);
}
Exemplo n.º 3
0
void    scan(char *file_name)
{
	t_file  file;
	t_list_content *t;
	t_list_reason *r;

	t = malloc(sizeof(t_list_content));
	r = malloc(sizeof(t_list_reason));
	file.name = file_name;
	init_lists(t, r);
	get_extension(&file, r);
	if (file.is_valid)
	{
		if (ft_open_file(&file, t))
		{
			ft_print_name(file.name);
			scan_file_type(&file, t, r, file.extension);
		}
	}
	view_reason_list(&file, r);
	clear_reason_list(r);
}