~ubuntu-branches/ubuntu/vivid/dovecot/vivid

« back to all changes in this revision

Viewing changes to src/lib-index/mail-transaction-util.c

  • Committer: Bazaar Package Importer
  • Author(s): Jaldhar H. Vyas
  • Date: 2005-11-05 23:19:19 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20051105231919-ydujs4y7687fpor2
Tags: upstream-1.0.alpha4
ImportĀ upstreamĀ versionĀ 1.0.alpha4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2004 Timo Sirainen */
 
2
 
 
3
#include "lib.h"
 
4
#include "buffer.h"
 
5
#include "mail-index-private.h"
 
6
#include "mail-transaction-log.h"
 
7
#include "mail-transaction-util.h"
 
8
 
 
9
const struct mail_transaction_type_map mail_transaction_type_map[] = {
 
10
        { MAIL_TRANSACTION_APPEND, MAIL_INDEX_SYNC_TYPE_APPEND,
 
11
          1 }, /* index-specific size, use 1 */
 
12
        { MAIL_TRANSACTION_EXPUNGE, MAIL_INDEX_SYNC_TYPE_EXPUNGE,
 
13
          sizeof(struct mail_transaction_expunge) },
 
14
        { MAIL_TRANSACTION_FLAG_UPDATE, MAIL_INDEX_SYNC_TYPE_FLAGS,
 
15
          sizeof(struct mail_transaction_flag_update) },
 
16
        { MAIL_TRANSACTION_HEADER_UPDATE, 0, 1 }, /* variable size, use 1 */
 
17
        { MAIL_TRANSACTION_EXT_INTRO, 0, 1 },
 
18
        { MAIL_TRANSACTION_EXT_RESET, 0,
 
19
          sizeof(struct mail_transaction_ext_reset) },
 
20
        { MAIL_TRANSACTION_EXT_HDR_UPDATE, 0, 1 },
 
21
        { MAIL_TRANSACTION_EXT_REC_UPDATE, 0, 1 },
 
22
        { MAIL_TRANSACTION_KEYWORD_UPDATE,
 
23
          MAIL_INDEX_SYNC_TYPE_KEYWORD_ADD |
 
24
          MAIL_INDEX_SYNC_TYPE_KEYWORD_REMOVE, 1 },
 
25
        { MAIL_TRANSACTION_KEYWORD_RESET,
 
26
          MAIL_INDEX_SYNC_TYPE_KEYWORD_RESET, 1 },
 
27
        { 0, 0, 0 }
 
28
};
 
29
 
 
30
const struct mail_transaction_type_map *
 
31
mail_transaction_type_lookup(enum mail_transaction_type type)
 
32
{
 
33
        int i;
 
34
 
 
35
        for (i = 0; mail_transaction_type_map[i].type != 0; i++) {
 
36
                if ((mail_transaction_type_map[i].type & type) != 0)
 
37
                        return &mail_transaction_type_map[i];
 
38
        }
 
39
        return NULL;
 
40
}
 
41
 
 
42
enum mail_transaction_type
 
43
mail_transaction_type_mask_get(enum mail_index_sync_type sync_type)
 
44
{
 
45
        enum mail_transaction_type type = 0;
 
46
        int i;
 
47
 
 
48
        for (i = 0; mail_transaction_type_map[i].type != 0; i++) {
 
49
                if ((mail_transaction_type_map[i].sync_type & sync_type) != 0)
 
50
                        type |= mail_transaction_type_map[i].type;
 
51
        }
 
52
        return type;
 
53
}