/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_vprintf.c                                       :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: gbaconni@student.42lausanne.ch             +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2022/01/20 11:43:52 by gbaconni          #+#    #+#             */
/*   Updated: 2022/04/13 01:24:00 by gbaconni         ###   lausanne.ch       */
/*                                                                            */
/* ************************************************************************** */

#include "libftprintf.h"

int	ft_vprintf(char const *format, va_list ap)
{
	int	ret;

	ret = 0;
	while (*format)
	{
		if (*format++ == '%')
		{
			if (*format == '%')
				ret += ft_vprintf_percent(format, ap);
			else if (*format == 'c')
				ret += ft_vprintf_char(format, ap);
			else if (*format == 's')
				ret += ft_vprintf_string(format, ap);
			else if (*format == 'p')
				ret += ft_vprintf_pointer(format, ap);
			else if (*format == 'd' || *format == 'i' || *format == 'u')
				ret += ft_vprintf_decimal(format, ap);
			else if (*format == 'x' || *format == 'X')
				ret += ft_vprintf_hexadecimal(format, ap);
		}
		else
			ret += ft_vprintf_other(format, ap);
		format++;
	}
	return (ret);
}
