#include "ft_nm.h" void ft_print_hex_digit(char c) { if (c > 9) { ft_putchar(c + 'W'); } else { ft_putchar(c + '0'); } } void ft_put_address_32(uint32_t addr) { for (char i = 7; i >= 0; i--) { ft_print_hex_digit((addr >> i * 4) & 0xF); } } void ft_put_address_64(uint64_t addr) { for (char i = 15; i >= 0; i--) { ft_print_hex_digit((addr >> i * 4) & 0xF); } } void ft_printf(const char *format, ...) { va_list ap; int argc = ft_strlen(format); va_start(ap, format); for (int i = 0; i < argc; i++) { switch (format[i]) { case 's': ft_putstr(va_arg(ap, char *)); break; case 'd': ft_putnbr(va_arg(ap, int)); break; case 'x': ft_put_address_32(va_arg(ap, uint32_t)); break; case 'X': ft_put_address_64(va_arg(ap, uint64_t)); break; case ' ': ft_putchar(' '); break; case 'p': ft_putstr(" "); break; case 'P': ft_putstr(" "); break; } } va_end(ap); }