comparison libutil/gsm7_pack.c @ 8:34bbb0585cab

libutil: import from previous fc-pcsc-tools version
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Mar 2021 05:42:37 +0000
parents
children
comparison
equal deleted inserted replaced
7:b25d4dfe5798 8:34bbb0585cab
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 }