[dovecot-cvs] dovecot/src/lib var-expand.c,1.10,1.11

cras at dovecot.org cras at dovecot.org
Wed Apr 12 10:39:34 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv1786/src/lib

Modified Files:
	var-expand.c 
Log Message:
%M modifier returns string's MD5 sum. Patch by Ben Winslow



Index: var-expand.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/var-expand.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- var-expand.c	12 Apr 2006 07:35:37 -0000	1.10
+++ var-expand.c	12 Apr 2006 07:39:32 -0000	1.11
@@ -1,7 +1,9 @@
 /* Copyright (C) 2003-2004 Timo Sirainen */
 
 #include "lib.h"
+#include "md5.h"
 #include "hash.h"
+#include "hex-binary.h"
 #include "str.h"
 #include "strescape.h"
 #include "var-expand.h"
@@ -76,6 +78,15 @@
 	return str_c(hash);
 }
 
+static const char *m_str_md5(const char *str, struct var_expand_context *ctx __attr_unused__)
+{
+	unsigned char digest[16];
+
+	md5_get_digest(str, strlen(str), digest);
+
+	return binary_to_hex(digest, sizeof(digest));
+}
+
 #define MAX_MODIFIER_COUNT 10
 static const struct var_expand_modifier modifiers[] = {
 	{ 'L', m_str_lcase },
@@ -84,6 +95,7 @@
 	{ 'X', m_str_hex },
 	{ 'R', m_str_reverse },
 	{ 'H', m_str_hash },
+	{ 'M', m_str_md5 },
 	{ '\0', NULL }
 };
 



More information about the dovecot-cvs mailing list