annotate gen-pdu/auto_scts.c @ 10:17dd30989c0b

sms-gen-tpdu: fix bug in GSM7 data source
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 05 Aug 2023 07:47:22 +0000
parents 003660a57f99
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements automatic generation of SC-Timestamp
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * based on the current time.
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <time.h>
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 extern u_char scts_buf[7];
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 extern int scts_is_set;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 void
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 set_auto_scts()
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 {
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 time_t unixtime;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 struct tm *tm;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 char timestr[32];
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 time(&unixtime);
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 tm = localtime(&unixtime);
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 sprintf(timestr, "%02d/%02d/%02d,%02d:%02d:%02d%+03d",
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday,
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_gmtoff / (15*60));
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 encode_gsm_sms_abstime(timestr, scts_buf);
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 scts_is_set = 1;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 }