/[imapfilter]/imapfilter/filter.h
ViewVC logotype

Annotation of /imapfilter/filter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations)
Sat Feb 14 19:14:43 2004 UTC (20 years, 1 month ago) by lefcha
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +8 -7 lines
File MIME type: text/plain
Indentation.

1 lefcha 1.1 #ifndef FILTER_H
2     #define FILTER_H
3    
4 lefcha 1.4
5 lefcha 1.6 #include <sys/types.h> /* For POSIX.1-2001 non-conformant systems. */
6 lefcha 1.1 #include <regex.h>
7    
8     #include "account.h"
9    
10    
11     /*
12 lefcha 1.7 * Mode for masks that comprise a filter. So if a filter is of AND type then as
13     * default masks are ANDed.
14 lefcha 1.1 */
15 lefcha 1.5 #define FILTER_MODE_OR 1
16     #define FILTER_MODE_AND 2
17 lefcha 1.1
18     /* Action to do in case of filter matching. */
19 lefcha 1.5 #define ACTION_DELETE 1
20     #define ACTION_COPY 2
21     #define ACTION_MOVE 3
22     #define ACTION_RCOPY 4
23     #define ACTION_RMOVE 5
24     #define ACTION_FLAG_REPLACE 6
25     #define ACTION_FLAG_ADD 7
26     #define ACTION_FLAG_REMOVE 8
27     #define ACTION_LIST 9
28 lefcha 1.1
29     /* Message flags to replace/add/remove. */
30 lefcha 1.5 #define MSG_FLAG_NONE 0x00
31     #define MSG_FLAG_SEEN 0x01
32     #define MSG_FLAG_ANSWERED 0x02
33     #define MSG_FLAG_FLAGGED 0x04
34     #define MSG_FLAG_DELETED 0x08
35     #define MSG_FLAG_DRAFT 0x10
36 lefcha 1.1
37     /* Type of mask. This overrides the default filter mode (AND/OR). */
38 lefcha 1.5 #define MASK_TYPE_OR 1
39     #define MASK_TYPE_AND 2
40 lefcha 1.1
41     /* Type of mask match according to the four different regular expressions. */
42 lefcha 1.7 #define MASK_MATCH_1 1
43     #define MASK_MATCH_2 2
44     #define MASK_MATCH_3 3
45     #define MASK_MATCH_4 4
46 lefcha 1.1
47     /* String length of action's arguments. */
48 lefcha 1.5 #define ARGS_LEN 256
49 lefcha 1.1
50     /* String length of mask's body. */
51 lefcha 1.5 #define MASK_BODY_LEN 256
52 lefcha 1.1
53     /* Maximum filters assigned to a mailbox. */
54 lefcha 1.5 #define MBOX_FILTERS_MAX 64
55 lefcha 1.1
56    
57     /* Filter. */
58     typedef struct filter {
59     char key[KEY_LEN]; /* Alias of filter. */
60     unsigned int mode; /* AND/OR mode. */
61    
62     struct { /* What to do on filter match. */
63     unsigned int type; /* Action. */
64     account_t *raccount; /* Remote account to rcopy/rmove
65     * message. */
66 lefcha 1.5 char destmbox[MBOX_LEN]; /* Destination mailbox. */
67 lefcha 1.7 unsigned int msgflags; /* Message flags to
68     * replace/add/remove. */
69 lefcha 1.1 char args[ARGS_LEN]; /* Action's arguments. */
70     } action;
71    
72     struct mask *masks; /* Masks comprising the filter. */
73     unsigned int masknum; /* Total number of masks. */
74     unsigned int masklen; /* Total length of body of masks. */
75    
76     struct filter *left, *right; /* Left/right node of tree. */
77     } filter_t;
78    
79     /* Mask. */
80     typedef struct mask {
81     char body[MASK_BODY_LEN]; /* Body of mask. */
82     unsigned int type; /* AND/OR type. */
83     struct mask *next; /* Next node of linked list. */
84     } mask_t;
85    
86    
87     /* filter.c */
88     int set_filter(char *line, regmatch_t * match);
89     int set_action(char *line, regmatch_t * match);
90     int set_mask(char *line, regmatch_t * match, int mmt);
91     int set_job(char *line, regmatch_t * match);
92    
93    
94     #endif /* FILTER_H */

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26