File: termtime.c

package info (click to toggle)
termrec 0.19-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,148 kB
  • sloc: ansic: 8,430; makefile: 181; perl: 16; sh: 15
file content (34 lines) | stat: -rw-r--r-- 723 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <ttyrec.h>
#include <errno.h>
#include <string.h>
#include "sys/error.h"
#include "gettext.h"

static struct timeval tt;

static void delay(const struct timeval *tm, void *arg)
{
    tadd(tt, *tm);
}

int main(int argc, char **argv)
{
    int i;
    int any=0;

    if (argc<2)
        die("%s termtime <%s> ...\n", _("Usage:"), _("filename"));
    for (i=1;i<argc;i++)
    {
        tt.tv_sec=tt.tv_usec=0;
        if (ttyrec_r_play(-1, 0, argv[i], 0, delay, 0, 0))
        {
            printf("%7ld.%06ld\t%s\n", (long)tt.tv_sec, (long)tt.tv_usec, argv[i]);
            any=1;
        }
        else
            fprintf(stderr, "%s: %s\n", argv[i], strerror(errno));
    }
    return !any;
}