38 lines
1.6 kB
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* dispatch_bonus.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: mleitao <mleitao@student.42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2026/04/04 03:21:25 by mleitao #+# #+# */
9/* Updated: 2026/05/02 00:51:41 by mleitao ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "dispatcher_bonus.h"
14#include "printers_bonus.h"
15
16int dispatch(t_data *d)
17{
18 char spec;
19
20 spec = d->format.spec;
21 if (spec == 'c')
22 return (print_c(d, va_arg(d->args, int)));
23 else if (spec == 's')
24 return (print_s(d, va_arg(d->args, char *)));
25 else if (spec == '%')
26 return (print_percent(d));
27 else if (spec == 'd' || spec == 'i')
28 return (print_diu(d, (long)va_arg(d->args, int), 1));
29 else if (spec == 'u')
30 return (print_diu(d, (unsigned long)va_arg(d->args, unsigned int), 0));
31 else if (spec == 'x')
32 return (print_xx(d, va_arg(d->args, unsigned int), 0));
33 else if (spec == 'X')
34 return (print_xx(d, va_arg(d->args, unsigned int), 1));
35 else if (spec == 'p')
36 return (print_p(d, va_arg(d->args, void *)));
37 return (-1);
38}