-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspec.c
More file actions
33 lines (32 loc) · 831 Bytes
/
spec.c
File metadata and controls
33 lines (32 loc) · 831 Bytes
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
#include "holberton.h"
/**
* print_spec - list of normal specifiers
* @x_ptr: to maintain index position of format
* @count: to keep counting
* @format: input string
* @list: argument list
* Return: count
*/
int print_spec(int *x_ptr, int count, const char *format, va_list list)
{
int i = 0, signal = 0;
spec_t specs[] = {
{'c', print_char}, {'s', print_string}, {'d', print_di}, {'i', print_di},
{'r', print_rev}, {'b', p_binary}, {'u', print_u}, {'o', print_o},
{'X', print_X}, {'x', print_x}, {'p', print_p}, {'S', print_S},
{'R', print_rot13}, {'\0', NULL}
};
for (; specs[i].letter; i++)
{
if (specs[i].letter == format[*(x_ptr) + 1])
{
count = specs[i].f(count, list);
*(x_ptr) += 1, signal = 1;
}
}
if (signal == 0)
{
count = print_percent(count, format, x_ptr);
}
return (count);
}