1 /* $Id: mbox.cpp 1649 2009-10-19 14:35:01Z terpstra $ 2 * 3 * mbox.cpp - Cleanup after an mbox/ command 4 * 5 * Copyright (C) 2002 - Wesley W. Terpstra 6 * 7 * License: GPL 8 * 9 * Authors: 'Wesley W. Terpstra' <wesley@terpstra.ca> 10 * 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. 14 * 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. 19 * 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 23 */ 24 25 #define _FILE_OFFSET_BITS 64 26 27 #include "PTable.h" 28 #include <Keys.h> 29 30 #include <iostream> 31 32 using namespace std; 33 test_mbox(KSI ks)34bool PTable::test_mbox(KSI ks) 35 { 36 const string::size_type skip = sizeof("mbox"); // null is / 37 return MessageId::is_full(ks->first.c_str() + skip); 38 } 39 calc_mbox(KSI ks)40void PTable::calc_mbox(KSI ks) 41 { 42 /* MBox contents never change 43 * 44 * Policy: 45 * kill after a bounded lifetime 46 * kill after a period of no accesses 47 */ 48 49 if (!test_mbox(ks)) 50 { 51 if (verbose) 52 cout << ks->first << ": not a lurker file." << endl; 53 return; 54 } 55 56 if (now - ks->second.mtime >= modifiedLimit) 57 { 58 ks->second.kill = true; 59 if (verbose) 60 cout << ks->first << ": expired due to maximum age." << endl; 61 return; 62 } 63 64 if (now - ks->second.atime >= accessedLimit) 65 { 66 ks->second.kill = true; 67 if (verbose) 68 cout << ks->first << ": expired due to no access." << endl; 69 return; 70 } 71 72 if (verbose) 73 cout << ks->first << ": not expired" << endl; 74 } 75