wmii/lib/libstuff/util/getulong.c

24 lines
416 B
C
Raw Normal View History

2010-05-22 06:52:47 +04:00
/* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
* See LICENSE file for license details.
*/
#include <string.h>
#include <stuff/util.h>
bool
getulong(const char *s, ulong *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 < 1)
return false;
*ret = strtoul(s, &rend, base);
return (end == rend);
}