dovecot-2.0: mail_generate_guid_128_hash() is now a public funct...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jul 16 01:32:05 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/54f84f569ca0
changeset: 9636:54f84f569ca0
user: Timo Sirainen <tss at iki.fi>
date: Wed Jul 15 18:29:42 2009 -0400
description:
mail_generate_guid_128_hash() is now a public function.
diffstat:
4 files changed, 23 insertions(+), 19 deletions(-)
src/lib-storage/mail-storage-private.h | 2 --
src/lib-storage/mail-storage.c | 11 -----------
src/lib-storage/mail-storage.h | 6 ++++++
src/lib-storage/mail.c | 23 +++++++++++++++++------
diffs (91 lines):
diff -r c8be44ff1090 -r 54f84f569ca0 src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h Wed Jul 15 18:29:21 2009 -0400
+++ b/src/lib-storage/mail-storage-private.h Wed Jul 15 18:29:42 2009 -0400
@@ -429,8 +429,6 @@ bool mail_storage_set_error_from_errno(s
const char *mail_generate_guid_string(void);
void mail_generate_guid_128(uint8_t guid[MAIL_GUID_128_SIZE]);
-void mail_generate_guid_128_hash(const char *input,
- uint8_t guid[MAIL_GUID_128_SIZE]);
int mail_set_aborted(struct mail *mail);
void mail_set_expunged(struct mail *mail);
void mailbox_set_deleted(struct mailbox *box);
diff -r c8be44ff1090 -r 54f84f569ca0 src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c Wed Jul 15 18:29:21 2009 -0400
+++ b/src/lib-storage/mail-storage.c Wed Jul 15 18:29:42 2009 -0400
@@ -1073,17 +1073,6 @@ void mailbox_set_deleted(struct mailbox
box->mailbox_deleted = TRUE;
}
-bool mail_guid_128_is_empty(const uint8_t guid_128[MAIL_GUID_128_SIZE])
-{
- unsigned int i;
-
- for (i = 0; i < MAILBOX_GUID_SIZE; i++) {
- if (guid_128[i] != 0)
- return FALSE;
- }
- return TRUE;
-}
-
bool mailbox_guid_is_empty(const uint8_t guid[MAILBOX_GUID_SIZE])
{
return mail_guid_128_is_empty(guid);
diff -r c8be44ff1090 -r 54f84f569ca0 src/lib-storage/mail-storage.h
--- a/src/lib-storage/mail-storage.h Wed Jul 15 18:29:21 2009 -0400
+++ b/src/lib-storage/mail-storage.h Wed Jul 15 18:29:42 2009 -0400
@@ -642,4 +642,10 @@ void mail_expunge(struct mail *mail);
/* Mark a cached field corrupted and have it recalculated. */
void mail_set_cache_corrupted(struct mail *mail, enum mail_fetch_field field);
+/* Return 128 bit GUID using input string. If guid is already 128 bit hex
+ encoded, it's returned as-is. Otherwise SHA1 sum is taken and its last
+ 128 bits are returned. */
+void mail_generate_guid_128_hash(const char *guid,
+ uint8_t guid_128[MAIL_GUID_128_SIZE]);
+
#endif
diff -r c8be44ff1090 -r 54f84f569ca0 src/lib-storage/mail.c
--- a/src/lib-storage/mail.c Wed Jul 15 18:29:21 2009 -0400
+++ b/src/lib-storage/mail.c Wed Jul 15 18:29:42 2009 -0400
@@ -280,19 +280,19 @@ void mail_generate_guid_128(uint8_t guid
memcpy(guid + 8, guid_static, 8);
}
-void mail_generate_guid_128_hash(const char *input,
- uint8_t guid[MAIL_GUID_128_SIZE])
+void mail_generate_guid_128_hash(const char *guid,
+ uint8_t guid_128[MAIL_GUID_128_SIZE])
{
unsigned char sha1_sum[SHA1_RESULTLEN];
buffer_t buf;
- buffer_create_data(&buf, guid, MAIL_GUID_128_SIZE);
- if (strlen(input) != MAIL_GUID_128_SIZE*2 ||
- hex_to_binary(input, &buf) < 0 ||
+ buffer_create_data(&buf, guid_128, MAIL_GUID_128_SIZE);
+ if (strlen(guid) != MAIL_GUID_128_SIZE*2 ||
+ hex_to_binary(guid, &buf) < 0 ||
buf.used != MAIL_GUID_128_SIZE) {
/* not 128bit hex. use a hash of it instead. */
buffer_set_used_size(&buf, 0);
- sha1_get_digest(input, strlen(input), sha1_sum);
+ sha1_get_digest(guid, strlen(guid), sha1_sum);
#if SHA1_RESULTLEN < DBOX_GUID_BIN_LEN
# error not possible
#endif
@@ -301,3 +301,14 @@ void mail_generate_guid_128_hash(const c
MAIL_GUID_128_SIZE);
}
}
+
+bool mail_guid_128_is_empty(const uint8_t guid_128[MAIL_GUID_128_SIZE])
+{
+ unsigned int i;
+
+ for (i = 0; i < MAILBOX_GUID_SIZE; i++) {
+ if (guid_128[i] != 0)
+ return FALSE;
+ }
+ return TRUE;
+}
More information about the dovecot-cvs
mailing list