-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_tab_utils.c
More file actions
92 lines (82 loc) · 1.88 KB
/
Copy pathinit_tab_utils.c
File metadata and controls
92 lines (82 loc) · 1.88 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* init_tab_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kamanfo <kamanfo@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/21 14:30:30 by kamanfo #+# #+# */
/* Updated: 2021/12/28 20:34:27 by kamanfo ### ########.fr */
/* */
/* ************************************************************************** */
#include "init_tab.h"
t_map *creat_lmap_elem(char *line, size_t len)
{
t_map *tmp;
tmp = (t_map *)malloc(sizeof(t_map));
if (!tmp)
return (NULL);
tmp->line = line;
tmp->len = len;
tmp->next = NULL;
return (tmp);
}
int push_last_elem(t_map **lmap, char *line, size_t len)
{
t_map *tmp;
t_map *elem;
tmp = NULL;
if (!lmap)
return (0);
elem = creat_lmap_elem(line, len);
if (!(*lmap))
*lmap = elem;
else
{
tmp = *lmap;
while (tmp->next)
tmp = tmp->next;
tmp->next = elem;
}
return (1);
}
int lst_len(t_map *lmap)
{
t_map *tmp;
int i;
if (!lmap)
return (0);
tmp = lmap;
i = 0;
while (tmp)
{
i++;
tmp = tmp->next;
}
return (i);
}
int is_mapset(char c)
{
if (c == '0' || c == '1' || c == 'C' || c == 'M'
|| c == 'E' || c == 'P' || c == 'F')
return (1);
return (0);
}
int verif_map(char **map)
{
int i;
int j;
i = 0;
while (map[i])
{
j = 0;
while (map[i][j] != '\n' && map[i][j])
{
if (!is_mapset(map[i][j]))
return (0);
j++;
}
i++;
}
return (1);
}