-
Notifications
You must be signed in to change notification settings - Fork 0
/
flags.c
84 lines (77 loc) · 1.48 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
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
/*
** EPITECH PROJECT, 2021
** sour
** File description:
** sour
*/
#include "my.h"
#include <stdarg.h>
void flags_3(int *i, char *format, va_list arg)
{
char f = format[(*i) + 1];
if (f == '%') {
my_putchar('%');
(*i)++;
return;
} else if (f == 'S') {
my_flags_s(va_arg(arg, char *));
(*i)++;
return;
}
if (f == 'o') {
my_flags_o(arg);
(*i)++;
return;
} else if(f == 'u') {
my_flags_u(va_arg(arg, unsigned int));
(*i)++;
return;
}
}
void flags_2(int *i, char *format, va_list arg)
{
char f = format[(*i) + 1];
if (f == 'b') {
my_flags_b(arg);
(*i)++;
return;
} else if (f == 'X') {
my_flags_hexa(arg);
(*i)++;
return;
}
if (f == 'x') {
my_flags_x(arg);
(*i)++;
return;
}
flags_3(i, format, arg);
}
void flags(int *i, char *format, va_list arg)
{
char f = format[(*i) + 1];
if (f == 's') {
my_putstr(va_arg(arg, char *));
(*i)++;
return;
} else if (f == 'c') {
my_putchar(va_arg(arg, int));
(*i)++;
return;
}
if (f == 'i' || f == 'd') {
my_put_nbr(va_arg(arg, int));
(*i)++;
return;
}
flags_2(i, format, arg);
}
int c_is_fl(char *list, char flag)
{
for (int i = 0; list[i] != '\0'; i++) {
if (list[i] == flag) {
return (1);
}
}
return (0);
}