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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* include.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/19 13:17:32 by cacharle #+# #+# */
/* Updated: 2019/07/24 11:51:17 by samzur ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef INCLUDE_H
# define INCLUDE_H
# define TRUE 1
# define FALSE 0
# define INIT_BUF_SIZE 2
# define GROWTH_FACTOR 2
# define EMPTY 1
# define OBSTACLE 0
# define FILLED -1
typedef struct s_terrain
{
int rows;
int columns;
int **matrix;
} t_terrain;
typedef struct s_parsed_terrain
{
char empty;
char obstacle;
char filled;
t_terrain *terrain;
} t_parsed_terrain;
typedef struct s_cell
{
int y;
int x;
int value;
} t_cell;
/*
** helper.c - previously made functions
*/
char *read_file(int fildes);
char *ft_memcat(char *file, char *buf, int file_size,
int read_size);
char *realloc_buf(char *buf, int buf_size);
int ft_natoi(char *str, unsigned int n);
void ft_putchar(char c);
/*
** algo.c - solve the thing
*/
int ft_min(int nb1, int nb2, int nb3);
t_cell solve(t_terrain *terrain);
void solve_and_complete(t_terrain *terrain);
/*
** parse.c - map parsing
*/
int parse_file(char *filename, t_parsed_terrain *pterrain);
int parse_fildes(int fildes, t_parsed_terrain *pterrain);
int parse(char *file, t_parsed_terrain *pterrain);
/*
** parse_helper.c - parse.c sub functions
*/
int *set_row(char *file, t_parsed_terrain *pterrain, int y);
int set_dimensions(char *file, t_parsed_terrain *pterrain);
int parse_header(char *file, t_parsed_terrain *pterrain);
/*
** terrain.c - terrain manipulation
*/
void destroy_terrain(t_terrain *terrain);
void print_terrain(t_parsed_terrain *parsed_terrain);
int terrain_to_string(t_parsed_terrain *pterrain, char *str);
/*
** utils.c - random stuff I need to put somewhere
*/
void parse_stdin_print(void);
void parse_file_print(char *filename);
int count_lines(char *file);
int ft_line_len(char *str);
#endif
|