masqmail

diff src/deliver.c @ 15:f671821d8222

code beautifying; 0 -> \0 if appropriate
author meillo@marmaro.de
date Thu, 06 Nov 2008 09:18:38 +0100
parents 9fb7ddbaf129
children 6c59dedd06be
line diff
     1.1 --- a/src/deliver.c	Wed Oct 29 21:21:26 2008 +0100
     1.2 +++ b/src/deliver.c	Thu Nov 06 09:18:38 2008 +0100
     1.3 @@ -16,15 +16,15 @@
     1.4      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     1.5  */
     1.6  
     1.7 -#include "masqmail.h"
     1.8 -#include "smtp_out.h"
     1.9  #include <fnmatch.h>
    1.10  #include <sysexits.h>
    1.11  #include <netdb.h>
    1.12  
    1.13 +#include "masqmail.h"
    1.14 +#include "smtp_out.h"
    1.15 +
    1.16  /* collect failed/defered rcpts for failure/warning messages */
    1.17 -/* returns TRUE if either there are no failures or a
    1.18 -   failure message has been successfully sent */
    1.19 +/* returns TRUE if either there are no failures or a failure message has been successfully sent */
    1.20  gboolean
    1.21  delivery_failures(message * msg, GList * rcpt_list, gchar * err_fmt, ...)
    1.22  {
    1.23 @@ -92,11 +92,8 @@
    1.24  		address *ret_path = msg->return_path;
    1.25  		header *retpath_hdr, *envto_hdr;
    1.26  
    1.27 -		/* we need a private copy of the hdr list because we add headers here
    1.28 -		   that belong to the rcpt only.
    1.29 -		   g_list_copy copies only the nodes, so it is safe to
    1.30 -		   g_list_free it
    1.31 -		 */
    1.32 +		/* we need a private copy of the hdr list because we add headers here that belong to the rcpt only.
    1.33 +		   g_list_copy copies only the nodes, so it is safe to g_list_free it */
    1.34  		hdr_list = g_list_copy(msg->hdr_list);
    1.35  		retpath_hdr = create_header(HEAD_ENVELOPE_TO, "Envelope-to: %s\n", addr_string(env_addr));
    1.36  		envto_hdr = create_header(HEAD_RETURN_PATH, "Return-path: %s\n", addr_string(ret_path));
    1.37 @@ -109,7 +106,8 @@
    1.38  			if (pipe_out(msg, hdr_list, rcpt, &(rcpt->local_part[1]),
    1.39  			    (conf.pipe_fromline ? MSGSTR_FROMLINE : 0)
    1.40  			    | (conf.pipe_fromhack ? MSGSTR_FROMHACK : 0))) {
    1.41 -				logwrite(LOG_NOTICE, "%s => %s <%s@%s> with pipe\n", msg->uid, rcpt->local_part, env_addr->local_part, env_addr->domain);
    1.42 +				logwrite(LOG_NOTICE, "%s => %s <%s@%s> with pipe\n",
    1.43 +				         msg->uid, rcpt->local_part, env_addr->local_part, env_addr->domain);
    1.44  				addr_mark_delivered(rcpt);
    1.45  				ok = TRUE;
    1.46  			} else {
    1.47 @@ -216,9 +214,7 @@
    1.48  	return ok;
    1.49  }
    1.50  
    1.51 -/* make a list of rcpt's of a message that are local
    1.52 -   return a new copy of the list
    1.53 -*/
    1.54 +/* make a list of rcpt's of a message that are local return a new copy of the list */
    1.55  void
    1.56  msg_rcptlist_local(GList * rcpt_list, GList ** p_local_list, GList ** p_nonlocal_list)
    1.57  {
    1.58 @@ -315,11 +311,9 @@
    1.59  	return ok;
    1.60  }
    1.61  
    1.62 -/* deliver list of messages to one host
    1.63 -   and finishes them if the message was delivered to at least one rcpt.
    1.64 +/* deliver list of messages to one host and finishes them if the message was delivered to at least one rcpt.
    1.65     Returns TRUE if at least one msg was delivered to at least one rcpt.
    1.66  */
    1.67 -
    1.68  gboolean
    1.69  deliver_msglist_host_smtp(connect_route * route, GList * msgout_list, gchar * host, GList * res_list)
    1.70  {
    1.71 @@ -368,8 +362,7 @@
    1.72  				gboolean flag, ok_msg = FALSE, ok_fail = FALSE;
    1.73  				message *msg = msgout->msg;
    1.74  
    1.75 -				/* we may have to read the data at this point
    1.76 -				   and remember if we did */
    1.77 +				/* we may have to read the data at this point and remember if we did */
    1.78  				flag = (msg->data_list == NULL);
    1.79  				if (flag) {
    1.80  					if (!spool_read_data(msg)) {
    1.81 @@ -380,7 +373,8 @@
    1.82  
    1.83  				smtp_out_msg(psb, msg, msgout->return_path, msgout->rcpt_list, msgout->hdr_list);
    1.84  
    1.85 -				ok_fail = delivery_failures(msg, msgout->rcpt_list, "while connected with %s, the server replied\n\t%s", host, psb->buffer);
    1.86 +				ok_fail = delivery_failures(msg, msgout->rcpt_list,
    1.87 +				                            "while connected with %s, the server replied\n\t%s", host, psb->buffer);
    1.88  
    1.89  				if ((psb->error == smtp_eof)
    1.90  				    || (psb->error == smtp_timeout)) {
    1.91 @@ -437,11 +431,9 @@
    1.92  					addr_mark_defered(rcpt);
    1.93  				}
    1.94  				if (route->wrapper
    1.95 -				    ? delivery_failures(msgout->msg, msgout->rcpt_list,
    1.96 -				                        "could not open wrapper:\n\t%s",
    1.97 +				    ? delivery_failures(msgout->msg, msgout->rcpt_list, "could not open wrapper:\n\t%s",
    1.98  				                        strerror(errno))
    1.99 -				    : delivery_failures(msgout->msg, msgout->rcpt_list,
   1.100 -				                        "could not open connection to %s:%d :\n\t%s",
   1.101 +				    : delivery_failures(msgout->msg, msgout->rcpt_list, "could not open connection to %s:%d :\n\t%s",
   1.102  				                        host, port, h_errno != 0 ? hstrerror(h_errno) : strerror(errno)))
   1.103  					deliver_finish(msgout);
   1.104  			}
   1.105 @@ -470,8 +462,7 @@
   1.106  {
   1.107  	gboolean ok = FALSE;
   1.108  
   1.109 -	DEBUG(5)
   1.110 -		debugf("deliver_route_msgout_list entered, route->name = %s\n", route->name);
   1.111 +	DEBUG(5) debugf("deliver_route_msgout_list entered, route->name = %s\n", route->name);
   1.112  
   1.113  	if (route->mail_host != NULL) {
   1.114  		/* this is easy... */
   1.115 @@ -506,8 +497,7 @@
   1.116  
   1.117  /*
   1.118    calls route_prepare_msg()
   1.119 -  delivers messages in msg_list using route
   1.120 -  by calling deliver_route_msgout_list()
   1.121 +  delivers messages in msg_list using route by calling deliver_route_msgout_list()
   1.122  */
   1.123  gboolean
   1.124  deliver_route_msg_list(connect_route * route, GList * msgout_list)
   1.125 @@ -524,12 +514,10 @@
   1.126  		GList *rcpt_list_non_delivered = NULL;
   1.127  		GList *rcpt_node;
   1.128  
   1.129 -		/* we have to delete already delivered rcpt's
   1.130 -		   because a previous route may have delivered to it */
   1.131 +		/* we have to delete already delivered rcpt's because a previous route may have delivered to it */
   1.132  		foreach(msgout_cloned->rcpt_list, rcpt_node) {
   1.133  			address *rcpt = (address *) (rcpt_node->data);
   1.134 -			/* failed addresses already have been bounced
   1.135 -			   - there should be a better way to handle those. */
   1.136 +			/* failed addresses already have been bounced - there should be a better way to handle those. */
   1.137  			if (!addr_is_delivered(rcpt) && !addr_is_failed(rcpt)
   1.138  			    && !(rcpt->flags & ADDR_FLAG_LAST_ROUTE))
   1.139  				rcpt_list_non_delivered = g_list_append(rcpt_list_non_delivered, rcpt);
   1.140 @@ -591,10 +579,9 @@
   1.141  	}
   1.142  }
   1.143  
   1.144 -/* after delivery attempts, we check if there are any
   1.145 -   rcpt addresses left in the message.
   1.146 -   If all addresses have been completed, the spool files will
   1.147 -   be deleted, otherwise the header spool will be written back.
   1.148 +/* after delivery attempts, we check if there are any rcpt addresses left in the message.
   1.149 +   If all addresses have been completed, the spool files will be deleted,
   1.150 +   otherwise the header spool will be written back.
   1.151     We never changed the data spool, so there is no need to write that back.
   1.152  
   1.153     returns TRUE if all went well.
   1.154 @@ -616,10 +603,8 @@
   1.155  		if (!addr_is_finished_children(rcpt))
   1.156  			finished = FALSE;
   1.157  		else {
   1.158 -			/* if ALL children have been delivered,
   1.159 -			   mark parent as delivered.
   1.160 -			   if there is one or more not delivered,
   1.161 -			   it must have failed, we mark the parent as failed as well.
   1.162 +			/* if ALL children have been delivered, mark parent as delivered.
   1.163 +			   if there is one or more not delivered, it must have failed, we mark the parent as failed as well.
   1.164  			 */
   1.165  			if (addr_is_delivered_children(rcpt)) {
   1.166  				addr_mark_delivered(rcpt);