-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
39 lines (34 loc) · 1.37 KB
/
main.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ncarvalh <ncarvalh@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/10 13:04:07 by ncarvalh #+# #+# */
/* Updated: 2023/02/22 22:17:42 by ncarvalh ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
int quit(t_game *game)
{
destroy_game(game);
exit(EXIT_SUCCESS);
}
bool is_filename_valid(char *filename)
{
size_t len;
len = ft_strlen(filename);
if (len < 4)
return (false);
return (ft_strnstr(filename + (len - 4), ".ber", 4) != NULL);
}
int main(int argc, char **argv)
{
if (argc - 1 != 1)
message(NULL, "Invalid number of parameters.\n");
if (!is_filename_valid(argv[1]))
message(NULL, "Filename must end in \".ber\".\n");
srand(time(NULL));
init_game(argv[1]);
}