dovecot-2.0: Added mail_guid_128_to_string(). Used it in several...

dovecot at dovecot.org dovecot at dovecot.org
Thu Feb 18 08:20:25 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/5ec28d7a5d13
changeset: 10751:5ec28d7a5d13
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Feb 18 08:20:22 2010 +0200
description:
Added mail_guid_128_to_string(). Used it in several places.

diffstat:

 src/dsync/dsync-data.c         |  2 +-
 src/dsync/dsync-proxy.c        |  2 +-
 src/dsync/dsync-worker-local.c |  4 ++--
 src/dsync/test-dsync-common.c  |  6 ++++++
 src/imap/imap-status.c         |  3 +--
 src/lib-storage/mail-storage.h |  2 ++
 src/lib-storage/mail.c         |  5 +++++
 7 files changed, 18 insertions(+), 6 deletions(-)

diffs (101 lines):

diff -r 6936dbe28947 -r 5ec28d7a5d13 src/dsync/dsync-data.c
--- a/src/dsync/dsync-data.c	Thu Feb 18 07:51:44 2010 +0200
+++ b/src/dsync/dsync-data.c	Thu Feb 18 08:20:22 2010 +0200
@@ -107,7 +107,7 @@
 
 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 -r 6936dbe28947 -r 5ec28d7a5d13 src/dsync/dsync-proxy.c
--- a/src/dsync/dsync-proxy.c	Thu Feb 18 07:51:44 2010 +0200
+++ b/src/dsync/dsync-proxy.c	Thu Feb 18 08:20:22 2010 +0200
@@ -275,7 +275,7 @@
 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 -r 6936dbe28947 -r 5ec28d7a5d13 src/dsync/dsync-worker-local.c
--- a/src/dsync/dsync-worker-local.c	Thu Feb 18 07:51:44 2010 +0200
+++ b/src/dsync/dsync-worker-local.c	Thu Feb 18 08:20:22 2010 +0200
@@ -702,7 +702,7 @@
 	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 @@
 	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 -r 6936dbe28947 -r 5ec28d7a5d13 src/dsync/test-dsync-common.c
--- a/src/dsync/test-dsync-common.c	Thu Feb 18 07:51:44 2010 +0200
+++ b/src/dsync/test-dsync-common.c	Thu Feb 18 08:20:22 2010 +0200
@@ -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 @@
 
 	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 -r 6936dbe28947 -r 5ec28d7a5d13 src/imap/imap-status.c
--- a/src/imap/imap-status.c	Thu Feb 18 07:51:44 2010 +0200
+++ b/src/imap/imap-status.c	Thu Feb 18 08:20:22 2010 +0200
@@ -123,8 +123,7 @@
 	}
 	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 -r 6936dbe28947 -r 5ec28d7a5d13 src/lib-storage/mail-storage.h
--- a/src/lib-storage/mail-storage.h	Thu Feb 18 07:51:44 2010 +0200
+++ b/src/lib-storage/mail-storage.h	Thu Feb 18 08:20:22 2010 +0200
@@ -689,5 +689,7 @@
 				 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 -r 6936dbe28947 -r 5ec28d7a5d13 src/lib-storage/mail.c
--- a/src/lib-storage/mail.c	Thu Feb 18 07:51:44 2010 +0200
+++ b/src/lib-storage/mail.c	Thu Feb 18 08:20:22 2010 +0200
@@ -334,3 +334,8 @@
 	}
 	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);
+}


More information about the dovecot-cvs mailing list