#!/usr/ug/bin/perl5 # # sample use: # gsub -akf /home/whuang/prog/gale/presence + # # by Wei-Hwa Huang (whuang@ugcs.caltech.edu) # sections of code stolen from jtr@ugcs.caltech.edu # 2000-03-07 my $MYNAME = 'whuang@ugcs.caltech.edu'; use strict; use POSIX qw(strftime); # gale info use vars qw($FROM $ENC $CAT $SIGN $TIME @MESSAGE $NEWCAT $FTIME); # misc use vars qw($GALE $HOME $LOGDIR $USER %LOGGEDTO); $FROM= $ENV{'HEADER_FROM'}; $TIME= $ENV{'HEADER_TIME'}; $CAT= $ENV{'GALE_CATEGORY'}; $CAT =~ s-zephyr/message-zephyr/MESSAGE-gi; $ENC= $ENV{'GALE_ENCRYPTED'}; $SIGN= $ENV{'GALE_SIGNED'}; $HOME= $ENV{'HOME'}; $GALE= $HOME . "/.gale/"; $LOGDIR= $HOME . "/gale/"; $USER= $ENV{'USER'}; $FTIME= $ENV{'GALE_TIME_ID_TIME'}; @MESSAGE = <>; if (($SIGN eq $MYNAME) and ($CAT !~ /bot/)) { my $filename = "/home/whuang/prog/gale/data/presence.$MYNAME"; print STDERR "found message from person: $SIGN\n"; my @times = (); push (@times, $TIME); # add the old times if (-e $filename) { open(FHAND,"<$filename"); my @data = ; chomp(@data); my $tm; my $lastline = ""; foreach $tm (@data) { next if ($tm eq $lastline); if ($TIME - $tm <= (60 * 60 * 99)) { push(@times, $tm); } $lastline = $tm; } close(FHAND); } # write the new times sub numic { return($a <=> $b); } @times = sort numic @times; open(FHAND,">$filename"); my $tm; foreach $tm (@times) { print FHAND "$tm\n"; } close(FHAND); }