-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_validator.c
112 lines (107 loc) · 1.48 KB
/
utils_validator.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "main.h"
/**
* is_digit - Checks if the given character is a digit character
* @c: The character to check
*
* Return: 1 or 0
*/
char is_digit(char c)
{
return (c >= '0' && c <= '9' ? TRUE : FALSE);
}
/**
* is_non_custom_specifier - Checks if the given character is a non-custom
* specifier character
* @c: The character to check
*
* Return: 1 or 0
*/
char is_non_custom_specifier(char c)
{
switch (c)
{
case '%':
case 'c':
case 'd':
case 'E':
case 'e':
case 'F':
case 'f':
case 'i':
case 'n':
case 'o':
case 'p':
case 's':
case 'u':
case 'X':
case 'x':
return (TRUE);
default:
return (FALSE);
}
}
/**
* is_specifier - Checks if the given character is a
* \ specifier character
* @c: The character to check
*
* Return: 1 or 0
*/
char is_specifier(char c)
{
if (is_non_custom_specifier(c))
{
return (TRUE);
}
else
{
switch (c)
{
case 'b':
case 'R':
case 'r':
case 'S':
return (TRUE);
default:
return (FALSE);
}
}
}
/**
* is_flag - Checks if the given character is a flag character
* @c: The character to check
*
* Return: 1 or 0
*/
char is_flag(char c)
{
switch (c)
{
case '-':
case '+':
case '\'':
case ' ':
case '#':
case '0':
return (TRUE);
default:
return (FALSE);
}
}
/**
* is_length - Checks if the given character is a length character
* @c: The character to check
*
* Return: 1 or 0
*/
char is_length(char c)
{
switch (c)
{
case 'h':
case 'l':
return (TRUE);
default:
return (FALSE);
}
}