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

Annotation of /imapfilter/data.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (hide annotations)
Fri Feb 8 22:15:43 2002 UTC (22 years, 2 months ago) by lefcha
Branch: MAIN
Changes since 1.16: +0 -2 lines
File MIME type: text/plain
Allow ssl appear in config file, but fail with error message.

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

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26