comparison libutil/gsm7_pack.c @ 213:50bdc48e7487

libutil: gsm7_pack.c brought over from FC uptools
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 Mar 2021 07:40:33 +0000
parents
children
comparison
equal deleted inserted replaced
212:43b57865fdb5 213:50bdc48e7487
1 /*
2 * This library module implements the function for packing septets into octets.
3 */
4
5 #include <sys/types.h>
6
7 gsm7_pack(inbuf, outbuf, noctets)
8 u_char *inbuf, *outbuf;
9 unsigned noctets;
10 {
11 u_char *ip = inbuf, *op = outbuf;
12 unsigned n, c;
13
14 for (n = 0; n < noctets; n++) {
15 c = n % 7;
16 *op++ = ((ip[1] << 7) | ip[0]) >> c;
17 if (c == 6)
18 ip += 2;
19 else
20 ip += 1;
21 }
22 }