From 791cdf412f5fb66a056aa28b27507fdc9af86507 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Fri, 11 Oct 2013 14:04:32 +0300 Subject: Add testsuite. --- src/binlogcat.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/binlogcat.c') diff --git a/src/binlogcat.c b/src/binlogcat.c index c51125b..219f78c 100644 --- a/src/binlogcat.c +++ b/src/binlogcat.c @@ -28,6 +28,7 @@ char *progname; char *timefmt = "%c"; int number_option; int verbose_option; +int timediff_option; void catlog(const char *fname) @@ -37,7 +38,8 @@ catlog(const char *fname) struct binlog_record rec; char timebuf[128]; size_t i; - + time_t start_ts; + if (strcmp(fname, "-") == 0) fp = stdin; else { @@ -83,6 +85,12 @@ catlog(const char *fname) break; } + if (timediff_option) { + if (i == 0) + start_ts = rec.ts; + rec.ts -= start_ts; + } + strftime(timebuf, sizeof timebuf, timefmt, localtime(&rec.ts)); if (number_option) printf("%lu ", (unsigned long) i); @@ -95,7 +103,7 @@ catlog(const char *fname) void help() { - printf("usage: %s [-hnv] [t FORMAT] [FILE...]\n"); + printf("usage: %s [-dhnv] [t FORMAT] [FILE...]\n"); } int @@ -104,8 +112,12 @@ main(int argc, char **argv) progname = argv[0]; int c; - while ((c = getopt(argc, argv, "ht:nv")) != EOF) + while ((c = getopt(argc, argv, "dht:nv")) != EOF) switch (c) { + case 'd': + timediff_option = 1; + timefmt = "%s"; + break; case 'h': help(); return 0; -- cgit v1.2.1