dovecot-1.2: Added var_has_key().
dovecot at dovecot.org
dovecot at dovecot.org
Sat Oct 25 15:42:47 EEST 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/66e0eaf4d536
changeset: 8324:66e0eaf4d536
user: Timo Sirainen <tss at iki.fi>
date: Sat Oct 25 15:19:37 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 60c48789841b -r 66e0eaf4d536 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:37 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 60c48789841b -r 66e0eaf4d536 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:37 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) ATTR_PURE;
+/* Returns TRUE if key variable is used in the string. */
+bool var_has_key(const char *str, char key) ATTR_PURE;
const struct var_expand_table *
var_expand_table_build(char key, const char *value, char key2, ...);
More information about the dovecot-cvs
mailing list