FreeCalypso > hg > sms-coding-utils
annotate libcoding/gsmtime_dec.c @ 32:829e082793d0
new README
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 14 Jun 2024 19:42:25 +0000 |
parents | 6e925aa54727 |
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 decoding of GSM timestamps. |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
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 #include <sys/types.h> |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.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 gsm_timestamp_decode(inbuf, outbuf) |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 u_char *inbuf; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 char *outbuf; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 { |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 u_char rev[7]; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 int i, d1, d2, tzsign; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 for (i = 0; i < 7; i++) { |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 d1 = inbuf[i] & 0xF; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 d2 = inbuf[i] >> 4; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 rev[i] = (d1 << 4) | d2; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 } |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 if (rev[6] & 0x80) { |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 rev[6] &= 0x7F; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 tzsign = '-'; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 } else |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 tzsign = '+'; |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 sprintf(outbuf, "%02X/%02X/%02X,%02X:%02X:%02X%c%02X", rev[0], rev[1], |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 rev[2], rev[3], rev[4], rev[5], tzsign, rev[6]); |
7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |