aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-10-19 00:06:22 +0200
committerHarald Welte <laforge@gnumonks.org>2016-10-19 00:06:22 +0200
commit74d1e3409d63154b786f2267e5257a3aae042a74 (patch)
tree8c6686b13bd77ff1cab32559f1ba6bba370676e1
parentdbb0f5ae999155b1eb2ec490c48ff3c5ec848935 (diff)
e1cap_dump: Print human-readable time
-rw-r--r--src/e1cap_dump.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/e1cap_dump.c b/src/e1cap_dump.c
index 3e91191..03b86f7 100644
--- a/src/e1cap_dump.c
+++ b/src/e1cap_dump.c
@@ -1,4 +1,6 @@
#include <stdio.h>
+#include <time.h>
+
#include <sys/time.h>
#include <osmocom/core/signal.h>
@@ -10,6 +12,20 @@
struct e1_recorder g_recorder;
+static char *timeval2str(struct timeval *tv)
+{
+ time_t nowtime;
+ struct tm *nowtm;
+ char tmbuf[64];
+ static char buf[64];
+
+ nowtime = tv->tv_sec;
+ nowtm = localtime(&nowtime);
+ strftime(tmbuf, sizeof tmbuf, "%Y-%m-%d %H:%M:%S", nowtm);
+ snprintf(buf, sizeof buf, "%s.%06ld", tmbuf, tv->tv_usec);
+ return buf;
+}
+
int main(int argc, char **argv)
{
struct osmo_e1cap_file *f;
@@ -26,8 +42,8 @@ int main(int argc, char **argv)
exit(1);
while ((pkt = osmo_e1cap_read_next(f))) {
- printf("%lu:%lu %02u/%02u %u (%u): %s\n",
- pkt->ts.tv_sec, pkt->ts.tv_usec,
+ printf("%s %02u/%02u %u (%u): %s\n",
+ timeval2str(&pkt->ts),
pkt->line_nr, pkt->ts_nr, pkt->capture_mode,
pkt->len,
osmo_hexdump_nospc(pkt->data, pkt->len));