-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_flags.c
More file actions
48 lines (43 loc) · 1.43 KB
/
check_flags.c
File metadata and controls
48 lines (43 loc) · 1.43 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_flags.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mtacnet <mtacnet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/05/26 13:05:35 by mtacnet #+# #+# */
/* Updated: 2017/06/17 17:07:45 by mtacnet ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_ls.h"
static void parser_flags(t_flags *flags, char *argv)
{
int i;
i = 1;
while (argv[i])
{
if (ft_strchr("Ralrt", (int)argv[i]) == NULL)
ft_error(1, argv[i]);
if (argv[i] == 'R')
flags->br_flag = 1;
if (argv[i] == 'a')
flags->a_flag = 1;
if (argv[i] == 'r')
flags->r_flag = 1;
if (argv[i] == 't')
flags->t_flag = 1;
if (argv[i] == 'l')
flags->l_flag = 1;
i++;
}
}
void check_flags(t_flags *flags, char **argv)
{
int i;
i = 1;
while (argv[i] && argv[i][0] == '-')
{
parser_flags(flags, argv[i]);
i++;
}
}