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

Annotation of /imapfilter/data.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (hide annotations)
Fri Nov 9 15:50:30 2001 UTC (22 years, 5 months ago) by lefcha
Branch: MAIN
Changes since 1.11: +3 -3 lines
File MIME type: text/plain
Variable size and naming changes.

1 lefcha 1.1 #ifndef DATA_H
2     #define DATA_H
3    
4 lefcha 1.8 #include <sys/types.h>
5 lefcha 1.1 #include <regex.h>
6    
7     /* String lengths of account settings. */
8 lefcha 1.7 #define SERVER_LEN (635 + 1) /* Section 2.5 RFC 1123. */
9 lefcha 1.12 #define USERNAME_LEN 128
10     #define PASSWORD_LEN 128
11 lefcha 1.1
12 lefcha 1.9 #ifdef SSL_TLS
13     /* Secure Socket Layer protocols. */
14     #define SSL_DISABLED 0
15     #define SSL_SSL_V2 1
16     #define SSL_SSL_V3 2
17     #define SSL_TLS_V1 3
18     #endif
19    
20 lefcha 1.1 /* String length of keys (aliases). */
21 lefcha 1.7 #define KEY_LEN 32
22 lefcha 1.1
23     /* String length of action's arguments. */
24 lefcha 1.7 #define ARGS_LEN 256
25 lefcha 1.1
26     /* String length of mailbox's name. */
27 lefcha 1.7 #define MBOX_NAME_LEN 128
28 lefcha 1.1
29     /* String length of mask's body. */
30 lefcha 1.7 #define MASK_BODY_LEN 256
31 lefcha 1.1
32     /* Maximum filters assigned to a mailbox. */
33 lefcha 1.12 #define MBOX_FILTERS_MAX 64
34 lefcha 1.1
35     /* Maximum mailboxes contained in a mailbox-group. */
36 lefcha 1.7 #define MBOXGRP_MBOXES_MAX 64
37 lefcha 1.1
38 lefcha 1.5 /*
39 lefcha 1.1 * Mode for masks that comprise a filter. So if a filter is of AND type then
40     * as default masks are ANDed.
41     */
42 lefcha 1.7 #define FILTER_MODE_OR 1
43     #define FILTER_MODE_AND 2
44 lefcha 1.1
45     /* Action to do in case of filter matching. */
46 lefcha 1.7 #define FILTER_ACTION_DELETE 1
47     #define FILTER_ACTION_COPY 2
48     #define FILTER_ACTION_MOVE 3
49     #define FILTER_ACTION_LIST 4
50 lefcha 1.1
51 lefcha 1.9 /* Type of mask. This overrides the default filter mode (AND/OR). */
52 lefcha 1.7 #define MASK_TYPE_OR 1
53     #define MASK_TYPE_AND 2
54 lefcha 1.1
55    
56     /*
57     * Find last node of linked list and append at the end of the list the
58     * supplied node.
59     */
60     #define APPEND_LINKED_LIST(f, n, p, a) \
61     a = &f; \
62     p = f; \
63     while (p) { \
64     a = &(p->next); \
65     p = p->next; \
66     } \
67     *a = n;
68    
69     /*
70 lefcha 1.5 * Find, based on the key of the supplied node, the apropriate position for it
71 lefcha 1.9 * in the tree, and then insert it there.
72 lefcha 1.1 */
73     #define INSERT_TREE(r, n, p, i, c) \
74     i = &r; \
75     p = r; \
76     while (p) { \
77     c = strncmp(n->key, p->key, KEY_LEN); \
78     if (c < 0) { \
79     i = &(p->left); \
80     p = p->left; \
81     } else if (c > 0) { \
82     i = &(p->right); \
83     p = p->right; \
84     } else \
85     return; \
86     } \
87     *i = n;
88    
89     /*
90     * Find, based on the supplied key, the position of a node, and return a
91     * pointer directing to that node.
92     */
93     #define FIND_TREE(r, k, p, c) \
94     p = r; \
95     while (p) { \
96     c = strncmp(k, p->key, KEY_LEN); \
97     if (c < 0) \
98     p = p->left; \
99     else if (c > 0) \
100     p = p->right; \
101     else \
102     return p; \
103     } \
104     return NULL;
105    
106 lefcha 1.7 #define create_node(A) xmalloc(A)
107 lefcha 1.5
108 lefcha 1.1
109     /* Account. */
110     typedef struct account_t {
111 lefcha 1.5 char server[SERVER_LEN]; /* Hostname of mail server. */
112     unsigned short int port; /* Port to connect. */
113    
114     char username[USERNAME_LEN];/* Username. */
115     char password[PASSWORD_LEN];/* Password. */
116 lefcha 1.10 #ifdef SSL_TLS
117 lefcha 1.9 unsigned int ssl; /* Secure Socket Layer support. */
118     #endif
119 lefcha 1.5 struct mbox_t *mboxes; /* Mailboxes. */
120     struct account_t *next; /* Next node of linked list. */
121 lefcha 1.1 } account_t;
122    
123     /* Mailbox. */
124     typedef struct mbox_t {
125 lefcha 1.5 char name[MBOX_NAME_LEN]; /* Name of mailbox. */
126 lefcha 1.1 struct filter_t *filters[MBOX_FILTERS_MAX]; /* Filters to be applied. */
127 lefcha 1.5 struct mbox_t *next; /* Next node of linked list. */
128 lefcha 1.1 } mbox_t;
129    
130     /* Group of mailboxes. */
131     typedef struct mboxgrp_t {
132 lefcha 1.5 char key[KEY_LEN]; /* Alias of mailbox group. */
133 lefcha 1.1 struct mbox_t *mboxes[MBOXGRP_MBOXES_MAX]; /* Mailboxes of group. */
134 lefcha 1.5 struct mboxgrp_t *left, *right; /* Left/right nodes of tree. */
135 lefcha 1.1 } mboxgrp_t;
136    
137     /* Filter. */
138     typedef struct filter_t {
139     char key[KEY_LEN]; /* Alias of filter. */
140     unsigned int mode; /* AND/OR mode. */
141    
142 lefcha 1.5 struct { /* What to do on filter match. */
143     unsigned int type; /* Action. */
144     char destmbox[MBOX_NAME_LEN]; /* Destination mailbox. */
145     char args[ARGS_LEN]; /* Action's arguments. */
146 lefcha 1.1 } action;
147    
148 lefcha 1.5 struct mask_t *masks; /* Masks comprising the filter. */
149     unsigned int masknum; /* Total number of masks. */
150     unsigned int masklen; /* Total length of body of masks. */
151    
152 lefcha 1.1 struct filter_t *left, *right; /* Left/right node of tree. */
153     } filter_t;
154    
155     /* Mask. */
156     typedef struct mask_t {
157     char body[MASK_BODY_LEN]; /* Body of mask. */
158     unsigned int type; /* AND/OR type. */
159     struct mask_t *next; /* Next node of linked list. */
160     } mask_t;
161    
162    
163     /* data.c */
164     void init_account(account_t * node);
165     void append_account(account_t * node);
166     int set_account(char *line, regmatch_t * match);
167    
168     void init_mboxgrp(mboxgrp_t * node);
169     void ins_mboxgrp(mboxgrp_t * node);
170     int set_mboxgrp(char *line, regmatch_t * match);
171     void process_mboxgrp(mboxgrp_t * node, char *mboxs);
172     mboxgrp_t *find_mboxgrp(char *key);
173    
174     void init_mbox(mbox_t * node);
175     void append_mbox(mbox_t * node);
176     mbox_t *set_mbox(char *name);
177    
178     void init_filter(filter_t * node);
179     void ins_filter(filter_t * node);
180     int set_filter(char *line, regmatch_t * match);
181     filter_t *find_filter(char *key);
182 lefcha 1.4 int set_action(char *line, regmatch_t * match);
183 lefcha 1.1
184     void init_mask(mask_t * node);
185     void append_mask(mask_t * node);
186     int set_mask(char *line, regmatch_t * match);
187 lefcha 1.10 void convert_date(mask_t * node);
188 lefcha 1.1
189     int set_job(char *line, regmatch_t * match);
190 lefcha 1.4 void link_mbox_filter(filter_t * cf, mboxgrp_t * cg);
191 lefcha 1.1
192 lefcha 1.3 void destroy_data(void);
193 lefcha 1.1 void destroy_mboxgrp(mboxgrp_t * node);
194 lefcha 1.11 void overwrite_password(char *passwd);
195 lefcha 1.1
196 lefcha 1.4 void string_upper(char *str, size_t size);
197 lefcha 1.6 int string_decode(char *str);
198 lefcha 1.3
199 lefcha 1.5 #endif /* DATA_H */

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26