# HG changeset patch # User Mychaela Falconia # Date 1517702497 0 # Node ID f40530e2d48de0e85e4b1b2da7d0914c34597e66 # Parent 74d5e95ee84a1975c2c586e04ab3b557fdb6161b uptools/libcoding: GSM timestamp decoding implemented diff -r 74d5e95ee84a -r f40530e2d48d uptools/libcoding/Makefile --- a/uptools/libcoding/Makefile Sat Feb 03 23:53:20 2018 +0000 +++ b/uptools/libcoding/Makefile Sun Feb 04 00:01:37 2018 +0000 @@ -1,7 +1,8 @@ CC= gcc CFLAGS= -O2 OBJS= alpha_addr.o decode_helpers.o gsm7_decode.o gsm7_decode_tables.o \ - gsm7_unpack.o hexdecode.o number_decode.o scaddr.o ucs2_decode.o + gsm7_unpack.o gsmtime.o hexdecode.o number_decode.o scaddr.o \ + ucs2_decode.o LIB= libcoding.a all: ${LIB} diff -r 74d5e95ee84a -r f40530e2d48d uptools/libcoding/gsmtime.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/uptools/libcoding/gsmtime.c Sun Feb 04 00:01:37 2018 +0000 @@ -0,0 +1,27 @@ +/* + * This library module implements decoding of GSM timestamps. + */ + +#include +#include + +gsm_timestamp_decode(inbuf, outbuf) + u_char *inbuf; + char *outbuf; +{ + u_char rev[7]; + int i, d1, d2, tzsign; + + for (i = 0; i < 7; i++) { + d1 = inbuf[i] & 0xF; + d2 = inbuf[i] >> 4; + rev[i] = (d1 << 4) | d2; + } + if (rev[6] & 0x80) { + rev[6] &= 0x7F; + tzsign = '-'; + } else + tzsign = '+'; + sprintf(outbuf, "%02X/%02X/%02X,%02X:%02X:%02X%c%02X", rev[0], rev[1], + rev[2], rev[3], rev[4], rev[5], tzsign, rev[6]); +}