FreeCalypso > hg > sms-coding-utils
comparison libcoding/gsm7_pack.c @ 0:2d0082216916
libcoding: beginning with a subset of uptools version
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sat, 05 Aug 2023 00:46:23 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:2d0082216916 |
|---|---|
| 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 } |
