int ft_atoi_base(const char *str, int base) { int i; int sign; i = -1; sign = 1; if (base > 0 && base < 17) { if (!ft_strncmp(str, "0x", 2) || !ft_strncmp(str, "0X", 2)) i += 2; while (str[++i]) { if (ft_ishexa(str[i])) return (sign * ft_calc(str, i, base)); if (str[i] == '-' || str[i] == '+') { if (!ft_ishexa(str[i + 1])) return (0); sign = 44 - str[i]; } else if (!ft_is_space(str[i])) return (0); } } return (0); }
char *ft_itoa(int n) { int len[2]; char *str; len[0] = 0; len[1] = 0; if (n == 0 || n == -2147483648) { str = jedoismlloc(n); return (str); } n = ft_calc(n, len); if (!(str = malloc(len[0] * sizeof(char) + 1 + len[1]))) return (NULL); fln(str, len); while (n) { str[len[0] - 1 + len[1]] = n % 10 + '0'; n /= 10; len[0]--; } return (str); }
static int expose_hook(t_env *e) { ft_calc(e->data, *e); return (0); }