FreeCalypso > hg > themwi-system-sw
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/smpp-trx-sa/enq_link_stat.c Wed Oct 11 21:22:32 2023 -0800 @@ -0,0 +1,50 @@ +/* + * This module tracks and logs the times of enquire_link packets + * from the SMPP server. + */ + +#include <sys/types.h> +#include <sys/file.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include <time.h> +#include <unistd.h> + +extern char fmt_time[32]; + +static int status_fd, status_enable; +static char last_enq_time[32]; + +void +log_enquire_link_open(filename) + char *filename; +{ + status_fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666); + if (status_fd < 0) { + perror(filename); + exit(1); + } + status_enable = 1; +} + +static void +write_enq_link_times() +{ + char buf[128]; + + sprintf(buf, "%s\n%s\n", last_enq_time, fmt_time); + lseek(status_fd, 0, SEEK_SET); + write(status_fd, buf, strlen(buf)); +} + +void +log_enquire_link_item() +{ + if (!status_enable) + return; + if (last_enq_time[0]) + write_enq_link_times(); + strcpy(last_enq_time, fmt_time); +}