dovecot-1.1: Added var_has_key().

dovecot at dovecot.org dovecot at dovecot.org
Sat Oct 25 16:07:35 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/f957853df4c2
changeset: 7967:f957853df4c2
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Oct 25 15:19:31 2008 +0300
description:
Added var_has_key().

diffstat:

2 files changed, 14 insertions(+)
src/lib/var-expand.c |   12 ++++++++++++
src/lib/var-expand.h |    2 ++

diffs (34 lines):

diff -r 2a7368d692ae -r f957853df4c2 src/lib/var-expand.c
--- a/src/lib/var-expand.c	Sat Oct 25 15:17:46 2008 +0300
+++ b/src/lib/var-expand.c	Sat Oct 25 15:19:31 2008 +0300
@@ -283,6 +283,18 @@ char var_get_key(const char *str)
 	return *str;
 }
 
+bool var_has_key(const char *str, char key)
+{
+	for (; *str != '\0'; str++) {
+		if (*str == '%' && str[1] != '\0') {
+			str++;
+			if (var_get_key(str) == key)
+				return TRUE;
+		}
+	}
+	return FALSE;
+}
+
 const struct var_expand_table *
 var_expand_table_build(char key, const char *value, char key2, ...)
 {
diff -r 2a7368d692ae -r f957853df4c2 src/lib/var-expand.h
--- a/src/lib/var-expand.h	Sat Oct 25 15:17:46 2008 +0300
+++ b/src/lib/var-expand.h	Sat Oct 25 15:19:31 2008 +0300
@@ -14,6 +14,8 @@ void var_expand(string_t *dest, const ch
 /* Returns the actual key character for given string, ie. skip any modifiers
    that are before it. The string should be the data after the '%' character. */
 char var_get_key(const char *str);
+/* Returns TRUE if key variable is used in the string. */
+bool var_has_key(const char *str, char key);
 
 const struct var_expand_table *
 var_expand_table_build(char key, const char *value, char key2, ...);


More information about the dovecot-cvs mailing list