strtonum(const char *numstr, long long minval, unsigned long long maxval,
strtonum(const char *numstr, long long minval, unsigned long long umaxval,
strtonum(const char *numstr, long long minval, unsigned long long maxval,    const char **errstrp){	unsigned long long ull;	char *ep;	int error;	struct errval {		const char *errstr;		int err;	} ev[4] = {		{ NULL,		0 },		{ "invalid",	EINVAL },		{ "too small",	ERANGE },		{ "too large",	ERANGE },	};	ev[0].err = errno;	errno = 0;	error = 0;	ull = 0;	if (minval > maxval || maxval < minval ||	    (minval < 0 && maxval > LLONG_MAX))		error = INVALID;	else if (maxval > LLONG_MAX ) {		ull = strtoull(numstr, &ep, 10);		if (numstr == ep || *ep != '\0')			error = INVALID;		else if ((ull == ULLONG_MAX && errno == ERANGE) || ull > maxval)			error = TOOLARGE;	} else {		long long ll = strtoll(numstr, &ep, 10);		if (numstr == ep || *ep != '\0')			error = INVALID;		else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval)			error = TOOSMALL;		else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval)			error = TOOLARGE;		ull = (unsigned long long)ll;	}	if (errstrp != NULL)		*errstrp = ev[error].errstr;	errno = ev[error].err;	if (error)		ull = 0;	return (ull);}