comparison libcoding/gsm7_unpack.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 unpacking of GSM 7-bit data
3 * from packed octets.
4 */
5
6 #include <sys/types.h>
7
8 static u_char shift[8] = {0, 7, 6, 5, 4, 3, 2, 1};
9
10 gsm7_unpack(inbuf, outbuf, nseptets)
11 u_char *inbuf, *outbuf;
12 unsigned nseptets;
13 {
14 u_char *inp = inbuf, *outp = outbuf;
15 unsigned n;
16
17 for (n = 0; n < nseptets; n++) {
18 *outp++ = (((inp[1] << 8) | inp[0]) >> shift[n&7]) & 0x7F;
19 if (n & 7)
20 inp++;
21 }
22 }