FreeCalypso > hg > freecalypso-sw
view gsm-fw/lldbg/hexarg.c @ 962:f4da3071dd61
doc/High-speed-serial write-up and Linux kernel patch added
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Fri, 06 Nov 2015 21:46:05 +0000 |
parents | f5affe83ba2d |
children |
line wrap: on
line source
/* * Many commands take hex arguments. This module contains the parse_hexarg() * function, which is a wrapper around strtoul that performs some additional * checks. */ #include <sys/types.h> #include <ctype.h> #include <stdlib.h> lldbg_parse_hexarg(arg, maxdigits, valp) char *arg; int maxdigits; u_long *valp; { char *cp = arg, *bp; int len; if (cp[0] == '0' && (cp[1] == 'x' || cp[1] == 'X')) cp += 2; for (bp = cp; *cp; cp++) if (!isxdigit(*cp)) return(-1); len = cp - bp; if (len < 1 || len > maxdigits) return(-1); *valp = strtoul(arg, 0, 16); return(0); }