diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-10-11 14:04:32 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-10-11 14:38:21 +0300 |
commit | 791cdf412f5fb66a056aa28b27507fdc9af86507 (patch) | |
tree | 9e6c4af696424ea72b51d0b8d9c8cf85c8b43856 /src/binlogcat.c | |
parent | df83b714395d41b096f7ad8cc3a090c9341f7598 (diff) | |
download | vmod-binlog-791cdf412f5fb66a056aa28b27507fdc9af86507.tar.gz vmod-binlog-791cdf412f5fb66a056aa28b27507fdc9af86507.tar.bz2 |
Add testsuite.
Diffstat (limited to 'src/binlogcat.c')
-rw-r--r-- | src/binlogcat.c | 18 |
1 files changed, 15 insertions, 3 deletions
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; |