comparison libcoding/number_decode.c @ 27:7418ca2e9949

libcoding: add functions from freecalypso-tools/uptools/libcoding that are needed for sms-pdu-decode & pcm-sms-decode
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 13 Jun 2024 02:29:29 +0000
parents
children
comparison
equal deleted inserted replaced
26:c8cb05b69118 27:7418ca2e9949
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 *outp = '\0';
29 }