aboutsummaryrefslogtreecommitdiff
path: root/lib/mfdb.h
blob: 5d53c4c847f15a84a896593e48f422f1e101e098 (plain)
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
/* This file is part of Mailfromd.
   Copyright (C) 2005-2012, 2015-2017 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/>. */

#include <mailutils/dbm.h>

typedef void (*db_item_printer_t)(struct mu_dbm_datum const *,
				  struct mu_dbm_datum const *);
typedef int (*db_expire_t)(struct mu_dbm_datum const *content);

struct db_format {
	char *name;
	char *dbname;
	int enabled;
	mu_debug_handle_t debug_handle;
	time_t expire_interval;
	db_item_printer_t print_item;
	db_expire_t expire;
};

typedef int (*dbfmt_enumerator_t)(struct db_format *fmt, void *);

extern mu_debug_handle_t db_debug_handle;
extern struct db_format *cache_format;
extern int mf_database_mode;

struct db_format *cache_format;
struct db_format *rate_format;
struct db_format *tbf_rate_format;
struct db_format *greylist_format;

mu_dbm_file_t mf_dbm_open(char *dbname, int access);
int mf_file_mode_to_safety_criteria(int mode);


void db_format_setup(void);
void db_format_enumerate(dbfmt_enumerator_t fp, void *data);
struct db_format *db_format_install(struct db_format *fmt);
struct db_format *db_format_lookup(const char *name);
int db_list_item(char *dbname, char *email, db_item_printer_t fun);
int db_list(char *dbname, db_item_printer_t fun);
int db_expire(char *dbname, db_expire_t fun);
int db_delete(char *dbname, char *id);
int db_compact(char *dbname, db_expire_t fun);

void database_cfg_init(void);
int cb_database_mode(void *data, mu_config_value_t *arg);

/* cache.c */
mf_status cache_get(const char *email);
void cache_insert(const char *email, mf_status rc);
mf_status cache_get2(const char *email, const char *client_addr);
void cache_insert2(const char *email, const char *client_addr, mf_status rc);

extern time_t negative_expire_interval;

/* rate.c */
mf_status get_rate(char *email, long *ret, unsigned long interval,
		   size_t mincount, size_t threshold);

/* tbf_rate.c */
mf_status check_tbf_rate(char *email, int *ret,
			 size_t cost, size_t interval, size_t burst_size);

extern int ignore_failed_reads_option;
extern char *time_format_string; /* String to format the time stamps */



Return to:

Send suggestions and report system problems to the System administrator.