From: J?rg P. <jp...@us...> - 2001-12-15 21:22:09
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv26953 Modified Files: proc.c Log Message: patch for 'sscanf' extended Index: proc.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/proc.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** proc.c 2001/12/14 23:16:23 1.4 --- proc.c 2001/12/15 21:22:07 1.5 *************** *** 954,957 **** --- 954,1003 ---- + + /** + * simple_strtoull - convert a string to an unsigned long long + * @cp: The start of the string + * @endp: A pointer to the end of the parsed string will be placed here + * @base: The number base to use + */ + unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base) + { + unsigned long long result = 0,value; + + if (!base) { + base = 10; + if (*cp == '0') { + base = 8; + cp++; + if ((*cp == 'x') && isxdigit(cp[1])) { + cp++; + base = 16; + } + } + } + while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp) + ? toupper(*cp) : *cp)-'A'+10) < base) { + result = result*base + value; + cp++; + } + if (endp) + *endp = (char *)cp; + return result; + } + + /** + * simple_strtoll - convert a string to a signed long long + * @cp: The start of the string + * @endp: A pointer to the end of the parsed string will be placed here + * @base: The number base to use + */ + long long simple_strtoll(const char *cp,char **endp,unsigned int base) + { + if(*cp=='-') + return -simple_strtoull(cp+1,endp,base); + return simple_strtoull(cp,endp,base); + } + + static int skip_atoi(const char **s) { |