Statistics
| Branch: | Tag: | Revision:

root / lib / filter.h @ 8d7dcace

History | View | Annotate | Download (3.24 KB)

1
/* filter.h */
2

    
3
#ifndef __FILTER_H__
4
#define __FILTER_H__
5

    
6
typedef enum {
7
        XF_CONTENT,
8
        XF_TEST
9
} XFilterType; 
10

    
11
typedef enum {
12
        XF_NOJUNK,
13
        XF_JUNK,
14
        XF_UNCERTAIN,
15
        XF_REWRITTEN,
16
        XF_NONE,
17
        XF_UNSUPPORTED_TYPE,
18
        XF_ERROR
19
} XFilterStatus;
20

    
21
typedef enum {
22
        XM_FROM,
23
        XM_TO,
24
        XM_CC,
25
        XM_SUBJECT,
26
} XMessageAttr;
27

    
28
typedef struct _XFilterManager        XFilterManager;
29
typedef struct _XFilter                XFilter;
30
typedef struct _XContentFilter        XContentFilter;
31
typedef struct _XTestFilter        XTestFilter;
32
typedef struct _XMessageData        XMessageData;
33
typedef struct _XFilterResult        XFilterResult;
34

    
35
#define XFILTER(f)                ((XFilter *)f)
36
#define X_CONTENT_FILTER(f)        ((XContentFilter *)f)
37
#define X_TEST_FILTER(f)        ((XTestFilter *)f)
38

    
39
typedef XFilter * (*XFilterConstructorFunc)        (void);
40

    
41
typedef XFilterStatus (*XContentFilterFunc)        (XFilter *filter,
42
                                                 const XMessageData *data,
43
                                                 XFilterResult *result);
44
typedef XFilterStatus (*XTestFilterFunc)        (XFilter *filter,
45
                                                 const XMessageData *data,
46
                                                 XFilterResult *result);
47

    
48

    
49
int         xfilter_init        (void);
50
void         xfilter_done        (void);
51

    
52
/* XFilter */
53

    
54
XFilter *xfilter_new        (XFilterType type, const char *name);
55
void         xfilter_free        (XFilter *filter);
56

    
57
XFilterType xfilter_get_type(XFilter *filter);
58
const char *xfilter_get_name(XFilter *filter);
59

    
60
void xfilter_set_input_mime_types(XFilter *filter, const char **types);
61
void xfilter_set_output_mime_type(XFilter *filter, const char *type);
62

    
63
/* XMessageData */
64

    
65
XMessageData *xfilter_message_data_new(const char *src, const char *mime_type);
66
XMessageData *xfilter_message_data_read_file(const char *file, const char *mime_type);
67
void         xfilter_message_data_free(XMessageData *msgdata);
68
void         xfilter_message_data_set_file(XMessageData *msgdata, const char *file);
69
void         xfilter_message_data_set_content(XMessageData *msgdata, char *content);
70
void         xfilter_message_data_set_attribute(XMessageData *msgdata, XMessageAttr attr, const char *value, int append);
71
void         xfilter_message_data_copy_attributes(XMessageData *msgdata, const XMessageData *srcdata);
72
const char *xfilter_message_data_get_mime_type(const XMessageData *msgdata);
73
const char *xfilter_message_data_get_file(const XMessageData *msgdata);
74
const char *xfilter_message_data_get_content(const XMessageData *msgdata);
75
const char *xfilter_message_data_get_attribute(const XMessageData *msgdata, XMessageAttr);
76

    
77
/* X*Filter */
78

    
79
void         xfilter_set_content_filter_func(XContentFilter *filter, XContentFilterFunc func);
80
void         xfilter_set_test_filter_func(XTestFilter *filter, XTestFilterFunc func);
81

    
82
XFilterStatus xfilter_exec(XFilter *filter, const XMessageData *msgdata, XFilterResult *result);
83

    
84
/* XFilterResult */
85

    
86
void         xfilter_result_print(XFilterResult *result);
87

    
88
XFilterResult *xfilter_result_new(void);
89
void xfilter_result_set_status(XFilterResult *result, XFilterStatus status);
90
void xfilter_result_set_message_data(XFilterResult *result, XMessageData *msgdata);
91
void xfilter_result_set_probability(XFilterResult *result, double prob);
92
XFilterStatus xfilter_result_get_status(XFilterResult *result);
93
XMessageData *xfilter_result_get_message_data(XFilterResult *result);
94
double xfilter_result_get_probability(XFilterResult *result);
95
void         xfilter_result_free(XFilterResult *result);
96

    
97
/* Utility functions */
98

    
99
void         xfilter_debug_print(const char *format, ...);
100

    
101
#endif /* __FILTER_H__ */