-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshort_modifier.c
45 lines (43 loc) · 1.14 KB
/
short_modifier.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
#include "main.h"
/**
* short_modifier_handler - Handles 'l' length modifier
* @format: A pointer to the format string
* @ap: Argument pointer
* @count: A pointer to the count of characters in buffer
* @total: The total number of characters printed
* @buffer: A pointer to the buffer storing characters to be printed
*/
void short_modifier_handler(const char *format, va_list ap, int *count,
int *total, char *buffer)
{
short short_int;
unsigned short u_short;
format++;
switch (*format)
{
case 'i':
case 'd':
short_int = (short)va_arg(ap, int);
short_int_handler(short_int, count, total, buffer);
break;
case 'u':
u_short = (unsigned short)va_arg(ap, unsigned int);
short_u_handler(u_short, count, total, buffer);
break;
case 'o':
u_short = (unsigned short)va_arg(ap, unsigned int);
short_o_handler(u_short, count, total, buffer);
break;
case 'x':
u_short = (unsigned short)va_arg(ap, unsigned int);
short_x_handler(u_short, count, total, buffer);
break;
case 'X':
u_short = (unsigned short)va_arg(ap, unsigned int);
short_upper_x_handler(u_short, count, total, buffer);
break;
default:
exit(1);
}
format++;
}