kernel/src/klibc/klibc.c
long int kstrtol(char * string, char ** endptr) {
    if (!string) return 0;

    long int integer = 0;
    long int result = 0;
    bool result_found = false;
    int sign = 1;

    if (*string == '-') {
        sign = -1;
        string++;
    } else if (*string == '+') {
        string++;
    }

    while (!result_found) {
        if (*string >= '0' && *string <= '9') {
            integer *= 10;
            integer += (*string - '0');
            string++;
        } else {
            result = sign * integer;
            result_found = true;
        }
    }
    *endptr = (char *)string;

    return result;
}
// Same as katol, but makes endptr point to the string which comes after the number
Same as katol, but makes endptr point to the string which comes after the number
Same as katol but makes endptr point to the string which comes after the number
long int kstrtol(char * string, char ** endptr) {
    if (!string) return 0;
    long int integer = 0;
    long int result = 0;
    bool result_found = false;
    int sign = 1;
    if (*string == '-') {
        sign = -1;
        string++;
    } else if (*string == '+') {
        string++;
    }
    while (!result_found) {
        if (*string >= '0' && *string <= '9') {
            integer *= 10;
            integer += (*string - '0');
            string++;
        } else {
            result = sign * integer;
            result_found = true;
        }
    }
    *endptr = (char *)string;
    return result;
}
long int kstrtol ( char * string , char * * endptr ) { if ( ! string ) return 0 ; long int integer = 0 ; long int result = 0 ; bool result_found = false ; int sign = 1 ; if ( * string == ' ' ) { sign = -1 ; string ++ ; } else if ( * string == ' ' ) { string ++ ; } while ( ! result_found ) { if ( * string >= ' ' && * string <= ' ' ) { integer *= 10 ; integer += ( * string - ' ' ) ; string ++ ; } else { result = sign * integer ; result_found = true ; } } * endptr = ( char * ) string ; return result ; }
Same as katol, but makes endptr point to the string which comes after the number
Same as katol but makes endptr point to the string which comes after the number