void static ft_finalstr_b(char *ptr, t_flags *flags, char c) { char *preci; char *ret; int len; int diff; diff = ft_check_preci_b(ptr, flags, c); preci = NULL; if (diff > 0 && (preci = ft_preci_b(ptr, flags->preci))) ptr = preci; len = ft_strlen(ptr); diff = flags->field - len; if (diff > 0) ret = ft_fdif(ptr, diff, flags); else ret = ft_strdup(ptr); if (flags->p == 1 || !(flags->isnull == 1 && flags->preci == 0)) ret = ft_hexa(ret, flags, diff, c); ft_putstr_c(ret); if (ret) ft_strdel(&ret); if (preci) ft_strdel(&preci); }
int ft_form2(t_format *tmp, va_list ap) { if (tmp->type == 's') return (ft_string(tmp, ap)); else if (tmp->type == 'C' || (tmp->type == 'c' && ft_strcmp(tmp->lenght, "l") == 0)) return (ft_wint(tmp, ap)); else if (tmp->type == 'c') return (ft_char(tmp, ap)); else if (tmp->type == 'd' || tmp->type == 'i' || tmp->type == 'D') return (ft_int(tmp, ap)); else if (tmp->type == 'f' || tmp->type == 'F') return (ft_float(tmp, ap)); else if (tmp->type == 'u' || tmp->type == 'U') return (ft_unint(tmp, ap)); else if (tmp->type == 'o' || tmp->type == 'O') return (ft_octal(tmp, ap)); else if (tmp->type == 'b' || tmp->type == 'B') return (ft_binaire(tmp, ap)); else if (tmp->type == 'e' || tmp->type == 'E') return (ft_scienti(tmp, ap)); else if (tmp->type == 'x' || tmp->type == 'X') return (ft_hexa(tmp, ap)); else if (tmp->type == 'p') return (ft_adrpoint(tmp, ap)); else return (ft_char(tmp, ap)); }
static int ft_convert_base(char *str) { int *nbrs; int i; int len; int r_value; i = 0; r_value = 0; len = ft_hexalen((char *)str); nbrs = ft_nbrnew(len); while (str[i] && ft_ishexa(str[i])) { nbrs[i] = ft_hexa(str[i]) * ft_power(16, (len - 1) - i); i++; } i = 0; while (str[i] && ft_ishexa(str[i])) { r_value += nbrs[i]; i++; } return (r_value); }