/*
** EPITECH PROJECT, 2018
** task01
** File description:
** I do task
*/
#include "lib/my_stdlib.h"

int my_strnb_i(const char **str)
{
    size_t neg;
    int result;

    neg = 0;
    result = 0;
    while (**str == '-' || **str == '+'
    || **str == '\t' || **str == ' '){
        neg = (**str == '-') ? 1 : neg;
        neg = (**str == '+') ? 0 : neg;
        (*str)++;
    }
    while (**str >= '0' && **str <= '9'){
        result = (result * 10) + **str - '0';
        (*str)++;
    }
    return (neg ? -result : result);
}

long int my_strnb_l(const char **str)
{
    long int result;
    size_t neg;

    neg = 0;
    result = 0;
    while (**str == '-' || **str == '+'
    || **str == '\t' || **str == ' '){
        neg = (**str == '-') ? 1 : neg;
        neg = (**str == '+') ? 0 : neg;
        (*str)++;
    }
    while (**str >= '0' && **str <= '9'){
        result = (result * 10) + **str - '0';
        (*str)++;
    }
    return (neg ? -result : result);
}

long long int my_strnb_ll(const char **str)
{
    long long int result;
    size_t neg;

    neg = 0;
    result = 0;
    while (**str == '-' || **str == '+'
    || **str == '\t' || **str == ' '){
        neg = (**str == '-') ? 1 : neg;
        neg = (**str == '+') ? 0 : neg;
        (*str)++;
    }
    while (**str >= '0' && **str <= '9'){
        result = (result * 10) + **str - '0';
        (*str)++;
    }
    return (neg ? -result : result);
}
