Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/plugins/trash/trash-plugin.c @ 4451:1a35d53c18fc HEAD
Array API redesigned to work using unions. It now provides type safety
without having to enable DEBUG, as long as the compiler supports typeof().
Its API changed a bit. It now allows directly accessing the array contents,
although that's not necessarily recommended. Changed existing array usage to
be type safe in a bit more places. Removed array_t completely. Also did
s/modifyable/modifiable/.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 28 Jun 2006 16:10:25 +0300 |
parents | 593523f53500 |
children | 511f1f5c76fa |
comparison
equal
deleted
inserted
replaced
4450:14b10f7ea70e | 4451:1a35d53c18fc |
---|---|
14 #include <fcntl.h> | 14 #include <fcntl.h> |
15 | 15 |
16 #define MAX_RETRY_COUNT 3 | 16 #define MAX_RETRY_COUNT 3 |
17 | 17 |
18 #define TRASH_CONTEXT(obj) \ | 18 #define TRASH_CONTEXT(obj) \ |
19 *((void **)array_idx_modifyable(&(obj)->quota_module_contexts, \ | 19 *((void **)array_idx_modifiable(&(obj)->quota_module_contexts, \ |
20 trash_quota_module_id)) | 20 trash_quota_module_id)) |
21 | 21 |
22 struct trash_quota_root { | 22 struct trash_quota_root { |
23 struct quota_backend_vfuncs super; | 23 struct quota_backend_vfuncs super; |
24 }; | 24 }; |
44 static void (*trash_next_hook_quota_root_created)(struct quota_root *root); | 44 static void (*trash_next_hook_quota_root_created)(struct quota_root *root); |
45 static unsigned int trash_quota_module_id; | 45 static unsigned int trash_quota_module_id; |
46 | 46 |
47 static pool_t config_pool; | 47 static pool_t config_pool; |
48 /* trash_boxes ordered by priority, highest first */ | 48 /* trash_boxes ordered by priority, highest first */ |
49 static array_t ARRAY_DEFINE(trash_boxes, struct trash_mailbox); | 49 static ARRAY_DEFINE(trash_boxes, struct trash_mailbox); |
50 | 50 |
51 static int trash_clean_mailbox_open(struct trash_mailbox *trash) | 51 static int trash_clean_mailbox_open(struct trash_mailbox *trash) |
52 { | 52 { |
53 struct mail_search_arg search_arg; | 53 struct mail_search_arg search_arg; |
54 | 54 |
94 unsigned int i, j, count, oldest_idx; | 94 unsigned int i, j, count, oldest_idx; |
95 time_t oldest, received; | 95 time_t oldest, received; |
96 uint64_t size; | 96 uint64_t size; |
97 int ret = 0; | 97 int ret = 0; |
98 | 98 |
99 trashes = array_get_modifyable(&trash_boxes, &count); | 99 trashes = array_get_modifiable(&trash_boxes, &count); |
100 for (i = 0; i < count; ) { | 100 for (i = 0; i < count; ) { |
101 /* expunge oldest mails first in all trash boxes with | 101 /* expunge oldest mails first in all trash boxes with |
102 same priority */ | 102 same priority */ |
103 oldest_idx = count; | 103 oldest_idx = count; |
104 oldest = (time_t)-1; | 104 oldest = (time_t)-1; |
249 trash->priority = atoi(t_strdup_until(line, name)); | 249 trash->priority = atoi(t_strdup_until(line, name)); |
250 } | 250 } |
251 i_stream_destroy(&input); | 251 i_stream_destroy(&input); |
252 (void)close(fd); | 252 (void)close(fd); |
253 | 253 |
254 qsort(array_get_modifyable(&trash_boxes, NULL), | 254 qsort(array_get_modifiable(&trash_boxes, NULL), |
255 array_count(&trash_boxes), sizeof(struct trash_mailbox), | 255 array_count(&trash_boxes), sizeof(struct trash_mailbox), |
256 trash_mailbox_priority_cmp); | 256 trash_mailbox_priority_cmp); |
257 return 0; | 257 return 0; |
258 } | 258 } |
259 | 259 |