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

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


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

Modified Files:
      Tag: branch_1_0
	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.15.2.1
diff -u -d -r1.15 -r1.15.2.1
--- message-address.c	13 Jan 2006 20:26:16 -0000	1.15
+++ message-address.c	8 Oct 2006 19:22:32 -0000	1.15.2.1
@@ -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.3.2.1
diff -u -d -r1.3 -r1.3.2.1
--- message-address.h	6 Jan 2005 18:14:28 -0000	1.3
+++ message-address.h	8 Oct 2006 19:22:32 -0000	1.3.2.1
@@ -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