File: mhrmm.pl

package info (click to toggle)
mhonarc 2.6.24-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,020 kB
  • sloc: perl: 280,086; makefile: 11
file content (113 lines) | stat: -rw-r--r-- 3,740 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
##---------------------------------------------------------------------------##
##  File:
##      $Id: mhrmm.pl,v 1.6 2001/09/17 16:10:35 ehood Exp $
##  Author:
##      Earl Hood       mhonarc@mhonarc.org
##  Description:
##      Rmm routine for MHonArc.
##---------------------------------------------------------------------------##
##    MHonArc -- Internet mail-to-HTML converter
##    Copyright (C) 1995-1999   Earl Hood, mhonarc@mhonarc.org
##
##    This program is free software; you can redistribute it and/or modify
##    it under the terms of the GNU General Public License as published by
##    the Free Software Foundation; either version 2 of the License, or
##    (at your option) any later version.
##
##    This program is distributed in the hope that it will be useful,
##    but WITHOUT ANY WARRANTY; without even the implied warranty of
##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##    GNU General Public License for more details.
##
##    You should have received a copy of the GNU General Public License
##    along with this program; if not, write to the Free Software
##    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
##    02111-1307, USA
##---------------------------------------------------------------------------##

package mhonarc;

##---------------------------------------------------------------------------
##	Function for removing messages.
##
sub rmm {
    my (@numbers) = ();
    my ($key, %Num2Index, $num, $i, $pg);
    local ($_);

    ## Create list of messages to remove
    foreach (@_) {
        # range
        if (/^(\d+)-(\d+)$/) {
            push(@numbers, int($1) .. int($2));
            next;
        }
        # single number
        if (/^\d+$/) {
            push(@numbers, int($_));
            next;
        }
        # probably message-id
        push(@numbers, $_);
    }

    if ($#numbers < 0) {
        warn("Warning: No messages specified\n");
        return 0;
    }

    ## Make hash to perform deletions
    foreach $key (keys %IndexNum) {
        $Num2Index{$IndexNum{$key}} = $key;
    }

    ## Set @MListOrder to flag next/prev messages to be updated.
    ## @TListOrder is already set since it is saved in db.
    @MListOrder = &sort_messages();
    $i          = 0;
    foreach $key (@MListOrder) {
        $Index2MLoc{$key} = $i++;
    }

    ## Remove messages
    foreach $num (@numbers) {
        if (($key = $Num2Index{$num}) || ($key = $MsgId{$num})) {
            &delmsg($key);

            # Need to flag messages that link to deleted message so
            # they will be updated.
            foreach (@{$FollowOld{$index}}) {
                $Update{$IndexNum{$_}} = 1;
            }
            $Update{$IndexNum{$TListOrder[$Index2TLoc{$key} - 1]}} = 1;
            $Update{$IndexNum{$TListOrder[$Index2TLoc{$key} + 1]}} = 1;
            $Update{$IndexNum{$MListOrder[$Index2MLoc{$key} - 1]}} = 1;
            $Update{$IndexNum{$MListOrder[$Index2MLoc{$key} + 1]}} = 1;

            # Mark where index page updates start
            if ($MULTIIDX) {
                $pg       = int($Index2MLoc{$key} / $IDXSIZE) + 1;
                $IdxMinPg = $pg
                    if ($pg < $IdxMinPg || $IdxMinPg < 0);
                $pg        = int($Index2TLoc{$key} / $IDXSIZE) + 1;
                $TIdxMinPg = $pg
                    if ($pg < $TIdxMinPg || $TIdxMinPg < 0);
            }

            next;
        }

        # message not in archive
        warn qq/Warning: Message "$num" not in archive\n/;
    }

    ## Clear loc data; it will get recomputed
    @MListOrder = ();
    %Index2MLoc = ();

    write_pages();
    1;
}

##---------------------------------------------------------------------------##
1;