annotate uptools/libcoding/number_decode.c @ 485:944e26b2f314

doc/Host-tools-overview: fc-bin2rftab addition documented
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 15 Mar 2019 06:24:08 +0000
parents ea41b6001848
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
331
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This library module implements the decoding of number (address) digits.
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 char gsm_address_digits[16] =
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 {'0','1','2','3','4','5','6','7','8','9','*','#','a','b','c','?'};
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 decode_address_digits(inbuf, outbuf, ndigits)
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 u_char *inbuf;
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 char *outbuf;
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 unsigned ndigits;
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 {
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 u_char *inp = inbuf;
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char *outp = outbuf;
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 unsigned n = 0, b;
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 while (n < ndigits) {
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 b = *inp++;
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 *outp++ = gsm_address_digits[b & 0xF];
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 n++;
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 if (n >= ndigits)
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 break;
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 *outp++ = gsm_address_digits[b >> 4];
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 n++;
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 }
332
ea41b6001848 uptools/libcoding: SC address decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 331
diff changeset
28 *outp = '\0';
331
110fffa1f001 uptools/libcoding: digit decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }