FreeCalypso > hg > fc-sim-tools
comparison libutil/gsm7_unpack.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 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 } |
