1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| typedef struct s_quares
{
int coor_x;
int coor_y;
int size;
struct s_quares *next;
} t_squares;
typedef struct s_file
{
int fd;
int nb_lines;
int width_lines;
int buffer_width;
int buffer_position;
char buffer[BUFFER_SIZE];
char **tab;
t_squares *begin;
}
void create_wordtab(t_file *f)
{
int x;
int y;
x = 0;
y = 0;
f->tab = malloc(sizeof(*(f->tab)) * (f->nb_lines + 1)); /* ERROR ! */
if (f->tab == NULL)
{
my_putstr(MALLOC_ERROR);
exit(EXIT_FAILURE);
}
f->tab[f->nb_lines] = NULL;
/* ... */
}
void init_wordtab(t_file *f, char *path)
{
f->fd = open(path, O_RDONLY);
if (f->fd <= 0)
{
my_putstr(OPEN_ERROR);
exit(EXIT_FAILURE);
}
create_wordtab(f);
close(f->fd);
print_wordtab(f->tab);
}
void do_prog(char *path)
{
t_file *f;
f = init_f();
if (f == NULL)
{
my_putstr(MALLOC_ERROR);
DEBUG_INFO;
exit(EXIT_FAILURE);
}
get_dimensions(f, path);
init_wordtab(f, path);
} |