changeset 21771:4cc995a5f002

auth: Add auth_fields_import_prefixed
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Thu, 16 Mar 2017 13:36:23 +0200
parents ace143d416d1
children 5379a8dd5937
files src/auth/auth-fields.c src/auth/auth-fields.h
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/auth-fields.c	Tue Mar 14 10:01:51 2017 +0200
+++ b/src/auth/auth-fields.c	Thu Mar 16 13:36:23 2017 +0200
@@ -114,8 +114,8 @@
 	}
 }
 
-void auth_fields_import(struct auth_fields *fields, const char *str,
-			enum auth_field_flags flags)
+void auth_fields_import_prefixed(struct auth_fields *fields, const char *prefix,
+				 const char *str, enum auth_field_flags flags)
 {
 	T_BEGIN {
 		const char *const *arg = t_strsplit_tab(str);
@@ -128,12 +128,20 @@
 				value = NULL;
 			} else {
 				key = t_strdup_until(*arg, value++);
+				if (*prefix != '\0')
+					key = t_strconcat(prefix, key, NULL);
 			}
 			auth_fields_add(fields, key, value, flags);
 		}
 	} T_END;
 }
 
+void auth_fields_import(struct auth_fields *fields, const char *str,
+			enum auth_field_flags flags)
+{
+	auth_fields_import_prefixed(fields, "", str, flags);
+}
+
 const ARRAY_TYPE(auth_field) *auth_fields_export(struct auth_fields *fields)
 {
 	if (!array_is_created(&fields->fields))
--- a/src/auth/auth-fields.h	Tue Mar 14 10:01:51 2017 +0200
+++ b/src/auth/auth-fields.h	Thu Mar 16 13:36:23 2017 +0200
@@ -28,6 +28,8 @@
 
 void auth_fields_import(struct auth_fields *fields, const char *str,
 			enum auth_field_flags flags);
+void auth_fields_import_prefixed(struct auth_fields *fields, const char *prefix,
+				 const char *str, enum auth_field_flags flags);
 const ARRAY_TYPE(auth_field) *auth_fields_export(struct auth_fields *fields);
 /* Append fields where (flag & flags_mask) == flags_result. */
 void auth_fields_append(struct auth_fields *fields, string_t *dest,