changeset 345:257ffce6c1cd

added local_rcpts() and remote_rcpts() for later use
author markus schnalke <meillo@marmaro.de>
date Sat, 03 Sep 2011 18:53:54 +0200 (2011-09-03)
parents 0410c8aabac2
children 1ca9bc4c6552
files src/masqmail.h src/route.c
diffstat 2 files changed, 48 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/masqmail.h	Sat Sep 03 18:32:37 2011 +0200
+++ b/src/masqmail.h	Sat Sep 03 18:53:54 2011 +0200
@@ -480,6 +480,8 @@
 void destroy_msgout_perhost(msgout_perhost * mo_ph);
 void rewrite_headers(msg_out * msgout, connect_route * route);
 void split_rcpts(GList* rcpt_list, GList* localnets, GList** rl_local, GList** rl_localnet, GList** rl_others);
+GList* local_rcpts(GList* rcpt_list);
+GList* remote_rcpts(GList* rcpt_list);
 gboolean route_strip_msgout(connect_route * route, msg_out * msgout);
 msg_out *route_prepare_msgout(connect_route * route, msg_out * msgout);
 GList *route_msgout_list(connect_route * route, GList * msgout_list);
--- a/src/route.c	Sat Sep 03 18:32:37 2011 +0200
+++ b/src/route.c	Sat Sep 03 18:53:54 2011 +0200
@@ -237,6 +237,52 @@
 	}
 }
 
+/*
+Return a new list of the local rcpts in the rcpt_list
+TODO: This function is almost exactly the same as remote_rcpts(). Merge?
+*/
+GList*
+local_rcpts(GList* rcpt_list)
+{
+	GList *rcpt_node;
+	GList *local_rcpts = NULL;
+	address *rcpt = NULL;
+
+	if (!rcpt_list) {
+		return NULL;
+	}
+	foreach(rcpt_list, rcpt_node) {
+		rcpt = (address *) (rcpt_node->data);
+		if (addr_is_local(rcpt)) {
+			local_rcpts = g_list_append(local_rcpts, rcpt);
+		}
+	}
+	return local_rcpts;
+}
+
+/*
+Return a new list of non-local rcpts in the rcpt_list
+TODO: This function is almost exactly the same as local_rcpts(). Merge?
+*/
+GList*
+remote_rcpts(GList* rcpt_list)
+{
+	GList *rcpt_node;
+	GList *remote_rcpts = NULL;
+	address *rcpt = NULL;
+
+	if (!rcpt_list) {
+		return NULL;
+	}
+	foreach(rcpt_list, rcpt_node) {
+		rcpt = (address *) (rcpt_node->data);
+		if (!addr_is_local(rcpt)) {
+			remote_rcpts = g_list_append(remote_rcpts, rcpt);
+		}
+	}
+	return remote_rcpts;
+}
+
 static gint
 _g_list_addrcmp(gconstpointer pattern, gconstpointer addr)
 {