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
|
/* This file is part of Mailfromd.
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Sergey
Poznyakoff
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 3, 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, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <mailutils/mailutils.h>
#include "libmf.h"
#include "mfdb.h"
#include "mf-dbm.h"
#include "filenames.h"
static void
greylist_print_item(const char *key, size_t size, const void *content)
{
time_t timestamp = *(time_t*) content;
size--; /* Size includes the trailing nul */
printf("%*.*s ", size, size, key);
format_time_str(stdout, timestamp);
putchar('\n');
}
static int
greylist_expire_item(const void *content)
{
time_t timestamp = *(time_t*) content;
return greylist_format->expire_interval &&
time(NULL) - timestamp > greylist_format->expire_interval;
}
static struct db_format greylist_format_struct = {
"greylist",
DEFAULT_GREYLIST_DATABASE,
1,
0,
DEFAULT_EXPIRE_INTERVAL,
greylist_print_item,
greylist_expire_item
};
struct db_format *greylist_format = &greylist_format_struct;
|