Statistics
| Branch: | Tag: | Revision:

root / lib / filter.h @ 4012ec30

History | View | Annotate | Download (2.33 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 struct _XFilterManager        XFilterManager;
22
typedef struct _XFilter                XFilter;
23
typedef struct _XContentFilter        XContentFilter;
24
typedef struct _XTestFilter        XTestFilter;
25
typedef struct _XMessageData        XMessageData;
26
typedef struct _XFilterResult        XFilterResult;
27

    
28
#define XFILTER(f)                ((XFilter *)f)
29
#define X_CONTENT_FILTER(f)        ((XContentFilter *)f)
30
#define X_TEST_FILTER(f)        ((XTestFilter *)f)
31

    
32
typedef XFilter * (*XFilterConstructorFunc)        (void);
33

    
34
typedef XFilterStatus (*XContentFilterFunc)        (XFilter *filter,
35
                                                 const XMessageData *data,
36
                                                 XMessageData **result);
37
typedef XFilterStatus (*XTestFilterFunc)        (XFilter *filter,
38
                                                 const XMessageData *data);
39

    
40

    
41
int         xfilter_init        (void);
42
void         xfilter_done        (void);
43

    
44
/* XFilter */
45

    
46
XFilter *xfilter_new        (XFilterType type, const char *name);
47
void         xfilter_free        (XFilter *filter);
48

    
49
XFilterType xfilter_get_type(XFilter *filter);
50
const char *xfilter_get_name(XFilter *filter);
51

    
52
void xfilter_set_input_mime_types(XFilter *filter, const char **types);
53
void xfilter_set_output_mime_type(XFilter *filter, const char *type);
54

    
55
/* XMessageData */
56

    
57
XMessageData *xfilter_message_data_new(const char *src, const char *mime_type);
58
void         xfilter_message_data_free(XMessageData *msgdata);
59
void         xfilter_message_data_set_content(XMessageData *msgdata, char *content);
60
const char *xfilter_message_data_get_mime_type(const XMessageData *msgdata);
61
const char *xfilter_message_data_get_content(const XMessageData *msgdata);
62

    
63
/* X*Filter */
64

    
65
void         xfilter_set_content_filter_func(XContentFilter *filter, XContentFilterFunc func);
66
void         xfilter_set_test_filter_func(XTestFilter *filter, XTestFilterFunc func);
67

    
68
XFilterStatus xfilter_exec(XFilter *filter, const XMessageData *msgdata, XMessageData **retdata);
69

    
70
/* XFilterResult */
71

    
72
void         xfilter_result_print(XFilterResult *result);
73

    
74
XFilterResult *xfilter_result_new(void);
75
XFilterStatus xfilter_result_get_status(XFilterResult *result);
76
XMessageData *xfiltrer_result_get_message_data(XFilterResult *result);
77
void         xfilter_result_free(XFilterResult *result);
78

    
79
/* Utility functions */
80

    
81
void         xfilter_debug_print(const char *format, ...);
82

    
83
#endif /* __FILTER_H__ */