1
/* $Id: message.cpp,v 1.8 2004/08/19 14:52:29 terpstra Exp $
3
* message.cpp - Cleanup after a message/ command
5
* Copyright (C) 2002 - Wesley W. Terpstra
9
* Authors: 'Wesley W. Terpstra' <wesley@terpstra.ca>
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; version 2.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
#define _XOPEN_SOURCE 500
26
#define _FILE_OFFSET_BITS 64
35
bool PTable::test_message(KSI ks)
37
const string::size_type skip = sizeof("message"); // null is /
38
return MessageId::is_full(ks->first.c_str() + skip);
41
void PTable::calc_message(KSI ks)
43
/* Messages themselves never change
45
* ... but messages include:
46
* list info (from config file)
48
* next/prev for each mbox info
51
* kill if obsolete due to above
52
* kill if older than a fixed time
53
* kill if no recent accesses
56
if (!test_message(ks))
59
cout << ks->first << ": not a lurker file." << endl;
63
MessageId id(ks->first.c_str() + 8);
64
if (ks->second.mtime <= cfg.modified)
65
{ // die - it's older than the config file
66
ks->second.kill = true;
68
cout << ks->first << ": older than config file." << endl;
72
if (now - ks->second.mtime >= modifiedLimit)
74
ks->second.kill = true;
76
cout << ks->first << ": expired due to maximum age." << endl;
80
if (now - ks->second.atime >= accessedLimit)
82
ks->second.kill = true;
84
cout << ks->first << ": expired due to no access." << endl;
88
Summary& sum = summaries[id];
89
string tid(subject_hash(sum.subject.c_str()));
90
if (threads.find(tid) != threads.end())
91
{ // die - the thread changed
92
ks->second.kill = true;
94
cout << ks->first << ": thread modified." << endl;
98
set<string>::const_iterator list;
99
for (list = sum.lists.begin(); list != sum.lists.end(); ++list)
101
const MessageIds& ids = lists[*list];
102
MessageIds::const_iterator self = ids.find(id);
103
if (self == ids.end())
105
// if it can't find us, then we are not in the range
106
// off messages whose mindex is affected by import
110
MessageIds::const_iterator next = self; ++next;
111
MessageIds::const_iterator prev = self; --prev;
113
Summaries::const_iterator ns, ps;
115
if (prev != ids.end() &&
116
(ps = summaries.find(*prev)) != summaries.end() &&
119
ks->second.kill = true;
121
cout << ks->first << ": previous message changed in '" << *list << "'." << endl;
125
if (next != ids.end() &&
126
(ns = summaries.find(*next)) != summaries.end() &&
129
ks->second.kill = true;
131
cout << ks->first << ": next message changed in '" << *list << "'." << endl;
137
cout << ks->first << ": not expired" << endl;