masqmail

diff src/deliver.c @ 367:b27f66555ba8

Reformated multiline comments to have leading asterisks on each line Now we use: /* ** comment */ This makes the indent style simpler, too.
author markus schnalke <meillo@marmaro.de>
date Thu, 20 Oct 2011 10:20:59 +0200
parents 41958685480d
children d86d7b4b8995
line diff
     1.1 --- a/src/deliver.c	Thu Sep 22 15:07:40 2011 +0200
     1.2 +++ b/src/deliver.c	Thu Oct 20 10:20:59 2011 +0200
     1.3 @@ -1,20 +1,21 @@
     1.4 -/*  MasqMail
     1.5 -    Copyright (C) 1999-2002 Oliver Kurth
     1.6 -    Copyright (C) 2008, 2010 markus schnalke <meillo@marmaro.de>
     1.7 -
     1.8 -    This program is free software; you can redistribute it and/or modify
     1.9 -    it under the terms of the GNU General Public License as published by
    1.10 -    the Free Software Foundation; either version 2 of the License, or
    1.11 -    (at your option) any later version.
    1.12 -
    1.13 -    This program is distributed in the hope that it will be useful,
    1.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.16 -    GNU General Public License for more details.
    1.17 -
    1.18 -    You should have received a copy of the GNU General Public License
    1.19 -    along with this program; if not, write to the Free Software
    1.20 -    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    1.21 +/*
    1.22 +**  MasqMail
    1.23 +**  Copyright (C) 1999-2002 Oliver Kurth
    1.24 +**  Copyright (C) 2008, 2010 markus schnalke <meillo@marmaro.de>
    1.25 +**
    1.26 +**  This program is free software; you can redistribute it and/or modify
    1.27 +**  it under the terms of the GNU General Public License as published by
    1.28 +**  the Free Software Foundation; either version 2 of the License, or
    1.29 +**  (at your option) any later version.
    1.30 +**
    1.31 +**  This program is distributed in the hope that it will be useful,
    1.32 +**  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.33 +**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.34 +**  GNU General Public License for more details.
    1.35 +**
    1.36 +**  You should have received a copy of the GNU General Public License
    1.37 +**  along with this program; if not, write to the Free Software
    1.38 +**  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    1.39  */
    1.40  
    1.41  #include <fnmatch.h>
    1.42 @@ -24,8 +25,11 @@
    1.43  #include "masqmail.h"
    1.44  #include "smtp_out.h"
    1.45  
    1.46 -/* collect failed/defered rcpts for failure/warning messages */
    1.47 -/* returns TRUE if either there are no failures or a failure message has been successfully sent */
    1.48 +/*
    1.49 +**  collect failed/defered rcpts for failure/warning messages
    1.50 +**  returns TRUE if either there are no failures or a failure message has
    1.51 +**  been successfully sent
    1.52 +*/
    1.53  gboolean
    1.54  delivery_failures(message *msg, GList *rcpt_list, gchar *err_fmt, ...)
    1.55  {
    1.56 @@ -173,9 +177,11 @@
    1.57  		address *ret_path = msg->return_path;
    1.58  		header *retpath_hdr, *envto_hdr;
    1.59  
    1.60 -		/* we need a private copy of the hdr list because we add headers
    1.61 -		   here that belong to the rcpt only. g_list_copy copies only
    1.62 -		   the nodes, so it is safe to g_list_free it */
    1.63 +		/*
    1.64 +		**  we need a private copy of the hdr list because we add
    1.65 +		**  headers here that belong to the rcpt only. g_list_copy
    1.66 +		**  copies only the nodes, so it is safe to g_list_free it
    1.67 +		*/
    1.68  		hdr_list = g_list_copy(msg->hdr_list);
    1.69  		retpath_hdr = create_header(HEAD_ENVELOPE_TO, "Envelope-to: %s\n", addr_string(env_addr));
    1.70  		envto_hdr = create_header(HEAD_RETURN_PATH, "Return-path: %s\n", addr_string(ret_path));
    1.71 @@ -184,8 +190,10 @@
    1.72  		hdr_list = g_list_prepend(hdr_list, retpath_hdr);
    1.73  
    1.74  		if (rcpt->local_part[0] == '|') {
    1.75 -			/* probably for expanded aliases, but why not done
    1.76 -			   like with the mda? //meillo 2010-12-06 */
    1.77 +			/*
    1.78 +			**  probably for expanded aliases, but why not done
    1.79 +			**  like with the mda? //meillo 2010-12-06
    1.80 +			*/
    1.81  			if (deliver_local_pipe(msg, hdr_list, rcpt, env_addr)) {
    1.82  				ok = TRUE;
    1.83  			}
    1.84 @@ -235,10 +243,13 @@
    1.85  	return ok;
    1.86  }
    1.87  
    1.88 -/* make a list of rcpt's of a message that are local
    1.89 -   return a new copy of the list */
    1.90 +/*
    1.91 +**  make a list of rcpt's of a message that are local
    1.92 +**  return a new copy of the list
    1.93 +*/
    1.94  void
    1.95 -msg_rcptlist_local(GList *rcpt_list, GList **p_local_list, GList **p_nonlocal_list)
    1.96 +msg_rcptlist_local(GList *rcpt_list, GList **p_local_list,
    1.97 +		GList **p_nonlocal_list)
    1.98  {
    1.99  	GList *rcpt_node;
   1.100  
   1.101 @@ -329,12 +340,14 @@
   1.102  	return ok;
   1.103  }
   1.104  
   1.105 -/* deliver list of messages to one host and finishes them if the message was
   1.106 -   delivered to at least one rcpt.
   1.107 -   Returns TRUE if at least one msg was delivered to at least one rcpt.
   1.108 +/*
   1.109 +**  deliver list of messages to one host and finishes them if the message was
   1.110 +**  delivered to at least one rcpt.
   1.111 +**  Returns TRUE if at least one msg was delivered to at least one rcpt.
   1.112  */
   1.113  gboolean
   1.114 -deliver_msglist_host_smtp(connect_route *route, GList *msgout_list, gchar *host, GList *res_list)
   1.115 +deliver_msglist_host_smtp(connect_route *route, GList *msgout_list,
   1.116 +		gchar *host, GList *res_list)
   1.117  {
   1.118  	gboolean ok = FALSE;
   1.119  	GList *msgout_node;
   1.120 @@ -477,7 +490,7 @@
   1.121  }
   1.122  
   1.123  /*
   1.124 -  delivers messages in msgout_list using route
   1.125 +** delivers messages in msgout_list using route
   1.126  */
   1.127  gboolean
   1.128  deliver_route_msgout_list(connect_route *route, GList *msgout_list)
   1.129 @@ -501,11 +514,12 @@
   1.130  		return FALSE;
   1.131  	}
   1.132  
   1.133 -	/* TODO: It would be nice to be able to fork for each host.
   1.134 -	   We cannot do that yet because of complications with finishing the
   1.135 -	   messages. Threads could be a solution because they use the same
   1.136 -	   memory. But we are not thread safe yet...
   1.137 -	 */
   1.138 +	/*
   1.139 +	**  TODO: It would be nice to be able to fork for each host.
   1.140 +	**  We cannot do that yet because of complications with finishing the
   1.141 +	**  messages. Threads could be a solution because they use the same
   1.142 +	**  memory. But we are not thread safe yet...
   1.143 +	*/
   1.144  	foreach(mo_ph_list, mo_ph_node) {
   1.145  		msgout_perhost *mo_ph = (msgout_perhost *) (mo_ph_node->data);
   1.146  		if (deliver_msglist_host(route, mo_ph->msgout_list, mo_ph->host, route->resolve_list)) {
   1.147 @@ -518,8 +532,9 @@
   1.148  }
   1.149  
   1.150  /*
   1.151 -  calls route_prepare_msg()
   1.152 -  delivers messages in msg_list using route by calling deliver_route_msgout_list()
   1.153 +** calls route_prepare_msg()
   1.154 +** delivers messages in msg_list using route by calling
   1.155 +** deliver_route_msgout_list()
   1.156  */
   1.157  gboolean
   1.158  deliver_route_msg_list(connect_route *route, GList *msgout_list)
   1.159 @@ -536,12 +551,16 @@
   1.160  		GList *rcpt_list_non_delivered = NULL;
   1.161  		GList *rcpt_node;
   1.162  
   1.163 -		/* we have to delete already delivered rcpt's because a
   1.164 -		   previous route may have delivered to it */
   1.165 +		/*
   1.166 +		**  we have to delete already delivered rcpt's because a
   1.167 +		**  previous route may have delivered to it
   1.168 +		*/
   1.169  		foreach(msgout_cloned->rcpt_list, rcpt_node) {
   1.170  			address *rcpt = (address *) (rcpt_node->data);
   1.171 -			/* failed addresses already have been bounced;
   1.172 -			   there should be a better way to handle those. */
   1.173 +			/*
   1.174 +			**  failed addresses already have been bounced;
   1.175 +			**  there should be a better way to handle those.
   1.176 +			*/
   1.177  			if (!addr_is_delivered(rcpt) && !addr_is_failed(rcpt)
   1.178  			    && !(rcpt->flags & ADDR_FLAG_LAST_ROUTE)) {
   1.179  				rcpt_list_non_delivered = g_list_append(rcpt_list_non_delivered, rcpt);
   1.180 @@ -596,8 +615,9 @@
   1.181  	return ok;
   1.182  }
   1.183  
   1.184 -/* copy pointers of delivered addresses to the msg's non_rcpt_list,
   1.185 -   to make sure that they will not be delivered again.
   1.186 +/*
   1.187 +**  copy pointers of delivered addresses to the msg's non_rcpt_list,
   1.188 +**  to make sure that they will not be delivered again.
   1.189  */
   1.190  void
   1.191  update_non_rcpt_list(msg_out *msgout)
   1.192 @@ -613,12 +633,13 @@
   1.193  	}
   1.194  }
   1.195  
   1.196 -/* after delivery attempts, we check if there are any rcpt addresses left in
   1.197 -   the message. If all addresses have been completed, the spool files will be
   1.198 -   deleted, otherwise the header spool will be written back. We never changed
   1.199 -   the data spool, so there is no need to write that back.
   1.200 -
   1.201 -   returns TRUE if all went well.
   1.202 +/*
   1.203 +**  after delivery attempts, we check if there are any rcpt addresses left in
   1.204 +**  the message. If all addresses have been completed, the spool files will be
   1.205 +**  deleted, otherwise the header spool will be written back. We never changed
   1.206 +**  the data spool, so there is no need to write that back.
   1.207 +**
   1.208 +**  returns TRUE if all went well.
   1.209  */
   1.210  gboolean
   1.211  deliver_finish(msg_out *msgout)
   1.212 @@ -629,18 +650,21 @@
   1.213  
   1.214  	update_non_rcpt_list(msgout);
   1.215  
   1.216 -	/* we NEVER made copies of the addresses, flags affecting addresses
   1.217 -	   were always set on the original address structs */
   1.218 +	/*
   1.219 +	**  we NEVER made copies of the addresses, flags affecting addresses
   1.220 +	**  were always set on the original address structs
   1.221 +	*/
   1.222  	foreach(msg->rcpt_list, rcpt_node) {
   1.223  		address *rcpt = (address *) (rcpt_node->data);
   1.224  		if (!addr_is_finished_children(rcpt)) {
   1.225  			finished = FALSE;
   1.226  		} else {
   1.227 -			/* if ALL children have been delivered, mark parent as
   1.228 -			   delivered. if there is one or more not delivered,
   1.229 -			   it must have failed, we mark the parent as failed
   1.230 -			   as well.
   1.231 -			 */
   1.232 +			/*
   1.233 +			**  if ALL children have been delivered, mark parent as
   1.234 +			**  delivered. if there is one or more not delivered,
   1.235 +			**  it must have failed, we mark the parent as failed
   1.236 +			**  as well.
   1.237 +			*/
   1.238  			if (addr_is_delivered_children(rcpt)) {
   1.239  				addr_mark_delivered(rcpt);
   1.240  			} else {
   1.241 @@ -728,8 +752,8 @@
   1.242  }
   1.243  
   1.244  /*
   1.245 -   This function splits the list of rcpt addresses
   1.246 -   into local and remote addresses and processes them accordingly.
   1.247 +**  This function splits the list of rcpt addresses
   1.248 +**  into local and remote addresses and processes them accordingly.
   1.249  */
   1.250  gboolean
   1.251  deliver_msg_list(GList *msg_list, guint flags)
   1.252 @@ -839,10 +863,10 @@
   1.253  }
   1.254  
   1.255  /*
   1.256 -   deliver() is called when a message has just been received
   1.257 -   (mode_accept and smtp_in) and should be delivered immediately
   1.258 -   (neither -odq nor do_queue). Only this one message will be tried to
   1.259 -   deliver then.
   1.260 +**  deliver() is called when a message has just been received
   1.261 +**  (mode_accept and smtp_in) and should be delivered immediately
   1.262 +**  (neither -odq nor do_queue). Only this one message will be tried to
   1.263 +**  deliver then.
   1.264  */
   1.265  gboolean
   1.266  deliver(message *msg)