ttyrex

ttyrec with more options
git clone https://a3nm.net/git/ttyrex/
Log | Files | Refs | README

commit 1ca7750b29b507eb7ab6d8d218346540834f47d3
parent fb3a5a0d595af543e9804013b49a3a4be1289752
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Thu, 18 Oct 2012 13:02:21 +0200

Make ttytime display the start time of recordings

Diffstat:
README | 2++
ttytime.1 | 8++++----
ttytime.c | 12++++++++----
3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/README b/README @@ -11,6 +11,8 @@ record grow huge: with -l, you will get something like the first limit bytes of garbage, 2*limit bytes every second spent displaying garbage, and the last limit bytes of the garbage, which resembles more or less what you are likely to see. +ttytime now display the start timestamp of each file along with the duration. + -- Antoine Amarilli <a3nm@a3nm.net> %%%%% Original readme follows %%%%% diff --git a/ttytime.1 b/ttytime.1 @@ -3,21 +3,21 @@ .\" .TH TTYTIME 1 .SH NAME -ttytime \- print the time of the recorded session data by ttyrec(1) +ttytime \- print the start time and duration of the recorded session data by ttyrec(1) .SH SYNOPSIS .br .B ttytime .I file... .SH DESCRIPTION .B Ttytime -tells you the time of recorded data in seconds. +tells you the start time and duration of recorded data in seconds. For example: .sp .RS .nf % ttytime *.tty - 173 foo.tty - 1832 bar.tty +1350557831 173 foo.tty +1350557842 1832 bar.tty .fi .RE .SH "SEE ALSO" diff --git a/ttytime.c b/ttytime.c @@ -38,8 +38,8 @@ #include "io.h" #include "ttyrec.h" -int -calc_time (const char *filename) +void +calc_time (const char *filename, time_t *start_time, int *duration) { Header start, end; FILE *fp = efopen(filename, "r"); @@ -54,17 +54,21 @@ calc_time (const char *filename) end = h; fseek(fp, h.len, SEEK_CUR); } - return end.tv.tv_sec - start.tv.tv_sec; + *start_time = start.tv.tv_sec; + *duration = end.tv.tv_sec - start.tv.tv_sec; } int main (int argc, char **argv) { int i; + time_t start_time; + int duration; set_progname(argv[0]); for (i = 1; i < argc; i++) { char *filename = argv[i]; - printf("%7d %s\n", calc_time(filename), filename); + calc_time(filename, &start_time, &duration); + printf("%10d %10d %s\n", (int) start_time, duration, filename); } return 0; }