#!/usr/local/bin/perl

# Usage: v2c [-v] [-i #] < verboselog >commonlog

# This script by default reads from standared input a WN logfile
# produced in the verbose format and writes a non-verbose one in
# the "common log format."   With the "-i n" option it writes only those
# entries from interface number 'n'.  I.e.  if you have listed three 
# IP addresses and corresponding data roots then "v2c -i 2 <logfile"
# will produce the log entries for the second of the three.  Adding
# the "-v" option gives the verbose form of log entries for interface #2.

	require "getopts.pl";

	&Getopts('vi:');


	$interface = $opt_i if $opt_i ne "";

	if ( !$opt_i) {
		while ( $line = <STDIN>) {
			$line =~ s/\s*<.*$//;
			print $line;
		}
	}
	else {
		while ( $line = <STDIN>) {
			chop $line;
			next unless $line =~ /<$interface>/;
			if ( $opt_v) {
				$line =~ s/<[0-9]*>$//;
			}
			else {
				$line =~ s/\s*<.*$//;
			}
			print $line, "\n";
		}
	}
