fixed compilation probs
[spider.git] / cmd / uncatchup.pl
1 #
2 # catchup some or all of the non-private messages for a node.
3 #
4 # in other words mark all messages as being already received
5 # by this node.
6 #
7 # $Id$
8 #
9 # Copyright (c) 1999 Dirk Koopman G1TLH
10 #
11
12 my ($self, $line) = @_;
13 return (1, $self->msg('e5')) if $self->priv < 9;
14
15 my @f = split /\s+/, $line;
16 return (1, "usage: catchup <node call> all|[<msgno ...]") unless @f >= 2;
17
18 my $call = uc shift @f;
19 my $user = DXUser->get_current($call);
20 return (1, "$call not a node") unless $user && $user->sort ne 'U';
21
22 my @out;
23 my $ref;
24 my @ref;
25
26 # get a more or less valid set of messages
27 foreach my $msgno (@f) {
28         if ($msgno =~ /^al/oi) {
29                 @ref = DXMsg::get_all();
30                 last;
31         }
32         $ref = DXMsg::get($msgno);
33         unless ($ref) {
34                 push @out, $self->msg('m13', $msgno);
35                 next;
36         }
37         push @ref, $ref;
38 }
39
40 foreach $ref (@ref) {
41         next if $ref->{private};
42         if (grep {$_ eq $call} @{$ref->{gotit}}) {
43                 $ref->{gotit} = [ grep {$_ ne $call} @{$ref->{gotit}} ]; # mark this up as NOT being received
44                 $ref->store( [ $ref->read_msg_body() ] );       # re- store the file
45                 push @out, $self->msg('m15', $ref->{msgno}, $call);
46         }
47 }
48
49 return (1, @out);
50