masqmail

diff src/smtp_out.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 f122535c589e
line diff
     1.1 --- a/src/smtp_out.c	Thu Sep 22 15:07:40 2011 +0200
     1.2 +++ b/src/smtp_out.c	Thu Oct 20 10:20:59 2011 +0200
     1.3 @@ -1,29 +1,30 @@
     1.4 -/* smtp_out.c
     1.5 -    Copyright (C) 1999-2001 Oliver Kurth
     1.6 -    Copyright (C) 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., 675 Mass Ave, Cambridge, MA 02139, USA.
    1.21 - */
    1.22 +/*
    1.23 +**  smtp_out.c
    1.24 +**  Copyright (C) 1999-2001 Oliver Kurth
    1.25 +**  Copyright (C) 2010 markus schnalke <meillo@marmaro.de>
    1.26 +**
    1.27 +**  This program is free software; you can redistribute it and/or modify
    1.28 +**  it under the terms of the GNU General Public License as published by
    1.29 +**  the Free Software Foundation; either version 2 of the License, or
    1.30 +**  (at your option) any later version.
    1.31 +**
    1.32 +**  This program is distributed in the hope that it will be useful,
    1.33 +**  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.34 +**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.35 +**  GNU General Public License for more details.
    1.36 +**
    1.37 +**  You should have received a copy of the GNU General Public License
    1.38 +**  along with this program; if not, write to the Free Software
    1.39 +**  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    1.40 +*/
    1.41  
    1.42  /*
    1.43 -  I always forget these rfc numbers:
    1.44 -  RFC 821  (SMTP)
    1.45 -  RFC 1869 (ESMTP)
    1.46 -  RFC 1870 (ESMTP SIZE)
    1.47 -  RFC 2197 (ESMTP PIPELINE)
    1.48 -  RFC 2554 (ESMTP AUTH)
    1.49 +**  I always forget these rfc numbers:
    1.50 +**  RFC 821  (SMTP)
    1.51 +**  RFC 1869 (ESMTP)
    1.52 +**  RFC 1870 (ESMTP SIZE)
    1.53 +**  RFC 2197 (ESMTP PIPELINE)
    1.54 +**  RFC 2554 (ESMTP AUTH)
    1.55  */
    1.56  
    1.57  #include "masqmail.h"
    1.58 @@ -73,9 +74,12 @@
    1.59  		if (host_entry) {
    1.60  			psb->helo_name = g_strdup(host_entry->h_name);
    1.61  		} else {
    1.62 -			/* we failed to look up our own name. Instead of giving our local hostname,
    1.63 -			   we may give our IP number to show the server that we are at least
    1.64 -			   willing to be honest. For the really picky ones. */
    1.65 +			/*
    1.66 +			**  we failed to look up our own name. Instead of
    1.67 +			**  giving our local hostname, we may give our IP
    1.68 +			**  number to show the server that we are at least
    1.69 +			**  willing to be honest. For the really picky ones.
    1.70 +			*/
    1.71  			DEBUG(5) debugf("failed to look up own host name.\n");
    1.72  			psb->helo_name = g_strdup_printf("[%s]", inet_ntoa(sname.sin_addr));
    1.73  		}
    1.74 @@ -276,20 +280,20 @@
    1.75  }
    1.76  
    1.77  /*
    1.78 -We first try EHLO, but if it fails HELO in a second fall back try.
    1.79 -This is what is requested by RFC 2821 (sec 3.2):
    1.80 -
    1.81 -	Once the server has sent the welcoming message and
    1.82 -	the client has received it, the client normally sends
    1.83 -	the EHLO command to the server, [...]
    1.84 -	For a particular connection attempt, if the server
    1.85 -	returns a "command not recognized" response to EHLO,
    1.86 -	the client SHOULD be able to fall back and send HELO.
    1.87 -
    1.88 -Up to and including version 0.3.0 masqmail used ESMTP only if the
    1.89 -string ``ESMTP'' appeared within the server's greeting message. This
    1.90 -made it impossible to use AUTH with servers that would send odd
    1.91 -greeting messages.
    1.92 +**  We first try EHLO, but if it fails HELO in a second fall back try.
    1.93 +**  This is what is requested by RFC 2821 (sec 3.2):
    1.94 +**
    1.95 +**      Once the server has sent the welcoming message and
    1.96 +**      the client has received it, the client normally sends
    1.97 +**      the EHLO command to the server, [...]
    1.98 +**      For a particular connection attempt, if the server
    1.99 +**      returns a "command not recognized" response to EHLO,
   1.100 +**      the client SHOULD be able to fall back and send HELO.
   1.101 +**
   1.102 +**  Up to and including version 0.3.0 masqmail used ESMTP only if the
   1.103 +**  string ``ESMTP'' appeared within the server's greeting message. This
   1.104 +**  made it impossible to use AUTH with servers that would send odd
   1.105 +**  greeting messages.
   1.106  */
   1.107  static gboolean
   1.108  smtp_helo(smtp_base *psb, gchar *helo)
   1.109 @@ -310,8 +314,10 @@
   1.110  		return FALSE;
   1.111  	}
   1.112  
   1.113 -	/* our guess that server understands EHLO could have been wrong,
   1.114 -	   try again with HELO */
   1.115 +	/*
   1.116 +	**  our guess that server understands EHLO could have been wrong,
   1.117 +	**  try again with HELO
   1.118 +	*/
   1.119  
   1.120  	fprintf(psb->out, "HELO %s\r\n", helo);
   1.121  	fflush(psb->out);
   1.122 @@ -357,13 +363,13 @@
   1.123  static void
   1.124  send_data_line(smtp_base *psb, gchar *data)
   1.125  {
   1.126 -	/* According to RFC 821 each line should be terminated with CRLF.
   1.127 -	   Since a dot on a line itself marks the end of data, each line
   1.128 -	   beginning with a dot is prepended with another dot.
   1.129 -	 */
   1.130 +	/*
   1.131 +	**  According to RFC 821 each line should be terminated with CRLF.
   1.132 +	**  Since a dot on a line itself marks the end of data, each line
   1.133 +	**  beginning with a dot is prepended with another dot.
   1.134 +	*/
   1.135  	gchar *ptr;
   1.136 -	gboolean new_line = TRUE;  /* previous versions assumed that each item was exactly one line.
   1.137 -	                              This is no longer the case */
   1.138 +	gboolean new_line = TRUE;  /* previous versions assumed that each item was exactly one line.  This is no longer the case */
   1.139  
   1.140  	ptr = data;
   1.141  	while (*ptr) {
   1.142 @@ -702,7 +708,8 @@
   1.143  }
   1.144  
   1.145  gint
   1.146 -smtp_out_msg(smtp_base *psb, message *msg, address *return_path, GList *rcpt_list, GList *hdr_list)
   1.147 +smtp_out_msg(smtp_base *psb, message *msg, address *return_path,
   1.148 +		GList *rcpt_list, GList *hdr_list)
   1.149  {
   1.150  	gint i, size;
   1.151  	gboolean ok = TRUE;
   1.152 @@ -732,8 +739,10 @@
   1.153  	}
   1.154  
   1.155  	if (ok) {
   1.156 -		/* pretend the message is a bit larger,
   1.157 -		   just in case the size calculation is buggy */
   1.158 +		/*
   1.159 +		**  pretend the message is a bit larger,
   1.160 +		**  just in case the size calculation is buggy
   1.161 +		*/
   1.162  		smtp_cmd_mailfrom(psb, return_path, psb->use_size ? size+SMTP_SIZE_ADD : 0);
   1.163  
   1.164  		if (!psb->use_pipelining) {
   1.165 @@ -775,8 +784,10 @@
   1.166  			}
   1.167  		}
   1.168  
   1.169 -		/* There is no point in going on if no recp.s were accpted.
   1.170 -		   But we can check that at this point only if not pipelining: */
   1.171 +		/*
   1.172 +		**  There is no point in going on if no recp.s were accpted.
   1.173 +		**  But we can check that at this point only if not pipelining:
   1.174 +		*/
   1.175  		ok = (ok && (psb->use_pipelining || (rcpt_accept > 0)));
   1.176  		if (ok) {
   1.177  
   1.178 @@ -786,17 +797,22 @@
   1.179  			DEBUG(4) debugf("C: DATA\r\n");
   1.180  
   1.181  			if (psb->use_pipelining) {
   1.182 -				/* the first pl'ed command was MAIL FROM
   1.183 -				   the last was DATA, whose response can be handled by the 'normal' code
   1.184 -				   all in between were RCPT TO:
   1.185 -				 */
   1.186 +				/*
   1.187 +				**  the first pl'ed command was MAIL FROM
   1.188 +				**  the last was DATA, whose response can be
   1.189 +				**  handled by the 'normal' code all in
   1.190 +				**  between were RCPT TO:
   1.191 +				*/
   1.192  				/* response to MAIL FROM: */
   1.193  				if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) {
   1.194  					if ((ok = check_response(psb, FALSE))) {
   1.195  
   1.196 -						/* response(s) to RCPT TO:
   1.197 -						   this is very similar to the sequence above for no pipeline
   1.198 -						 */
   1.199 +						/*
   1.200 +						**  response(s) to RCPT TO:
   1.201 +						**  this is very similar to
   1.202 +						**  the sequence above for no
   1.203 +						**  pipeline
   1.204 +						*/
   1.205  						for (i = 0; i < rcpt_cnt; i++) {
   1.206  							if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) {
   1.207  								address *rcpt = g_list_nth_data(rcpt_list, i);
   1.208 @@ -804,10 +820,12 @@
   1.209  									rcpt_accept++;
   1.210  									addr_mark_delivered(rcpt);
   1.211  								} else {
   1.212 -									/* if server returned an error 4xx or 5xx for one recp. we
   1.213 -									   may still try the others. But if it is a timeout, eof
   1.214 -									   or unexpected response, it is more serious and we
   1.215 -									   should give up. */
   1.216 +									/*
   1.217 +									** if server returned an error 4xx or 5xx for one recp. we
   1.218 +									**  may still try the others. But if it is a timeout, eof
   1.219 +									**  or unexpected response, it is more serious and we
   1.220 +									**  should give up.
   1.221 +									*/
   1.222  									if ((psb->error != smtp_trylater) &&
   1.223  										(psb->error != smtp_fail)) {
   1.224  										ok = FALSE;
   1.225 @@ -870,9 +888,11 @@
   1.226  				         msg->uid, addr_string(rcpt), psb->remote_host);
   1.227  		}
   1.228  	} else {
   1.229 -		/* if something went wrong,
   1.230 -		   we have to unmark the rcpts prematurely marked as delivered
   1.231 -		   and mark the status */
   1.232 +		/*
   1.233 +		**  if something went wrong,
   1.234 +		**  we have to unmark the rcpts prematurely marked as
   1.235 +		**  delivered and mark the status
   1.236 +		*/
   1.237  		smtp_out_mark_rcpts(psb, rcpt_list);
   1.238  
   1.239  		/* log the failure: */
   1.240 @@ -895,7 +915,8 @@
   1.241  }
   1.242  
   1.243  gint
   1.244 -smtp_deliver(gchar *host, gint port, GList *resolve_list, message *msg, address *return_path, GList *rcpt_list)
   1.245 +smtp_deliver(gchar *host, gint port, GList *resolve_list, message *msg,
   1.246 +		address *return_path, GList *rcpt_list)
   1.247  {
   1.248  	smtp_base *psb;
   1.249  	smtp_error err;