FreeCalypso > hg > freecalypso-tools
view uptools/libcoding/hexdecode.c @ 561:392525355ee7
loadtools/scripts: gtm900.config renamed to gen4.config
It turns out that a GTM900 variant exists with 8 MiB flash, thus -h gen8
needs to be used for GTM900 modules as the general case, and the old
-h gtm900 config is best renamed to -h gen4, although not currently official
for any actual target.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 30 Jan 2020 07:10:20 +0000 |
parents | 18c692984549 |
children |
line wrap: on
line source
/* * This library module implements decoding of long hex strings, * such as SMS PDUs. */ #include <sys/types.h> #include <ctype.h> decode_hex_line(inbuf, outbuf, outmax) char *inbuf; u_char *outbuf; unsigned outmax; { char *inp = inbuf; u_char *outp = outbuf; unsigned outcnt = 0; int c, d[2], i; while (*inp) { if (!isxdigit(inp[0]) || !isxdigit(inp[1])) return(-1); if (outcnt >= outmax) break; for (i = 0; i < 2; i++) { c = *inp++; if (isdigit(c)) d[i] = c - '0'; else if (isupper(c)) d[i] = c - 'A' + 10; else d[i] = c - 'a' + 10; } *outp++ = (d[0] << 4) | d[1]; outcnt++; } return outcnt; }