-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflags.c
52 lines (44 loc) · 1.45 KB
/
flags.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* flags.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jjacobso <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/23 18:34:24 by jjacobso #+# #+# */
/* Updated: 2019/04/04 18:32:09 by jjacobso ### ########.fr */
/* */
/* ************************************************************************** */
#include "printf.h"
int check_flag(char flags, char flag)
{
return ((flags & flag) != 0);
}
void set_flag(t_spec *spec, char c)
{
int i;
i = 0;
while (FLAGS[i] != c && i < (int)ft_strlen(FLAGS) + 1)
i++;
if (i < (int)ft_strlen(FLAGS))
spec->flags |= (int)ft_pow(2, i);
}
char char_to_flag(char c)
{
int i;
i = 0;
while (FLAGS[i] != c && i < 6)
i++;
return ((int)ft_pow(2, i));
}
int check_narg(const char *str)
{
int i;
i = 0;
while (++i < 6)
if (str[i] == '$')
return (1);
else if (!ft_isdigit(str[i]))
return (0);
return (0);
}