#
#	Here is a nawk script that converts a report generated
#	with "netaccount -s 0 filename > reportfile" or
#	"netaccount -t filename > reportfile" to a tab-separated
#	format that can be incorporated into most spreadsheets.
#	To use this script, run "nawk -f tospread reportfile > spreadfile".
#	The file "spreadfile" can than be read into your spreadsheet.
#
#	The information in this software is subject to change without
#	notice and should not be construed as a commitment by
#	Silicon Graphics, Inc.
#
#	$Revision: 1.1 $
#
/----------/ { print "\n",$0,"\n" }
/\(([0-9]+.)+[0-9]+|\[([0-9|a-f]+:)+[0-9|a-f]/ {
	if (NF != 1)
		break
	i = match($0, "[a-z|0-9]")
	if (i != 1)
		name = ""
	else {
		e = match($0, "[(]|[\[]")
		if (e == 0)
			name = $0
		else
			name = substr($0, i, e-1)
	}
	i = match($0, "[(]")
	if (i == 0)
		inet = ""
	else {
		e = match($0, "[)]")
		if (e == 0)
			inet = ""
		else
			inet = substr($0, i+1, e-i-1)
	}
	i = match($0, "[\[]")
	if (i == 0)
		enet = ""
	else {
		e = match($0, "[\]]")
		if (e == 0)
			enet = ""
		else
			enet = substr($0, i+1, e-i-1)
	}
	printf "%s\t%s\t%s\n", name, inet, enet
}
/(ether|fddi|crayio|arp|rarp|arpip|ip|egp|hello|icmp|igmp|tcp|udp|bootp|dns|rip|sunrpc|mount|nfs|pmap|yp|ypbind|tftp|decnet|nsp|xtp|smt|mac|llc|fimpl|idp|xnsrip|echo|error|spp|pep|elap|aarp|ddp|rtmp|aep|atp|nbp|adsp|zip|asp|pap|afp|snmp|lat|0x[0-9|a-f]+)/ {
	if (NF < 3)
		break
	printf "\t\t"
	for (i = 1; i <= NF; i++) {
		e = match($i, "[\[]")
		if (e != 0) {
			f = match($i, "[\]]")
			if (f == 0)
				continue
			$i = substr($i, e+1, f-e-1)
		}
		e = match($i, "%")
		if (e != 0)
			$i = substr($i, 1, e-1)
		printf "\t%s", $i
	}
	printf "\n"
}
