[c5c522c] | 1 | /* $Id: pgsql_drv.h,v 1.17 2011/09/30 20:52:20 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 _PGSQL_DRV_H |
---|
| 23 | # define _PGSQL_DRV_H |
---|
| 24 | |
---|
| 25 | #ifdef HAVE_CONFIG_H |
---|
| 26 | #include <auto-config.h> |
---|
| 27 | #endif |
---|
| 28 | |
---|
| 29 | #include <libpq-fe.h> |
---|
| 30 | |
---|
| 31 | struct _pgsql_drv_storage |
---|
| 32 | { |
---|
| 33 | PGconn *dbh; /* database connection */ |
---|
| 34 | int pg_token_type; /* type of token */ |
---|
| 35 | |
---|
| 36 | struct _ds_spam_totals control_totals; /* totals at storage init */ |
---|
| 37 | struct _ds_spam_totals merged_totals; /* totals for merged group */ |
---|
| 38 | |
---|
| 39 | /* control token data; used to measure deltas from getall to setall |
---|
| 40 | * enabling us to code a sql query based on increments/decrements |
---|
| 41 | * instead of query-coded data */ |
---|
| 42 | |
---|
| 43 | unsigned long long control_token; /* control token crc */ |
---|
| 44 | long control_sh; /* control token spam hits at getall */ |
---|
| 45 | long control_ih; /* control token innocent hits at getall */ |
---|
| 46 | |
---|
| 47 | PGresult *iter_user; /* get_nextuser iteration result */ |
---|
| 48 | PGresult *iter_token; /* get_nexttoken iteration result */ |
---|
| 49 | PGresult *iter_sig; /* get_nextsignature iteration result */ |
---|
| 50 | |
---|
| 51 | char u_getnextuser[MAX_FILENAME_LENGTH]; |
---|
| 52 | struct passwd p_getpwuid; |
---|
| 53 | struct passwd p_getpwnam; |
---|
| 54 | int dbh_attached; |
---|
| 55 | }; |
---|
| 56 | |
---|
| 57 | /* Driver-specific functions */ |
---|
| 58 | |
---|
| 59 | int _pgsql_drv_get_spamtotals (DSPAM_CTX * CTX); |
---|
| 60 | int _pgsql_drv_set_spamtotals (DSPAM_CTX * CTX); |
---|
| 61 | void _pgsql_drv_query_error (const char *error, const char *query); |
---|
| 62 | int _pgsql_drv_token_type (struct _pgsql_drv_storage *s, PGresult *result, int column); |
---|
| 63 | char *_pgsql_drv_token_write (int type, unsigned long long token, char *buffer, size_t bufsz); |
---|
| 64 | unsigned long long _pgsql_drv_token_read(int type, char *str); |
---|
| 65 | PGconn *_pgsql_drv_connect (DSPAM_CTX *CTX); |
---|
| 66 | struct passwd *_pgsql_drv_getpwnam (DSPAM_CTX * CTX, const char *name); |
---|
| 67 | struct passwd *_pgsql_drv_getpwuid (DSPAM_CTX * CTX, uid_t uid); |
---|
| 68 | DSPAM_CTX *_pgsql_drv_init_tools( const char *home, config_t config, |
---|
| 69 | void *dbh, int mode); |
---|
| 70 | |
---|
| 71 | #ifdef VIRTUAL_USERS |
---|
| 72 | struct passwd *_pgsql_drv_setpwnam (DSPAM_CTX * CTX, const char *name); |
---|
| 73 | #endif |
---|
| 74 | |
---|
| 75 | #ifdef EXT_LOOKUP |
---|
| 76 | int verified_user; |
---|
| 77 | #endif |
---|
| 78 | |
---|
| 79 | #ifdef PREFERENCES_EXTENSION |
---|
| 80 | int _pgsql_drv_set_attributes(DSPAM_CTX *CTX, config_t config); |
---|
| 81 | #endif |
---|
| 82 | |
---|
| 83 | #endif /* _PGSQL_DRV_H */ |
---|