comparison libutil/gsm7_unpack.c @ 157:f064dbcc5f41

libutil split from libcommon
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 26 Feb 2021 20:19:58 +0000
parents libcommon/gsm7_unpack.c@dc8a2e6fa03e
children
comparison
equal deleted inserted replaced
156:5f1f3f6fd865 157:f064dbcc5f41
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 }