mirror of
https://github.com/0intro/wmii
synced 2024-11-29 09:03:25 +03:00
24 lines
421 B
C
24 lines
421 B
C
/* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
|
|
* See LICENSE file for license details.
|
|
*/
|
|
#include <string.h>
|
|
#include <stuff/util.h>
|
|
|
|
bool
|
|
getlong(const char *s, long *ret) {
|
|
const char *end;
|
|
char *rend;
|
|
int base;
|
|
long sign;
|
|
|
|
if(s == nil)
|
|
return false;
|
|
end = s+strlen(s);
|
|
base = getbase(&s, &sign);
|
|
if(sign == 0)
|
|
return false;
|
|
|
|
*ret = sign * strtol(s, &rend, base);
|
|
return (end == rend);
|
|
}
|