static int hexa_min(t_struct data, unsigned int nb, int i, int lower) { int j; int ret; ret = 0; j = i; if (data.flag & 1 && data.min != 0 && data.flag & 2) { if (data.flag & 0b00000001 && nb != 0) ret += pf_putstr(lower == 1 ? "0x" : "0X"); while (ret < data.min - (data.prec < j ? 0 : data.prec)) ret += pf_putchar(data.flag & 0b00000010 ? '0' : ' '); } else { while (ret < data.min - (data.prec < j ? j : data.prec)) ret += pf_putchar(data.flag & 0b00000010 ? '0' : ' '); if (data.flag & 0b00000001 && nb != 0) ret += pf_putstr(lower == 1 ? "0x" : "0X"); } ret += put_prec_nb(data.prec - j); if (data.prec != -1) pf_puthexa_noflag(nb, lower); return (ret); }
static int hexa_prec(t_struct data, unsigned int nb, int i, int lower) { int ret; ret = 0; ret += put_prec_nb(data.prec - i); if (data.flag & 0b00000001) ret += pf_putstr(lower == 1 ? "0x" : "0X"); if (data.prec != -1) pf_puthexa_noflag(nb, lower); return (ret); }
static int hexa_hash(t_struct data, unsigned int nb, int i, int lower) { int j; int ret; ret = 0; j = i; if (data.flag & 0b00000001 && nb != 0) ret += pf_putstr(lower == 1 ? "0x" : "0X"); ret += put_prec_nb(data.prec - j); if (data.prec != -1) pf_puthexa_noflag(nb, lower); while (ret < data.min + (data.flag & 1 ? 2 : 0) - j) ret += pf_putchar(' '); return (ret); }
int pf_rethexa_noclong(unsigned int nbr, int lower) { int i; unsigned int nbr2; nbr2 = nbr; i = 0; while (nbr2 >= 16) { nbr2 /= 16; i++; } if (lower != 2) pf_puthexa_noflag(nbr, lower); return (i + 1); }
void pf_puthexa_noflag(unsigned int nbr, int lower) { char c; c = lower == 1 ? 'a' : 'A'; if (nbr >= 16) { pf_puthexa_noflag(nbr / 16, lower); if (nbr % 16 > 9) ft_putchar((nbr % 16 - 10) + c); else ft_putchar((nbr % 16) + '0'); } else { if (nbr % 16 > 9) ft_putchar((nbr % 16 - 10) + c); else ft_putchar((nbr % 16) + '0'); } }