comparison uptools/libcoding/number_decode.c @ 331:110fffa1f001

uptools/libcoding: digit decoding implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 03 Feb 2018 22:41:20 +0000
parents
children ea41b6001848
comparison
equal deleted inserted replaced
330:d29b45c4c8db 331:110fffa1f001
1 /*
2 * This library module implements the decoding of number (address) digits.
3 */
4
5 #include <sys/types.h>
6
7 char gsm_address_digits[16] =
8 {'0','1','2','3','4','5','6','7','8','9','*','#','a','b','c','?'};
9
10 decode_address_digits(inbuf, outbuf, ndigits)
11 u_char *inbuf;
12 char *outbuf;
13 unsigned ndigits;
14 {
15 u_char *inp = inbuf;
16 char *outp = outbuf;
17 unsigned n = 0, b;
18
19 while (n < ndigits) {
20 b = *inp++;
21 *outp++ = gsm_address_digits[b & 0xF];
22 n++;
23 if (n >= ndigits)
24 break;
25 *outp++ = gsm_address_digits[b >> 4];
26 n++;
27 }
28 }