-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_redirect_to.c
91 lines (84 loc) · 2.37 KB
/
ft_redirect_to.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
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_redirect_to.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hmoumani <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/02 11:14:47 by hmoumani #+# #+# */
/* Updated: 2020/11/02 11:14:49 by hmoumani ### ########.fr */
/* */
/* ************************************************************************** */
#include "lib.h"
size_t ft_ptr_str_len(char **ptr)
{
size_t len;
len = 0;
while (ptr[len])
len++;
return (len);
}
char *ft_missing(void)
{
if (g_conf.win_h == -1)
return ("Resolution");
else if (g_conf.no.height == -1)
return ("North texture");
else if (g_conf.so.height == -1)
return ("South texture");
else if (g_conf.we.height == -1)
return ("West texture");
else if (g_conf.ea.height == -1)
return ("East texture");
else if (g_conf.spr.height == -1)
return ("Sprite texture");
else if (g_conf.f == -1)
return ("floor texture");
else if (g_conf.c == -1)
return ("Ceilling texture");
return ("smth");
}
int ft_is_end_with(char *s, char *s1)
{
int len;
int i;
int len1;
len = ft_strlen(s);
len1 = ft_strlen(s1);
i = 0;
while (len - i >= 0)
{
if (s[len - i] != s1[len1 - i])
return (0);
if (i == len1)
return (1);
i++;
}
return (1);
}
void ft_redirect_to(char **ptr, int count, char *line)
{
if (!ptr[0])
return ;
else if (!ft_strncmp(ptr[0], "R", 2))
ft_treat_res(ptr);
else if (!ft_strncmp(ptr[0], "NO", 3))
ft_treat_no(line);
else if (!ft_strncmp(ptr[0], "SO", 3))
ft_treat_so(line);
else if (!ft_strncmp(ptr[0], "WE", 3))
ft_treat_we(line);
else if (!ft_strncmp(ptr[0], "EA", 3))
ft_treat_ea(line);
else if (!ft_strncmp(ptr[0], "S", 2))
ft_treat_spr(line);
else if (!ft_strncmp(ptr[0], "F", 2))
ft_treat_f(ptr, count);
else if (!ft_strncmp(ptr[0], "C", 2))
ft_treat_c(ptr, count);
else
{
ft_error("map file is misconfigured");
exit(1);
}
}