FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/lldbg/hexarg.c @ 865:f5affe83ba2d
lldbg hack (poor girl's substitute for JTAG) implemented
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Fri, 15 May 2015 00:02:03 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
864:4fa939eada22 | 865:f5affe83ba2d |
---|---|
1 /* | |
2 * Many commands take hex arguments. This module contains the parse_hexarg() | |
3 * function, which is a wrapper around strtoul that performs some additional | |
4 * checks. | |
5 */ | |
6 | |
7 #include <sys/types.h> | |
8 #include <ctype.h> | |
9 #include <stdlib.h> | |
10 | |
11 lldbg_parse_hexarg(arg, maxdigits, valp) | |
12 char *arg; | |
13 int maxdigits; | |
14 u_long *valp; | |
15 { | |
16 char *cp = arg, *bp; | |
17 int len; | |
18 | |
19 if (cp[0] == '0' && (cp[1] == 'x' || cp[1] == 'X')) | |
20 cp += 2; | |
21 for (bp = cp; *cp; cp++) | |
22 if (!isxdigit(*cp)) | |
23 return(-1); | |
24 len = cp - bp; | |
25 if (len < 1 || len > maxdigits) | |
26 return(-1); | |
27 *valp = strtoul(arg, 0, 16); | |
28 return(0); | |
29 } |