-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspecifier.c
More file actions
50 lines (48 loc) · 810 Bytes
/
specifier.c
File metadata and controls
50 lines (48 loc) · 810 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "main.h"
#define BUFFER_SIZE 1024
/**
* specifier - looks for the specifier and call prototypes
* @i: member i
* @format: string from _printf
* @list: the list of arguments
* Return: length of output
*/
int specifier(int *i, const char *format, va_list list)
{
int len2 = 0, k = *i, l = 0, m = 0;
mark_t spec[] = {
{"b", p_b},
{"c", p_c},
{"d", p_d},
{"i", p_d},
{"o", p_o},
{"%", p_p},
{"r", p_r},
{"R", p_Rt},
{"s", p_s},
{"u", p_u},
{"X", p_Xu},
{"x", p_x},
{"S", p_Su},
{NULL, NULL},
};
int size = sizeof(spec) / sizeof(mark_t) - 1;
while (l < size)
{
if (*(spec[l].opointer) == format[k + 1])
{
len2 += spec[l].fpointer(list);
*i += 1;
}
else
{
m++;
}
l++;
}
if (m == size)
{
len2 += _putchar(format[k]);
}
return (len2);
}