File: libdspam.h

package info (click to toggle)
dspam 3.10.1+dfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,656 kB
  • sloc: ansic: 26,034; sh: 12,546; perl: 5,469; makefile: 690; sql: 379
file content (106 lines) | stat: -rw-r--r-- 3,372 bytes parent folder | download
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* $Id: libdspam.h,v 1.27 2011/06/28 00:13:48 sbajic Exp $ */

/*
 DSPAM
 COPYRIGHT (C) 2002-2011 DSPAM PROJECT

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as
 published by the Free Software Foundation, either version 3 of the
 License, 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 Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

#ifdef __cplusplus
extern "C" {
#endif

#ifdef HAVE_CONFIG_H
#include <auto-config.h>
#endif

#ifndef _LIBDSPAM_H
#  define _LIBDSPAM_H

#include "diction.h"
#include "nodetree.h"
#include "error.h"
#include "storage_driver.h"
#include "decode.h"
#include "libdspam_objects.h"
#include "heap.h"
#include "tokenizer.h"

#define LIBDSPAM_VERSION_MAJOR	3
#define LIBDSPAM_VERSION_MINOR	6
#define LIBDSPAM_VERSION_PATCH	0

#define BNR_SIZE 3

/* Public API */

int libdspam_init(const char *);
int libdspam_shutdown(void);

DSPAM_CTX * dspam_init	(const char *username, const char *group,
            const char *home, int operating_mode, u_int32_t flags);

DSPAM_CTX * dspam_create (const char *username, const char *group,
            const char *home, int operating_mode, u_int32_t flags);

int dspam_attach  (DSPAM_CTX *CTX, void *dbh);
int dspam_detach  (DSPAM_CTX *CTX);
int dspam_process (DSPAM_CTX * CTX, const char *message);

int dspam_getsource       (DSPAM_CTX * CTX, char *buf, size_t size);
int dspam_addattribute    (DSPAM_CTX * CTX, const char *key, const char *value);
int dspam_clearattributes (DSPAM_CTX * CTX);

void dspam_destroy        (DSPAM_CTX * CTX);


/* Private functions */

int _ds_calc_stat (DSPAM_CTX * CTX, ds_term_t term, struct _ds_spam_stat *s,
     int type, struct _ds_spam_stat *bnr_tot);
int _ds_calc_result (DSPAM_CTX * CTX, ds_heap_t sort, ds_diction_t diction); 
int _ds_increment_tokens(DSPAM_CTX *CTX, ds_diction_t diction);
int  _ds_operate               (DSPAM_CTX * CTX, char *headers, char *body);
int  _ds_process_signature     (DSPAM_CTX * CTX);
int  _ds_factor                (struct nt *set, char *token_name, float value);
int _ds_instantiate_bnr        (DSPAM_CTX *CTX, ds_diction_t patterns, 
    struct nt *order, char identifier);
ds_diction_t _ds_apply_bnr (DSPAM_CTX *CTX, ds_diction_t diction);
void _ds_factor_destroy        (struct nt *factors);


/* Standard Return Codes */

#ifndef EINVAL
#       define EINVAL                   -0x01
  /* Invalid call or parms - already initialized or shutdown */
#endif
#define EUNKNOWN                -0x02   /* Unknown/unexpected error */
#define EFILE                   -0x03   /* File error */
#define ELOCK                   -0x04   /* Lock error */
#define EFAILURE                -0x05   /* Failed to perform operation */

#define FALSE_POSITIVE(A) \
  (A->classification == DSR_ISINNOCENT && A->source == DSS_ERROR)
#define SPAM_MISS(A) \
  (A->classification == DSR_ISSPAM && A->source == DSS_ERROR)
#define SIGNATURE_NULL(A)	(A->signature == NULL)

#endif /* _LIBDSPAM_H */

#ifdef __cplusplus
}
#endif