-
Notifications
You must be signed in to change notification settings - Fork 1
/
parsing4.c
executable file
·66 lines (59 loc) · 1.65 KB
/
parsing4.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing4.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abenheni <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 13:56:14 by abenheni #+# #+# */
/* Updated: 2023/02/15 13:56:18 by abenheni ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
static int containe_other(char *s)
{
int i;
i = 0;
while (s[i])
{
if (s[i] != '0' && s[i] != '1' && s[i] != 'C'
&& s[i] != 'E' && s[i] != 'P' && s[i] != '\n' && s[i] != '\0')
return (1);
i++;
}
return (0);
}
void check_correct_char(char *s)
{
int i;
char *line;
i = open(s, O_RDONLY);
line = get_next_line(i);
if (line == NULL)
ft_error("error\n");
while (line)
{
if (containe_other(line))
ft_error("other character\n");
free(line);
line = get_next_line(i);
}
close(i);
}
void count_width(char *s, t_long *data)
{
int i;
int fd;
char *line;
fd = open(s, O_RDONLY);
line = get_next_line(fd);
if (line == NULL)
{
ft_error("error\n");
}
i = 0;
while (line[i] && line[i++] != '\n')
data->width++;
free(line);
close(fd);
}