#  /Trace replacement - Eric Prestemon (ecp2z@virginia.edu, Mar 23, 1992)
#  Some simple aliases and on's to implement a single-line trace
#  Lost is the timing of net delays, but also lost is the wasted
#  space...just load these up at run time, and /trace'ing will
#  never be the same.
#  Note: Do not launch a new trace until the old one finishes. I don't
#  even know what will happen, I just know it will be wrong. =)

# The main alias
alias STRACE ^assign _stn $0;^assign _stt Trace:$left($index(. $S)-1 $S);quote trace $0

# Don't want to see that first one...
on ^server_notice *LINK* comment

# These 2 stick the first part of each server name on the path onto the
#   end of _tt...(2.7 and 2.6 are handled, respectively)
on ^200 * assign _stt $_stt-$left($index(. $0)-1 $0)
on ^NOTICE "*.* *LINK*" assign _stt $_stt-$left($index(. $3)-1 $3)

# The next few lines handle the messages from 2.6* servers
on ^notice "*.* *OPER*" {
	if ( [$6] )
		{ assign _stx $6 }
		{ assign _stx $5 }
	if ( rmatch($left($index([ $_stx)-1 $_stx) $_stn) == 1 )
		{ _trace_parse $0 $_stx * }
		{ _trace_servb $* }
	assign -_stx
}

on ^notice "*.* *USER*" comment

on ^notice "%.% *SERV*" _trace_servb $*
alias _trace_servb {
	if ( rmatch($0 $_stn) == 1 )
		{ echo $_stt-$0 }
	assign -_stt
	assign -_str
	assign _stn qwertyuipoadfg
	echo $1-3 $5-
}

# These lines handle 2.7* servers, with their numeric messages
on ^203 * comment

on ^204 * {
	if ( rmatch($left($index([ $3)-1 $3) $_stn) == 1 )
		{ _trace_parse $0 $3 * }
		{ _trace_serva $* }
}
on ^205 * comment

on ^206 * _trace_serva $*
alias _trace_serva {
	if ( rmatch($0 $_stn) == 1 )
		{ echo $_stt-$0 }
	assign -_stt
	assign -_str
	assign _stn qwertyuiopzxc
	echo *** $1 Class[$2] ==> $3-
}

on ^209 comment

# This is called at the end of the line, if it is a user or operator, to 
#   echo the path, the full name of the final server, and the username.
alias _trace_parse assign _str -$left($index([ $1)-1 $1);echo $_stt-$0$_str$2;assign _stn qwertuipzxc;assign -_str;assign -_stt
