From: djk Date: Wed, 30 Sep 1998 23:07:57 +0000 (+0000) Subject: got a working read message command WITH private marking (ie store works) X-Git-Tag: SPIDER_1_5~32 X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=624a291612bd3adf9dc02ec813a213109331b4c9;p=spider.git got a working read message command WITH private marking (ie store works) --- diff --git a/cmd/read.pl b/cmd/read.pl index c72be605..9df5edad 100644 --- a/cmd/read.pl +++ b/cmd/read.pl @@ -5,3 +5,34 @@ # # $Id$ # + +my ($self, $line) = @_; +my @f = split /\s+/, $line; +my $msgno; +my @out; +my @body; +my $ref; + +for $msgno (@f) { + $ref = DXMsg::get($msgno); + if (!$ref) { + push @out, "Msg $msgno not found"; + next; + } + if ($ref->private && $self->priv < 9 && $ref->to ne $ref->call) { + push @out, "Msg $msgno not available"; + next; + } + push @out, sprintf "Msg: %d From: %s Date: %6.6s %5.5s Subj: %-30.30s", $msgno, + $ref->from, cldate($ref->t), ztime($ref->t), $ref->subject; + @body = $ref->read_msg_body; + push @out, @body; + + # mark my privates as read + if ($ref->private && $self->call eq $ref->to && $ref->read == 0) { + $ref->read(1); + $ref->store(\@body); # note call by reference! + } +} + +return (1, @out); diff --git a/perl/DXMsg.pm b/perl/DXMsg.pm index e949c682..47a8e674 100644 --- a/perl/DXMsg.pm +++ b/perl/DXMsg.pm @@ -134,9 +134,14 @@ sub process my $ref = $work{"$f[1]$f[2]$f[3]"}; if ($ref) { $self->send(DXProt::pc33($f[2], $f[1], $f[3]));# acknowledge it + + # get the next msg no - note that this has NOTHING to do with the stream number in PC protocol + my $msgno = next_transno("Msgno") if !$ref->{file}; + $ref->store($ref->{lines}); # store it (whatever that may mean) $ref->workclean; delete $work{"$f[1]$f[2]$f[3]"}; # remove the reference from the work vector + push @msg, $ref; # add this message to the incore message list } last SWITCH; } @@ -210,17 +215,14 @@ sub store # push @{$ref->{gotit}}, $ref->{fromnode} if $ref->{fromnode}; } else { # a normal message - # get the next msg no - note that this has NOTHING to do with the stream number in PC protocol - my $msgno = next_transno("Msgno"); - # attempt to open the message file - my $fn = filename($msgno); + my $fn = filename($ref->{msgno}); dbg('msg', "To be stored in $fn\n"); my $fh = new FileHandle "$fn", "w"; if (defined $fh) { - print $fh "=== $msgno^$ref->{to}^$ref->{from}^$ref->{t}^$ref->{private}^$ref->{subject}^$ref->{origin}^$ref->{read}\n"; + print $fh "=== $ref->{msgno}^$ref->{to}^$ref->{from}^$ref->{t}^$ref->{private}^$ref->{subject}^$ref->{origin}^$ref->{read}\n"; print $fh "=== $ref->{fromnode}\n"; my $line; foreach $line (@{$lines}) { @@ -228,11 +230,9 @@ sub store print $fh "$line\n"; } $ref->{gotit} = []; - $ref->{msgno} = $msgno; push @{$ref->{gotit}}, $ref->{fromnode} if $ref->{fromnode}; - push @msg, $ref; # add this message to the incore message list $fh->close; - dbg('msg', "msg $msgno stored\n"); + dbg('msg', "msg $ref->{msgno} stored\n"); } else { confess "can't open msg file $fn $!"; } @@ -314,8 +314,8 @@ sub read_msg_body chomp (@out = <$file>); close($file); - shift @out if $out[0] =~ /^=== \d+\^/; - shift @out if $out[0] =~ /^=== \d+\^/; + shift @out if $out[0] =~ /^=== /; + shift @out if $out[0] =~ /^=== /; return @out; } @@ -374,6 +374,17 @@ sub get_all return @msg; } +# get a particular message +sub get +{ + my $msgno = shift; + for (@msg) { + return $_ if $_->{msgno} == $msgno; + last if $_->{msgno} > $msgno; + } + return undef; +} + # return the official filename for a message no sub filename {