Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | ##---------------------------------------------------------------------------## |
2 | ## File: | |
3 | ## $Id: mhrmm.pl,v 1.6 2001/09/17 16:10:35 ehood Exp $ | |
4 | ## Author: | |
5 | ## Earl Hood mhonarc@mhonarc.org | |
6 | ## Description: | |
7 | ## Rmm routine for MHonArc. | |
8 | ##---------------------------------------------------------------------------## | |
9 | ## MHonArc -- Internet mail-to-HTML converter | |
10 | ## Copyright (C) 1995-1999 Earl Hood, mhonarc@mhonarc.org | |
11 | ## | |
12 | ## This program is free software; you can redistribute it and/or modify | |
13 | ## it under the terms of the GNU General Public License as published by | |
14 | ## the Free Software Foundation; either version 2 of the License, or | |
15 | ## (at your option) any later version. | |
16 | ## | |
17 | ## This program is distributed in the hope that it will be useful, | |
18 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | ## GNU General Public License for more details. | |
21 | ## | |
22 | ## You should have received a copy of the GNU General Public License | |
23 | ## along with this program; if not, write to the Free Software | |
24 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
25 | ## 02111-1307, USA | |
26 | ##---------------------------------------------------------------------------## | |
27 | ||
28 | package mhonarc; | |
29 | ||
30 | ##--------------------------------------------------------------------------- | |
31 | ## Function for removing messages. | |
32 | ## | |
33 | sub rmm { | |
34 | my(@numbers) = (); | |
35 | my($key, %Num2Index, $num, $i, $pg); | |
36 | local($_); | |
37 | ||
38 | ## Create list of messages to remove | |
39 | foreach (@_) { | |
40 | # range | |
41 | if (/^(\d+)-(\d+)$/) { | |
42 | push(@numbers, int($1) .. int($2)); | |
43 | next; | |
44 | } | |
45 | # single number | |
46 | if (/^\d+$/) { | |
47 | push(@numbers, int($_)); | |
48 | next; | |
49 | } | |
50 | # probably message-id | |
51 | push(@numbers, $_); | |
52 | } | |
53 | ||
54 | if ($#numbers < 0) { | |
55 | warn("Warning: No messages specified\n"); | |
56 | return 0; | |
57 | } | |
58 | ||
59 | ## Make hash to perform deletions | |
60 | foreach $key (keys %IndexNum) { | |
61 | $Num2Index{$IndexNum{$key}} = $key; | |
62 | } | |
63 | ||
64 | ## Set @MListOrder to flag next/prev messages to be updated. | |
65 | ## @TListOrder is already set since it is saved in db. | |
66 | @MListOrder = &sort_messages(); | |
67 | $i=0; foreach $key (@MListOrder) { | |
68 | $Index2MLoc{$key} = $i++; | |
69 | } | |
70 | ||
71 | ## Remove messages | |
72 | foreach $num (@numbers) { | |
73 | if (($key = $Num2Index{$num}) || ($key = $MsgId{$num})) { | |
74 | &delmsg($key); | |
75 | ||
76 | # Need to flag messages that link to deleted message so | |
77 | # they will be updated. | |
78 | foreach (@{$FollowOld{$index}}) { | |
79 | $Update{$IndexNum{$_}} = 1; | |
80 | } | |
81 | $Update{$IndexNum{$TListOrder[$Index2TLoc{$key}-1]}} = 1; | |
82 | $Update{$IndexNum{$TListOrder[$Index2TLoc{$key}+1]}} = 1; | |
83 | $Update{$IndexNum{$MListOrder[$Index2MLoc{$key}-1]}} = 1; | |
84 | $Update{$IndexNum{$MListOrder[$Index2MLoc{$key}+1]}} = 1; | |
85 | ||
86 | # Mark where index page updates start | |
87 | if ($MULTIIDX) { | |
88 | $pg = int($Index2MLoc{$key}/$IDXSIZE)+1; | |
89 | $IdxMinPg = $pg | |
90 | if ($pg < $IdxMinPg || $IdxMinPg < 0); | |
91 | $pg = int($Index2TLoc{$key}/$IDXSIZE)+1; | |
92 | $TIdxMinPg = $pg | |
93 | if ($pg < $TIdxMinPg || $TIdxMinPg < 0); | |
94 | } | |
95 | ||
96 | next; | |
97 | } | |
98 | ||
99 | # message not in archive | |
100 | warn qq/Warning: Message "$num" not in archive\n/; | |
101 | } | |
102 | ||
103 | ## Clear loc data; it will get recomputed | |
104 | @MListOrder = (); | |
105 | %Index2MLoc = (); | |
106 | ||
107 | write_pages(); | |
108 | 1; | |
109 | } | |
110 | ||
111 | ##---------------------------------------------------------------------------## | |
112 | 1; |