FreeCalypso > hg > sms-coding-utils
annotate libcoding/gsm7_unpack.c @ 33:a91fb88a57b2 default tip
add INSTALL document
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 14 Jun 2024 20:29:17 +0000 |
parents | 7418ca2e9949 |
children |
rev | line source |
---|---|
27
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This library module implements unpacking of GSM 7-bit data |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * from packed octets. |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 static u_char shift[8] = {0, 7, 6, 5, 4, 3, 2, 1}; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 gsm7_unpack(inbuf, outbuf, nseptets) |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 u_char *inbuf, *outbuf; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 unsigned nseptets; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 { |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 u_char *inp = inbuf, *outp = outbuf; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 unsigned n; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 for (n = 0; n < nseptets; n++) { |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 *outp++ = (((inp[1] << 8) | inp[0]) >> shift[n&7]) & 0x7F; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 if (n & 7) |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 inp++; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 } |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 } |