-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_options.c
56 lines (51 loc) · 1.03 KB
/
find_options.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
/*
** EPITECH PROJECT, 2021
** B-PSU-100-PAR-1-1-myls-axel.humeau
** File description:
** find_options
*/
#include "my_ls.h"
void invalid_option(char i_o)
{
my_puterror("my_ls: invalid option -- ");
my_puterror(&i_o);
my_puterror("\n");
exit(84);
}
void find_options_switch2(char *str, option_presence_t *options, int i)
{
switch(str[i]) {
case 'a' :
options->a = 1;
break;
default :
invalid_option(str[i]);
}
}
void find_options_switch(char *str, option_presence_t *options, int i)
{
switch (str[i]) {
case 'l' :
options->l = 1;
break;
case 'r' :
options->r = 1;
break;
case 'R' :
options->R = 1;
break;
case 'd' :
options->d = 1;
break;
case 't' :
options->t = 1;
break;
default :
find_options_switch2(str, options, i);
}
}
void find_options(char *str, option_presence_t *options)
{
for (int i = 1; str[i] != '\0'; i++)
find_options_switch(str, options, i);
}