wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

getulong.c (416B)


      1 /* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
      2  * See LICENSE file for license details.
      3  */
      4 #include <string.h>
      5 #include <stuff/util.h>
      6 
      7 bool
      8 getulong(const char *s, ulong *ret) {
      9 	const char *end;
     10 	char *rend;
     11 	int base;
     12 	long sign;
     13 
     14 	if(s == nil)
     15 		return false;
     16 	end = s+strlen(s);
     17 	base = getbase(&s, &sign);
     18 	if(sign < 1)
     19 		return false;
     20 
     21 	*ret = strtoul(s, &rend, base);
     22 	return (end == rend);
     23 }