From: Timo Sirainen Date: Thu, 18 Feb 2010 06:20:22 +0000 (+0200) Subject: Added mail_guid_128_to_string(). Used it in several places. X-Git-Tag: 2.0.beta3~47 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=16aef418492cb8d18c5196fd573a487177a9cab2;p=thirdparty%2Fdovecot%2Fcore.git Added mail_guid_128_to_string(). Used it in several places. --HG-- branch : HEAD --- diff --git a/src/dsync/dsync-data.c b/src/dsync/dsync-data.c index 02648e121d..19f70cd674 100644 --- a/src/dsync/dsync-data.c +++ b/src/dsync/dsync-data.c @@ -107,7 +107,7 @@ int dsync_guid_cmp(const mailbox_guid_t *guid1, const mailbox_guid_t *guid2) const char *dsync_guid_to_str(const mailbox_guid_t *guid) { - return binary_to_hex(guid->guid, sizeof(guid->guid)); + return mail_guid_128_to_string(guid->guid); } const char *dsync_get_guid_128_str(const char *guid, unsigned char *dest, diff --git a/src/dsync/dsync-proxy.c b/src/dsync/dsync-proxy.c index caf400810c..dd6da9863d 100644 --- a/src/dsync/dsync-proxy.c +++ b/src/dsync/dsync-proxy.c @@ -275,7 +275,7 @@ int dsync_proxy_mailbox_import(pool_t pool, const char *str, void dsync_proxy_mailbox_guid_export(string_t *str, const mailbox_guid_t *mailbox) { - str_append(str, binary_to_hex(mailbox->guid, sizeof(mailbox->guid))); + str_append(str, dsync_guid_to_str(mailbox)); } int dsync_proxy_mailbox_guid_import(const char *str, mailbox_guid_t *guid_r) diff --git a/src/dsync/dsync-worker-local.c b/src/dsync/dsync-worker-local.c index e4afc0d3bd..f120b58eec 100644 --- a/src/dsync/dsync-worker-local.c +++ b/src/dsync/dsync-worker-local.c @@ -702,7 +702,7 @@ static int local_mailbox_open(struct local_dsync_worker *worker, lbox = hash_table_lookup(worker->mailbox_hash, guid); if (lbox == NULL) { i_error("Trying to open a non-listed mailbox with guid=%s", - binary_to_hex(guid->guid, sizeof(guid->guid))); + dsync_guid_to_str(guid)); return -1; } @@ -720,7 +720,7 @@ static int local_mailbox_open(struct local_dsync_worker *worker, if (memcmp(mailbox_guid, guid->guid, sizeof(guid->guid)) != 0) { i_error("Mailbox %s changed its GUID (%s -> %s)", lbox->storage_name, dsync_guid_to_str(guid), - binary_to_hex(mailbox_guid, sizeof(mailbox_guid))); + mail_guid_128_to_string(mailbox_guid)); mailbox_free(&box); return -1; } diff --git a/src/dsync/test-dsync-common.c b/src/dsync/test-dsync-common.c index 8db63db362..e3c831a00c 100644 --- a/src/dsync/test-dsync-common.c +++ b/src/dsync/test-dsync-common.c @@ -2,6 +2,7 @@ #include "lib.h" #include "array.h" +#include "hex-binary.h" #include "sha1.h" #include "dsync-data.h" #include "test-dsync-common.h" @@ -83,3 +84,8 @@ bool mail_guid_128_is_empty(const uint8_t guid_128[MAIL_GUID_128_SIZE]) return memcmp(empty_guid, guid_128, sizeof(empty_guid)) == 0; } + +const char *mail_guid_128_to_string(const uint8_t guid_128[MAIL_GUID_128_SIZE]) +{ + return binary_to_hex(guid_128, MAIL_GUID_128_SIZE); +} diff --git a/src/imap/imap-status.c b/src/imap/imap-status.c index 496ce037f6..3f41623868 100644 --- a/src/imap/imap-status.c +++ b/src/imap/imap-status.c @@ -123,8 +123,7 @@ void imap_status_send(struct client *client, const char *mailbox, } if (items->guid) { str_printfa(str, "X-GUID %s ", - binary_to_hex(result->mailbox_guid, - sizeof(result->mailbox_guid))); + mail_guid_128_to_string(result->mailbox_guid)); } if (items != 0) diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index 646f45eedc..dbc14b5eb3 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -689,5 +689,7 @@ void mail_generate_guid_128_hash(const char *guid, uint8_t guid_128[MAIL_GUID_128_SIZE]); /* Returns TRUE if GUID is empty (not set / unknown). */ bool mail_guid_128_is_empty(const uint8_t guid_128[MAIL_GUID_128_SIZE]); +/* Returns GUID as a hex string. */ +const char *mail_guid_128_to_string(const uint8_t guid_128[MAIL_GUID_128_SIZE]); #endif diff --git a/src/lib-storage/mail.c b/src/lib-storage/mail.c index c441a2a5f7..05e02a970d 100644 --- a/src/lib-storage/mail.c +++ b/src/lib-storage/mail.c @@ -334,3 +334,8 @@ bool mail_guid_128_is_empty(const uint8_t guid_128[MAIL_GUID_128_SIZE]) } return TRUE; } + +const char *mail_guid_128_to_string(const uint8_t guid_128[MAIL_GUID_128_SIZE]) +{ + return binary_to_hex(guid_128, MAIL_GUID_128_SIZE); +}