## NOTE: this file has been machine-generated.  It's ugly.  So?  =)
##
## zwgc2zion translator,  version 0.967 <08sep1996>
##  Zwgc::Desc tokenizer, version 1.00 <22aug1996>
##  translation rules,    version 0.201 <08sep1996>

use FileHandle;
use IPC::Open2;

use lib '/afs/sipb/user/bert/dev/zion/dev';
use Zion::Zwgc 0.20;
BEGIN { $Zion::Zwgc::Debug = 1; }   # comment this out to suppress messages

use vars qw( %ZVAR %port );
%ZVAR = Zion::Zwgc::zephyr_variables("$ENV{'HOME'}/.zephyr.vars")
	unless %ZVAR;

my $_buffer_ = '';
my @fields = Zion::fields();

#	Copyright 1989, 1990 Massachusetts Institute of Technology
#
#	For copying and distribution information, see the file
#	"mit-copyright.h".
# 
#	$Source: /afs/dev.mit.edu/source/src80/athena/lib/zephyr.p4a/zwgc/RCS/zwgc.desc,v $
#	$Author: probe $
#	$Id: zwgc.desc,v 1.12 1994/04/29 11:59:32 probe Exp $
#
#
# Default WindowGram description file
#

# Opcode "ping" is used by sender programs to see if the message would
# really get sent, or if the recipient has logged out.  No useful
# information is normally contained in these messages, so we discard them.
 if( (  uc($opcode) eq "PING" ) ) { exit; }

#
# AUTHENTICATION information
#
# $auth can be either Yes, No, or Forged
#
# "Yes" means that the sender field present in the notice was verified by
# Kerberos authentication
#
# "No" means that either the sender did not include any authentication
# information, or the authentication information was not verified by the
# Zephyr Server before the notice was sent to you.
#
# "Forged" means that the Server claims that the sender of the notice
# was verified by Kerberos authentication, but your WindowGram client
# could not verify this.  This stage of verification is done by a cryptographic
# checksum.  The most probable cause of the failure of the checksum
# provided by the Server to match the checksum generated by your
# WindowGram client is that you changed Kerberos tickets, and the Server
# was using an old value to compute the cryptographic checksum.  You can
# update the Server's value by typing 'zctl load' to your prompt.
#
# By default, notices which appear forged are labeled as 'UNAUTHENTIC'
# to avoid confusion as to what 'Forged' really means.
# To change this display, change the last word in the line following
# 'match "forged" to something other than "UNAUTHENTIC".
{my $_case_ = $auth; if (0) {} # so every 'match' is an elsif

 elsif(grep($_case_ eq $_,"yes")){
$aval="Authentic";
} elsif(grep($_case_ eq $_,"no","forged")){
$aval="\@b(\@large(UNAUTHENTIC))";
}}

{my $_case_ = $class; if (0) {} # so every 'match' is an elsif

 elsif(grep($_case_ eq $_,"WG_CTL_CLASS")){
 exit; 
#  
# MAIL NOTIFICATION
#
# To receive mail notifications, you need to do several things:
# 1) subscribe to MAIL,POP messages.  You do this by typing:
#	zctl add mail pop
# to your prompt.  By doing this, you will get a simple notice every
# time you are logged in and more mail arrives for you at your post office.
#
# 2) If you wish to be notified of the sender, recipient and subject of the
# new mail, remove the pound-signs from the beginning of the 10 lines below
# between 'match "MAIL"' and 'exit', inclusive, and type the command
#	zctl add mail popret
# to your prompt.
#
# Note: The use of the following lines is NOT necessary to receive
# notifications of new mail.  The only effect of uncommenting these
# lines is to display on your screen the sender, recipient and subject
# of the mail (In addition, uncommenting these lines will add extra load
# to the post office servers, making them run slower.).
# If you do not wish this information to be displayed where other users
# might possibly read it, or you wish to avoid loading down the post
# office servers, you need not uncomment these lines.  Just follow step
# 1 above. 
#
#match "MAIL"
#	case $instance
#	match "pop"
#		exec "zmailnotify"
#		exit
#	endcase
#	print "(Authentication: @bold("+$aval+"))\n"
#	print substitute($default)
#	put
#	exit
} elsif(grep($_case_ eq $_,"message")){
{my $_case_ = $instance; if (0) {} # so every 'match' is an elsif

 elsif(grep($_case_ eq $_,"PERSONAL")){
$type="Personal";
} elsif(grep($_case_ eq $_,"URGENT")){
$type="Urgent";
} else {
$type="Instance ".$instance;
}}

($signature,$body) = @fields; 
 if( ( $body eq "" ) ) {
$body=$signature;
$signature="";
}
 if( ( $signature=~ m"^[Ff]rom: .*" ) ) {
$dummy= Zion::Zwgc::any(\$signature, 0, length("From: "));
}
 if( ( $signature=~ m"\n\$" ) ) {
$dummy= Zion::Zwgc::any(\$signature, -length("\n"));
}
 if( ( $signature eq "" ) ) {
$ftext="From: \@bold(". Zion::Zwgc::protect($sender).")";
}{
$ftext="From: \@bold(". Zion::Zwgc::protect($signature)." <". Zion::Zwgc::protect(
$sender).">)";
}

 $_buffer_ .= join(" ", "\@center(\@bold(".$aval.") ".$type." message at ".$time." on ".$date."\n".$ftext." on ".$fromhost."\nTo: ".$recipient.")\n\n"); 


 $_buffer_ .= join(" ", $body); 
 Zion::put($_buffer_); 
 exit; 

} elsif(grep($_case_ eq $_,"login")){
{my $_case_ = $opcode; if (0) {} # so every 'match' is an elsif

 elsif(grep($_case_ eq $_,"USER_LOGIN")){
$log="logged in";
} elsif(grep($_case_ eq $_,"USER_LOGOUT")){
$log="logged out";
} else {
$log="unknown opcode";
}}

($host,$when,$tty) = @fields; 
 $_buffer_ .= join(" ", "\@center(\@bold(".$sender.") ".$log.")\n"); 
 $_buffer_ .= join(" ", "\@center(on \@bold(".$host.") on ".$tty.")\n"); 
 $_buffer_ .= join(" ", "\@center(at ".$when.")"); 
 Zion::put($_buffer_); 
 exit; 

} else {
 $_buffer_ .= join(" ", "(Authentication: \@bold(".$aval.") from host: ".$fromhost.")\n"); 
 $_buffer_ .= join(" ",  Zion::Zwgc::substitute($default)); 
 Zion::put($_buffer_); 
 exit; 

}}
