Statistics
| Branch: | Tag: | Revision:

root / lib / filters / wordsep-filter.c @ 4012ec30

History | View | Annotate | Download (984 Bytes)

1
#include <glib.h>
2

    
3
#include "filter.h"
4
#include "wordsep-filter.h"
5

    
6

    
7
static char *do_wordsep(const char *content)
8
{
9
        return g_strdup(content);
10
}
11

    
12
static XFilterStatus xfilter_wordsep_func(XFilter *filter, const XMessageData *data, XMessageData **result)
13
{
14
        const char *mime_type;
15
        const char *content = NULL;
16
        char *processed_content;
17

    
18
        *result = NULL;
19

    
20
        mime_type = xfilter_message_data_get_mime_type(data);
21
        if (!mime_type)
22
                return XF_UNSUPPORTED_TYPE;
23

    
24
        if (!g_strncasecmp(mime_type, "text/", 5))
25
                content = xfilter_message_data_get_content(data);
26
        else
27
                return XF_UNSUPPORTED_TYPE;
28

    
29
        processed_content = do_wordsep(content);
30

    
31
        *result = xfilter_message_data_new(NULL, mime_type);
32
        xfilter_message_data_set_content(*result, processed_content);
33

    
34
        return XF_REWRITTEN;
35
}
36

    
37
XFilter *xfilter_wordsep_new(void)
38
{
39
        XFilter *filter;
40

    
41
        filter = xfilter_new(XF_CONTENT, "wordsep");
42
        xfilter_set_content_filter_func(X_CONTENT_FILTER(filter),
43
                                        xfilter_wordsep_func);
44

    
45
        return filter;
46
}