1 | /* $Id: mysql_drv.h,v 1.21 2011/06/28 00:13:48 sbajic Exp $ */ |
---|
2 | |
---|
3 | /* |
---|
4 | DSPAM |
---|
5 | COPYRIGHT (C) 2002-2012 DSPAM PROJECT |
---|
6 | |
---|
7 | This program is free software: you can redistribute it and/or modify |
---|
8 | it under the terms of the GNU Affero General Public License as |
---|
9 | published by the Free Software Foundation, either version 3 of the |
---|
10 | License, or (at your option) any later version. |
---|
11 | |
---|
12 | This program is distributed in the hope that it will be useful, |
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | GNU Affero General Public License for more details. |
---|
16 | |
---|
17 | You should have received a copy of the GNU Affero General Public License |
---|
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef _MYSQL_DRV_H |
---|
23 | # define _MYSQL_DRV_H |
---|
24 | |
---|
25 | #ifdef HAVE_CONFIG_H |
---|
26 | #include <auto-config.h> |
---|
27 | #endif |
---|
28 | |
---|
29 | #include <mysql.h> |
---|
30 | #include <mysqld_error.h> |
---|
31 | #include <errmsg.h> |
---|
32 | |
---|
33 | typedef struct _mysql_drv_dbh { |
---|
34 | MYSQL *dbh_read; |
---|
35 | MYSQL *dbh_write; |
---|
36 | } *_mysql_drv_dbh_t; |
---|
37 | |
---|
38 | struct _mysql_drv_storage |
---|
39 | { |
---|
40 | _mysql_drv_dbh_t dbt; /* db connections */ |
---|
41 | |
---|
42 | struct _ds_spam_totals control_totals; /* totals at storage init */ |
---|
43 | struct _ds_spam_totals merged_totals; /* totals for merged group */ |
---|
44 | |
---|
45 | /* control token data; used to measure deltas from getall to setall |
---|
46 | * enabling us to code a sql query based on increments/decrements |
---|
47 | * instead of query-coded data */ |
---|
48 | |
---|
49 | unsigned long long control_token; /* control token crc */ |
---|
50 | long control_sh; /* control token spam hits at getall */ |
---|
51 | long control_ih; /* control token innocent hits at getall */ |
---|
52 | |
---|
53 | MYSQL_RES *iter_user; /* get_nextuser iteration result */ |
---|
54 | MYSQL_RES *iter_token; /* get_nexttoken iteration result */ |
---|
55 | MYSQL_RES *iter_sig; /* get_nextsignature iteration result */ |
---|
56 | |
---|
57 | char u_getnextuser[MAX_FILENAME_LENGTH]; |
---|
58 | struct passwd p_getpwuid; |
---|
59 | struct passwd p_getpwnam; |
---|
60 | int dbh_attached; |
---|
61 | }; |
---|
62 | |
---|
63 | /* Driver-specific functions */ |
---|
64 | |
---|
65 | int _mysql_drv_get_spamtotals (DSPAM_CTX * CTX); |
---|
66 | int _mysql_drv_set_spamtotals (DSPAM_CTX * CTX); |
---|
67 | void _mysql_drv_query_error (const char *error, const char *query); |
---|
68 | MYSQL *_mysql_drv_connect (DSPAM_CTX *CTX, const char *prefix); |
---|
69 | MYSQL *_mysql_drv_sig_write_handle (DSPAM_CTX *CTX, |
---|
70 | struct _mysql_drv_storage *s); |
---|
71 | struct passwd *_mysql_drv_getpwnam (DSPAM_CTX * CTX, const char *name); |
---|
72 | struct passwd *_mysql_drv_getpwuid (DSPAM_CTX * CTX, uid_t uid); |
---|
73 | DSPAM_CTX *_mysql_drv_init_tools (const char *home, config_t config, |
---|
74 | void *dbt, int mode); |
---|
75 | |
---|
76 | #ifdef VIRTUAL_USERS |
---|
77 | struct passwd *_mysql_drv_setpwnam (DSPAM_CTX * CTX, const char *name); |
---|
78 | #endif |
---|
79 | |
---|
80 | #ifdef EXT_LOOKUP |
---|
81 | int verified_user; |
---|
82 | #endif |
---|
83 | |
---|
84 | #ifdef PREFERENCES_EXTENSION |
---|
85 | int _mysql_drv_set_attributes(DSPAM_CTX *CTX, config_t config); |
---|
86 | #endif |
---|
87 | #endif /* _MYSQL_DRV_H */ |
---|
88 | |
---|