comparison smpp-trx-sa/enq_link_stat.c @ 263:1bf989f60aa3

smpp-trx-sa: log times of enquire_link packets
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 11 Oct 2023 21:22:32 -0800
parents
children
comparison
equal deleted inserted replaced
262:f1c024b2b835 263:1bf989f60aa3
1 /*
2 * This module tracks and logs the times of enquire_link packets
3 * from the SMPP server.
4 */
5
6 #include <sys/types.h>
7 #include <sys/file.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <strings.h>
12 #include <time.h>
13 #include <unistd.h>
14
15 extern char fmt_time[32];
16
17 static int status_fd, status_enable;
18 static char last_enq_time[32];
19
20 void
21 log_enquire_link_open(filename)
22 char *filename;
23 {
24 status_fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666);
25 if (status_fd < 0) {
26 perror(filename);
27 exit(1);
28 }
29 status_enable = 1;
30 }
31
32 static void
33 write_enq_link_times()
34 {
35 char buf[128];
36
37 sprintf(buf, "%s\n%s\n", last_enq_time, fmt_time);
38 lseek(status_fd, 0, SEEK_SET);
39 write(status_fd, buf, strlen(buf));
40 }
41
42 void
43 log_enquire_link_item()
44 {
45 if (!status_enable)
46 return;
47 if (last_enq_time[0])
48 write_enq_link_times();
49 strcpy(last_enq_time, fmt_time);
50 }