File: tty_log.pl

package info (click to toggle)
uml-utilities 20070815.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 728 kB
  • sloc: ansic: 3,391; perl: 1,277; makefile: 239; exp: 129; sh: 122
file content (38 lines) | stat: -rw-r--r-- 805 bytes parent folder | download | duplicates (9)
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
35
36
37
38
# 
# Copyright (C) 2002, 2003 Jeff Dike (jdike@karaya.com)
# Licensed under the GPL
#

use tty_log;

use strict;

!@ARGV and die "Usage : perl tty_log.pl log-file";

my $file = $ARGV[0];

my @ops = read_log($file);

foreach my $op (@ops){
    if($op->{op} eq "open"){
	printf("Opening new tty 0x%x from tty 0x%x\n", $op->{tty}, 
	       $op->{old_tty});
    }
    elsif($op->{op} eq "close"){
	printf("Closing tty 0x%x\n", $op->{tty});
    }
    elsif($op->{op} eq "write"){
	if($op->{direction} eq "read"){
	    printf("Read from tty 0x%x - '%s'\n", $op->{tty}, $op->{string});
	}
	elsif($op->{direction} eq "write"){
	    printf("Write to tty 0x%x - '%s'\n", $op->{tty}, $op->{string});
	}
	else {
	    die "Bad direction - '$op->{direction}'";
	}
    }
    else {
	die "Bad op - " . $op->{op};
    }
}