I'd write something like this:
long long parseLongSomehow(char *s) {
if (isspace(s[0])) {
return parseLongSomehow(s + 1);
} else if (s[0] == '-') {
return -parseLongSomehow(s + 1);
} else if (s[0] == '0' && s[1] == 'x') {
return strtoull(s + 2, 16);
} else {
return strtoull(s, 10);
}
}
That doesn't handle negative values smaller than LONG_LONG_MIN gracefully, though. Also doesn't do error handling.