26 |
/* Maximum mailboxes contained in a mailbox-group. */ |
/* Maximum mailboxes contained in a mailbox-group. */ |
27 |
#define MBOXGRP_MBOXES_MAX 64 |
#define MBOXGRP_MBOXES_MAX 64 |
28 |
|
|
29 |
/* |
/* |
30 |
* Mode for masks that comprise a filter. So if a filter is of AND type then |
* Mode for masks that comprise a filter. So if a filter is of AND type then |
31 |
* as default masks are ANDed. |
* as default masks are ANDed. |
32 |
*/ |
*/ |
58 |
*a = n; |
*a = n; |
59 |
|
|
60 |
/* |
/* |
61 |
* Find, based on the key of the supplied node, the apropriate position for it |
* Find, based on the key of the supplied node, the apropriate position for it |
62 |
* in the tree, and the insert it there. |
* in the tree, and the insert it there. |
63 |
*/ |
*/ |
64 |
#define INSERT_TREE(r, n, p, i, c) \ |
#define INSERT_TREE(r, n, p, i, c) \ |
94 |
} \ |
} \ |
95 |
return NULL; |
return NULL; |
96 |
|
|
97 |
|
#define create_node(A) xmalloc(A) |
98 |
|
|
99 |
|
|
100 |
/* Account. */ |
/* Account. */ |
101 |
typedef struct account_t { |
typedef struct account_t { |
102 |
char server[SERVER_LEN]; /* Hostname of mail server. */ |
char server[SERVER_LEN]; /* Hostname of mail server. */ |
103 |
unsigned short int port; /* Port to connect. */ |
unsigned short int port; /* Port to connect. */ |
104 |
|
|
105 |
|
char username[USERNAME_LEN];/* Username. */ |
106 |
|
char password[PASSWORD_LEN];/* Password. */ |
107 |
|
|
108 |
char username[USERNAME_LEN]; /* Username. */ |
struct mbox_t *mboxes; /* Mailboxes. */ |
109 |
char password[PASSWORD_LEN]; /* Password. */ |
struct account_t *next; /* Next node of linked list. */ |
|
|
|
|
struct mbox_t *mboxes; /* Mailboxes. */ |
|
|
struct account_t *next; /* Next node of linked list. */ |
|
110 |
} account_t; |
} account_t; |
111 |
|
|
112 |
/* Mailbox. */ |
/* Mailbox. */ |
113 |
typedef struct mbox_t { |
typedef struct mbox_t { |
114 |
char name[MBOX_NAME_LEN]; /* Name of mailbox. */ |
char name[MBOX_NAME_LEN]; /* Name of mailbox. */ |
115 |
struct filter_t *filters[MBOX_FILTERS_MAX]; /* Filters to be applied. */ |
struct filter_t *filters[MBOX_FILTERS_MAX]; /* Filters to be applied. */ |
116 |
struct mbox_t *next; /* Next node of linked list. */ |
struct mbox_t *next; /* Next node of linked list. */ |
117 |
} mbox_t; |
} mbox_t; |
118 |
|
|
119 |
/* Group of mailboxes. */ |
/* Group of mailboxes. */ |
120 |
typedef struct mboxgrp_t { |
typedef struct mboxgrp_t { |
121 |
char key[KEY_LEN]; /* Alias of mailbox group. */ |
char key[KEY_LEN]; /* Alias of mailbox group. */ |
122 |
struct mbox_t *mboxes[MBOXGRP_MBOXES_MAX]; /* Mailboxes of group. */ |
struct mbox_t *mboxes[MBOXGRP_MBOXES_MAX]; /* Mailboxes of group. */ |
123 |
struct mboxgrp_t *left, *right; /* Left/right nodes of tree. */ |
struct mboxgrp_t *left, *right; /* Left/right nodes of tree. */ |
124 |
} mboxgrp_t; |
} mboxgrp_t; |
125 |
|
|
126 |
/* Filter. */ |
/* Filter. */ |
128 |
char key[KEY_LEN]; /* Alias of filter. */ |
char key[KEY_LEN]; /* Alias of filter. */ |
129 |
unsigned int mode; /* AND/OR mode. */ |
unsigned int mode; /* AND/OR mode. */ |
130 |
|
|
131 |
struct { /* What to do on filter match. */ |
struct { /* What to do on filter match. */ |
132 |
unsigned int type; /* Action. */ |
unsigned int type; /* Action. */ |
133 |
char destmbox[MBOX_NAME_LEN]; /* Destination mailbox. */ |
char destmbox[MBOX_NAME_LEN]; /* Destination mailbox. */ |
134 |
char args[ARGS_LEN]; /* Action's arguments. */ |
char args[ARGS_LEN]; /* Action's arguments. */ |
135 |
} action; |
} action; |
136 |
|
|
137 |
struct mask_t *masks; /* Masks comprising the filter. */ |
struct mask_t *masks; /* Masks comprising the filter. */ |
138 |
unsigned int masknum; /* Total number of masks. */ |
unsigned int masknum; /* Total number of masks. */ |
139 |
unsigned int masklen; /* Total length of body of masks. */ |
unsigned int masklen; /* Total length of body of masks. */ |
140 |
|
|
141 |
struct filter_t *left, *right; /* Left/right node of tree. */ |
struct filter_t *left, *right; /* Left/right node of tree. */ |
142 |
} filter_t; |
} filter_t; |
143 |
|
|
150 |
|
|
151 |
|
|
152 |
/* data.c */ |
/* data.c */ |
|
void *create_node(size_t size); |
|
|
|
|
153 |
void init_account(account_t * node); |
void init_account(account_t * node); |
154 |
void append_account(account_t * node); |
void append_account(account_t * node); |
155 |
int set_account(char *line, regmatch_t * match); |
int set_account(char *line, regmatch_t * match); |
182 |
|
|
183 |
void string_upper(char *str, size_t size); |
void string_upper(char *str, size_t size); |
184 |
|
|
185 |
#endif /* DATA_H */ |
#endif /* DATA_H */ |