1 | /* $Id: diction.h,v 1.10 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 _DICTION_H |
---|
23 | # define _DICTION_H |
---|
24 | |
---|
25 | #include "nodetree.h" |
---|
26 | #include "libdspam_objects.h" |
---|
27 | |
---|
28 | typedef struct _ds_diction |
---|
29 | { |
---|
30 | unsigned long size; |
---|
31 | unsigned long items; |
---|
32 | struct _ds_term **tbl; |
---|
33 | |
---|
34 | unsigned long long whitelist_token; |
---|
35 | struct nt *order; |
---|
36 | struct nt *chained_order; |
---|
37 | } *ds_diction_t; |
---|
38 | |
---|
39 | typedef struct _ds_term |
---|
40 | { |
---|
41 | unsigned long long key; |
---|
42 | struct _ds_term *next; |
---|
43 | |
---|
44 | int frequency; |
---|
45 | struct _ds_spam_stat s; |
---|
46 | char *name; |
---|
47 | char type; |
---|
48 | |
---|
49 | } *ds_term_t; |
---|
50 | |
---|
51 | typedef struct _ds_diction_c |
---|
52 | { |
---|
53 | struct _ds_diction *diction; |
---|
54 | unsigned long iter_index; |
---|
55 | ds_term_t iter_next; |
---|
56 | } *ds_cursor_t; |
---|
57 | |
---|
58 | typedef unsigned long long ds_key_t; |
---|
59 | |
---|
60 | ds_diction_t ds_diction_create(unsigned long size); |
---|
61 | void ds_diction_destroy(ds_diction_t diction); |
---|
62 | |
---|
63 | ds_term_t ds_diction_term_create(ds_key_t key, const char *name); |
---|
64 | ds_term_t ds_diction_find(ds_diction_t diction, ds_key_t key); |
---|
65 | ds_term_t ds_diction_touch(ds_diction_t diction, ds_key_t key, |
---|
66 | const char *name, int flags); |
---|
67 | void ds_diction_delete(ds_diction_t diction, ds_key_t key); |
---|
68 | int ds_diction_setstat(ds_diction_t diction, ds_key_t key, ds_spam_stat_t s); |
---|
69 | int ds_diction_addstat(ds_diction_t diction, ds_key_t key, ds_spam_stat_t s); |
---|
70 | int ds_diction_getstat(ds_diction_t diction, ds_key_t key, ds_spam_stat_t s); |
---|
71 | |
---|
72 | ds_cursor_t ds_diction_cursor(ds_diction_t diction); |
---|
73 | ds_term_t ds_diction_next(ds_cursor_t cur); |
---|
74 | void ds_diction_close(ds_cursor_t cur); |
---|
75 | |
---|
76 | #define DSD_CHAINED 0x01 |
---|
77 | #define DSD_CONTEXT 0x02 |
---|
78 | |
---|
79 | #endif /* _DICTION_H */ |
---|