[dovecot-cvs] dovecot/src/lib var-expand.c, 1.3, 1.4 var-expand.h, 1.2, 1.3

cras at dovecot.org cras at dovecot.org
Wed Dec 15 21:31:08 EET 2004


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

Modified Files:
	var-expand.c var-expand.h 
Log Message:
Auth cache key was built wrong if any modifiers were used for %vars.
Added var_get_key() function which skips over any modifiers and returns the
actual key.



Index: var-expand.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/var-expand.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- var-expand.c	26 Jul 2004 16:39:18 -0000	1.3
+++ var-expand.c	15 Dec 2004 19:31:06 -0000	1.4
@@ -90,3 +90,27 @@
 		}
 	}
 }
+
+char var_get_key(const char *str)
+{
+	const struct var_expand_modifier *m;
+
+	/* [<offset>.]<width>[<modifier>]<variable> */
+	while (*str >= '0' && *str <= '9')
+		str++;
+
+	if (*str == '.') {
+		str++;
+		while (*str >= '0' && *str <= '9')
+			str++;
+	}
+
+	for (m = modifiers; m->key != '\0'; m++) {
+		if (m->key == *str) {
+			str++;
+			break;
+		}
+	}
+
+	return *str;
+}

Index: var-expand.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/var-expand.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- var-expand.h	24 May 2004 22:33:50 -0000	1.2
+++ var-expand.h	15 Dec 2004 19:31:06 -0000	1.3
@@ -11,4 +11,8 @@
 void var_expand(string_t *dest, const char *str,
 		const struct var_expand_table *table);
 
+/* 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);
+
 #endif



More information about the dovecot-cvs mailing list