-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.c
executable file
·91 lines (73 loc) · 1.21 KB
/
utils.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
#include "main.h"
/**
* is_printable - Function
* @c: Parameter
*
* Return: 1 else 0
*/
int is_printable(char c)
{
if (c >= 32 && c < 127)
return (1);
return (0);
}
/**
* append_hexa_code - Function
* @dig: Parameter
* @buff: Parameter
* @i: Parameter
* Return: Always 3
*/
int append_hexa_code(char dig, char buff[], int i)
{
char tab_hex[] = "0123456789ABCDEF";
if (dig < 0)
dig *= -1;
buff[i++] = '\\';
buff[i++] = 'x';
buff[i++] = tab_hex[dig / 16];
buff[i] = tab_hex[dig % 16];
return (3);
}
/**
* is_digit - Function
* @c: Parameter
*
* Return: 1 else 0
*/
int is_digit(char c)
{
if (c >= '0' && c <= '9')
return (1);
return (0);
}
/**
* convert_size_number - Function
* @a: Parameter
* @sz: Parameter
*
* Return: Casted value of a
*/
long int convert_size_number(long int a, int sz)
{
if (sz == S_LONG)
return (a);
else if (sz == S_SHORT)
return ((short)a);
return ((int)a);
}
/**
* convert_size_unsgnd - Function
* @a: Parameter
* @sz: Parameter
*
* Return: Casted value of a
*/
long int convert_size_unsgnd(unsigned long int a, int sz)
{
if (sz == S_LONG)
return (a);
else if (sz == S_SHORT)
return ((unsigned short)a);
return ((unsigned int)a);
}