diff src/sm-archive.cpp @ 8:ed73e6361570 stable-1-0

initial version
author carl
date Fri, 10 Mar 2006 12:55:07 -0800
parents 5241a079fe03
children 48880e61ce5e
line wrap: on
line diff
--- a/src/sm-archive.cpp	Fri Mar 10 12:26:37 2006 -0800
+++ b/src/sm-archive.cpp	Fri Mar 10 12:55:07 2006 -0800
@@ -88,7 +88,6 @@
 	pthread_mutex_unlock(&config_mutex);
 	mailaddr	   = NULL;
 	queueid 	   = NULL;
-	processed_from = false;
 }
 
 mlfiPriv::~mlfiPriv() {
@@ -99,7 +98,7 @@
 }
 
 void mlfiPriv::reset(bool final) {
-	processed_from = false;
+	targets.clear();
 	if (mailaddr) free(mailaddr);
 	if (queueid)  free(queueid);
 	if (!final) {
@@ -176,16 +175,12 @@
 	return SMFIS_CONTINUE;
 }
 
-void add_target(mlfiPriv &priv, SMFICTX *ctx, char *target);
-void add_target(mlfiPriv &priv, SMFICTX *ctx, char *target)
+void add_target(mlfiPriv &priv, char *target);
+void add_target(mlfiPriv &priv, char *target)
 {
 	if (target) {
-		smfi_addrcpt(ctx, target);
-		if (debug_syslog > 1) {
-			char msg[maxlen];
-			snprintf(msg, sizeof(msg), "adding recipient <%s>", target);
-			my_syslog(&priv, msg);
-		}
+		string_set::iterator i = priv.targets.find(target);
+		if (i == priv.targets.end()) priv.targets.insert(target);
 	}
 }
 
@@ -201,18 +196,26 @@
 		my_syslog(&priv, msg);
 	}
 	char *target = dc.find_to(rcptaddr);
-	add_target(priv, ctx, target);
 	free(rcptaddr);
-	if (!priv.processed_from) {
-		target = dc.find_from(priv.mailaddr);
-		add_target(priv, ctx, target);
-		priv.processed_from = true;
-	}
+	add_target(priv, target);
 	return SMFIS_CONTINUE;
 }
 
 sfsistat mlfi_eom(SMFICTX *ctx)
 {
+	mlfiPriv &priv = *MLFIPRIV;
+	CONFIG &dc = *priv.pc;
+	char *target = dc.find_from(priv.mailaddr);
+	add_target(priv, target);
+	for (string_set::iterator i=priv.targets.begin(); i!=priv.targets.end(); i++) {
+		target = (*i);
+		smfi_addrcpt(ctx, target);
+		if (debug_syslog > 1) {
+			char msg[maxlen];
+			snprintf(msg, sizeof(msg), "adding recipient <%s>", target);
+			my_syslog(&priv, msg);
+		}
+	}
 	// reset for a new message on the same connection
 	mlfi_abort(ctx);
 	return SMFIS_CONTINUE;