1
/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */
5
#include "hex-binary.h"
7
#include "dsync-data.h"
8
#include "test-dsync-common.h"
10
const guid_128_t test_mailbox_guid1 = {
11
0x12, 0x34, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
12
0x21, 0x43, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe
15
const guid_128_t test_mailbox_guid2 = {
16
0xa3, 0xbd, 0x78, 0x24, 0xde, 0xfe, 0x08, 0xf7,
17
0xac, 0xc7, 0xca, 0x8c, 0xe7, 0x39, 0xdb, 0xca
20
bool dsync_messages_equal(const struct dsync_message *m1,
21
const struct dsync_message *m2)
25
if (strcmp(m1->guid, m2->guid) != 0 ||
26
m1->uid != m2->uid || m1->flags != m2->flags ||
27
m1->modseq != m2->modseq || m1->save_date != m2->save_date)
30
if (m1->keywords == m2->keywords)
32
if (m1->keywords == NULL)
33
return m2->keywords == NULL || m2->keywords[0] == NULL;
34
if (m2->keywords == NULL)
35
return m1->keywords[0] == NULL;
37
for (i = 0; m1->keywords[i] != NULL && m2->keywords[i] != NULL; i++) {
38
if (strcasecmp(m1->keywords[i], m2->keywords[i]) != 0)
41
return m1->keywords[i] == NULL && m2->keywords[i] == NULL;
44
bool dsync_mailboxes_equal(const struct dsync_mailbox *box1,
45
const struct dsync_mailbox *box2)
47
const struct mailbox_cache_field *f1 = NULL, *f2 = NULL;
48
unsigned int i, f1_count = 0, f2_count = 0;
50
if (strcmp(box1->name, box2->name) != 0 ||
51
box1->name_sep != box2->name_sep ||
52
memcmp(box1->mailbox_guid.guid, box2->mailbox_guid.guid,
53
sizeof(box1->mailbox_guid.guid)) != 0 ||
54
box1->uid_validity != box2->uid_validity ||
55
box1->uid_next != box2->uid_next ||
56
box1->highest_modseq != box2->highest_modseq)
59
if (array_is_created(&box1->cache_fields))
60
f1 = array_get(&box1->cache_fields, &f1_count);
61
if (array_is_created(&box2->cache_fields))
62
f2 = array_get(&box2->cache_fields, &f2_count);
63
if (f1_count != f2_count)
65
for (i = 0; i < f1_count; i++) {
66
if (strcmp(f1[i].name, f2[i].name) != 0 ||
67
f1[i].decision != f2[i].decision ||
68
f1[i].last_used != f2[i].last_used)
74
void mail_generate_guid_128_hash(const char *guid, guid_128_t guid_128_r)
76
unsigned char sha1_sum[SHA1_RESULTLEN];
78
sha1_get_digest(guid, strlen(guid), sha1_sum);
79
memcpy(guid_128_r, sha1_sum, GUID_128_SIZE);