[dovecot-cvs] dovecot/src/lib-mail message-address.c, 1.15, 1.16 message-address.h, 1.3, 1.4

tss at dovecot.org tss at dovecot.org
Sun Oct 8 20:22:41 UTC 2006


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

Modified Files:
	message-address.c message-address.h 
Log Message:
Added fill_missing parameter to message_address_parse() which specifies if
missing mailbox and domain should be returned as MISSING_MAILBOX and
MISSING_DOMAIN or just as empty strings.



Index: message-address.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-address.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- message-address.c	13 Jan 2006 20:26:16 -0000	1.15
+++ message-address.c	8 Oct 2006 19:22:37 -0000	1.16
@@ -12,6 +12,8 @@
 
 	struct message_address *first_addr, *last_addr, addr;
 	string_t *str;
+
+	bool fill_missing;
 };
 
 static void add_address(struct message_address_parser_context *ctx)
@@ -189,10 +191,14 @@
 			return -1;
 	}
 
-	if (ctx->addr.mailbox == NULL)
-		ctx->addr.mailbox = p_strdup(ctx->pool, "MISSING_MAILBOX");
-	if (ctx->addr.domain == NULL)
-		ctx->addr.domain = p_strdup(ctx->pool, "MISSING_DOMAIN");
+	if (ctx->addr.mailbox == NULL) {
+		ctx->addr.mailbox = !ctx->fill_missing ? "" :
+			p_strdup(ctx->pool, "MISSING_MAILBOX");
+	}
+	if (ctx->addr.domain == NULL) {
+		ctx->addr.domain = !ctx->fill_missing ? "" :
+			p_strdup(ctx->pool, "MISSING_DOMAIN");
+	}
 	add_address(ctx);
 
 	return ret;
@@ -273,7 +279,7 @@
 
 struct message_address *
 message_address_parse(pool_t pool, const unsigned char *data, size_t size,
-		      unsigned int max_addresses)
+		      unsigned int max_addresses, bool fill_missing)
 {
 	struct message_address_parser_context ctx;
 
@@ -284,6 +290,7 @@
 	rfc822_parser_init(&ctx.parser, data, size, t_str_new(128));
 	ctx.pool = pool;
 	ctx.str = t_str_new(128);
+	ctx.fill_missing = fill_missing;
 
 	rfc822_skip_lwsp(&ctx.parser);
 

Index: message-address.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-address.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- message-address.h	6 Jan 2005 18:14:28 -0000	1.3
+++ message-address.h	8 Oct 2006 19:22:37 -0000	1.4
@@ -10,10 +10,12 @@
 	const char *name, *route, *mailbox, *domain;
 };
 
-/* Parse message addresses from given data. */
+/* Parse message addresses from given data. If fill_missing is TRUE, missing
+   mailbox and domain are set to MISSING_MAILBOX and MISSING_DOMAIN strings.
+   Otherwise they're set to "". */
 struct message_address *
 message_address_parse(pool_t pool, const unsigned char *data, size_t size,
-		      unsigned int max_addresses);
+		      unsigned int max_addresses, bool fill_missing);
 
 void message_address_write(string_t *str, const struct message_address *addr);
 



More information about the dovecot-cvs mailing list