masqmail-0.2

changeset 13:49dab67fe461

code beautifying
author meillo@marmaro.de
date Wed, 29 Oct 2008 21:10:18 +0100
parents 9fb7ddbaf129
children a8f3424347dc
files src/accept.c src/address.c src/conf.c
diffstat 3 files changed, 33 insertions(+), 59 deletions(-) [+]
line diff
     1.1 --- a/src/accept.c	Wed Oct 29 16:34:13 2008 +0100
     1.2 +++ b/src/accept.c	Wed Oct 29 21:10:18 2008 +0100
     1.3 @@ -306,14 +306,17 @@
     1.4  
     1.5  				if ((msg->return_path = create_address_qualified(addr, FALSE, msg->received_host)) != NULL) {
     1.6  					DEBUG(3) debugf("setting return_path to %s\n", addr_string(msg->return_path));
     1.7 -					msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN, "X-Warning: return path set from %s address\n", hdr->id == HEAD_SENDER ? "Sender:" : "From:"));
     1.8 +					msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN,
     1.9 +					                              "X-Warning: return path set from %s address\n",
    1.10 +					                              hdr->id == HEAD_SENDER ? "Sender:" : "From:"));
    1.11  				}
    1.12  				g_free(addr);
    1.13  			}
    1.14  			if (msg->return_path == NULL) {  /* no Sender: or From: or create_address_qualified failed */
    1.15  				msg->return_path = create_address_qualified("postmaster", TRUE, conf.host_name);
    1.16  				DEBUG(3) debugf("setting return_path to %s\n", addr_string(msg->return_path));
    1.17 -				msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN, "X-Warning: real return path is unkown\n"));
    1.18 +				msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN,
    1.19 +				                              "X-Warning: real return path is unkown\n"));
    1.20  			}
    1.21  		}
    1.22  
    1.23 @@ -342,23 +345,19 @@
    1.24  			msg->hdr_list = g_list_append(msg->hdr_list,
    1.25  			                msg->full_sender_name
    1.26  			                ?
    1.27 -			                  create_header(HEAD_FROM,
    1.28 -			                  "From: \"%s\" <%s@%s>\n",
    1.29 -			                  msg->full_sender_name,
    1.30 -			                  msg->return_path->local_part,
    1.31 -			                  msg->return_path->
    1.32 -			                  domain)
    1.33 +			                  create_header(HEAD_FROM, "From: \"%s\" <%s@%s>\n", msg->full_sender_name,
    1.34 +			                                msg->return_path->local_part, msg->return_path->domain)
    1.35  			                :
    1.36  			                  create_header(HEAD_FROM, "From: <%s@%s>\n",
    1.37 -			                  msg->return_path->local_part,
    1.38 -			                  msg->return_path->domain)
    1.39 +			                                msg->return_path->local_part, msg->return_path->domain)
    1.40  			                );
    1.41  		}
    1.42  		if ((flags & ACC_HEAD_FROM_RCPT) && !has_rcpt) {
    1.43  			GList *node;
    1.44  			DEBUG(3) debugf("adding 'To' header(s)\n");
    1.45  			for (node = g_list_first(msg->rcpt_list); node; node = g_list_next(node)) {
    1.46 -				msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_TO, "To: %s\n", addr_string(msg-> return_path)));
    1.47 +				msg->hdr_list = g_list_append(msg->hdr_list,
    1.48 +				                              create_header(HEAD_TO, "To: %s\n", addr_string(msg-> return_path)));
    1.49  			}
    1.50  		}
    1.51  		if ((flags & ACC_DEL_BCC) && !has_to_or_cc) {
    1.52 @@ -372,7 +371,8 @@
    1.53  		}
    1.54  		if (!has_id) {
    1.55  			DEBUG(3) debugf("adding 'Message-ID:' header\n");
    1.56 -			msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_MESSAGE_ID, "Message-ID: <%s@%s>\n", msg->uid, conf.host_name));
    1.57 +			msg->hdr_list = g_list_append(msg->hdr_list,
    1.58 +			                              create_header(HEAD_MESSAGE_ID, "Message-ID: <%s@%s>\n", msg->uid, conf.host_name));
    1.59  		}
    1.60  	}
    1.61  
    1.62 @@ -390,40 +390,20 @@
    1.63  		}
    1.64  
    1.65  		if (msg->received_host == NULL) {
    1.66 -			hdr = create_header(HEAD_RECEIVED,
    1.67 -			                    "Received: from %s by %s"
    1.68 -			                    " with %s (%s %s) id %s%s;"
    1.69 -			                    " %s\n",
    1.70 -			                    passwd->pw_name, conf.host_name,
    1.71 -			                    prot_names[msg->received_prot],
    1.72 -			                    PACKAGE, VERSION,
    1.73 -			                    msg->uid, for_string ? for_string : "",
    1.74 -			                    rec_timestamp());
    1.75 +			hdr = create_header(HEAD_RECEIVED, "Received: from %s by %s with %s (%s %s) id %s%s; %s\n",
    1.76 +			                    passwd->pw_name, conf.host_name, prot_names[msg->received_prot],
    1.77 +			                    PACKAGE, VERSION, msg->uid, for_string ? for_string : "", rec_timestamp());
    1.78  		} else {
    1.79  #ifdef ENABLE_IDENT
    1.80  			DEBUG(5) debugf("adding 'Received:' header (5)\n");
    1.81 -			hdr = create_header(HEAD_RECEIVED,
    1.82 -			                    "Received: from %s (ident=%s) by %s"
    1.83 -			                    " with %s (%s %s) id %s%s;"
    1.84 -			                    " %s\n",
    1.85 -			                    msg->received_host,
    1.86 -			                    msg->ident ? msg->ident : "unknown",
    1.87 -			                    conf.host_name,
    1.88 -			                    prot_names[msg->received_prot],
    1.89 -			                    PACKAGE, VERSION,
    1.90 -			                    msg->uid, for_string ? for_string : "",
    1.91 +			hdr = create_header(HEAD_RECEIVED, "Received: from %s (ident=%s) by %s with %s (%s %s) id %s%s; %s\n",
    1.92 +			                    msg->received_host, msg->ident ? msg->ident : "unknown", conf.host_name,
    1.93 +			                    prot_names[msg->received_prot], PACKAGE, VERSION, msg->uid, for_string ? for_string : "",
    1.94  			                    rec_timestamp());
    1.95  #else
    1.96 -			hdr = create_header(HEAD_RECEIVED,
    1.97 -			                    "Received: from %s by %s"
    1.98 -			                    " with %s (%s %s) id %s%s;"
    1.99 -			                    " %s\n",
   1.100 -			                    msg->received_host,
   1.101 -			                    conf.host_name,
   1.102 -			                    prot_names[msg->received_prot],
   1.103 -			                    PACKAGE, VERSION,
   1.104 -			                    msg->uid, for_string ? for_string : "",
   1.105 -			                    rec_timestamp());
   1.106 +			hdr = create_header(HEAD_RECEIVED, "Received: from %s by %s with %s (%s %s) id %s%s; %s\n",
   1.107 +			                    msg->received_host, conf.host_name, prot_names[msg->received_prot],
   1.108 +			                    PACKAGE, VERSION, msg->uid, for_string ? for_string : "", rec_timestamp());
   1.109  #endif
   1.110  		}
   1.111  		header_fold(hdr);
   1.112 @@ -435,8 +415,8 @@
   1.113  
   1.114  	/* write message to spool: */
   1.115  	/* accept is no longer responsible for this
   1.116 -	   if(!spool_write(msg, TRUE))
   1.117 -	   return AERR_NOSPOOL;
   1.118 +	   if (!spool_write(msg, TRUE))
   1.119 +	     return AERR_NOSPOOL;
   1.120  	 */
   1.121  	return AERR_OK;
   1.122  }
     2.1 --- a/src/address.c	Wed Oct 29 16:34:13 2008 +0100
     2.2 +++ b/src/address.c	Wed Oct 29 21:10:18 2008 +0100
     2.3 @@ -43,8 +43,7 @@
     2.4  	return addr;
     2.5  }
     2.6  
     2.7 -/* nothing special about pipes here,
     2.8 -   but its only called for that purpose */
     2.9 +/* nothing special about pipes here, but its only called for that purpose */
    2.10  address*
    2.11  create_address_pipe(gchar * path)
    2.12  {
    2.13 @@ -103,9 +102,8 @@
    2.14  gboolean
    2.15  addr_isequal(address * addr1, address * addr2)
    2.16  {
    2.17 -	return
    2.18 -		(strcmp(addr1->local_part, addr2->local_part) == 0) &&
    2.19 -		(strcasecmp(addr1->domain, addr2->domain) == 0);
    2.20 +	return (strcmp(addr1->local_part, addr2->local_part) == 0)
    2.21 +	       && (strcasecmp(addr1->domain, addr2->domain) == 0);
    2.22  }
    2.23  
    2.24  /* searches in ancestors of addr1 */
     3.1 --- a/src/conf.c	Wed Oct 29 16:34:13 2008 +0100
     3.2 +++ b/src/conf.c	Wed Oct 29 21:10:18 2008 +0100
     3.3 @@ -16,11 +16,11 @@
     3.4      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     3.5  */
     3.6  
     3.7 +#include <pwd.h>
     3.8 +#include <grp.h>
     3.9 +
    3.10  #include "masqmail.h"
    3.11  
    3.12 -#include "pwd.h"
    3.13 -#include "grp.h"
    3.14 -
    3.15  masqmail_conf conf;
    3.16  
    3.17  void
    3.18 @@ -107,9 +107,7 @@
    3.19  	return list;
    3.20  }
    3.21  
    3.22 -/* given a semicolon separated string, this function
    3.23 -   makes a GList out of it.
    3.24 -*/
    3.25 +/* given a semicolon separated string, this function makes a GList out of it. */
    3.26  GList*
    3.27  parse_list(gchar * line, gboolean read_file)
    3.28  {
    3.29 @@ -354,8 +352,7 @@
    3.30  
    3.31  	c = fgetc(in);
    3.32  	if (c != '\"') {
    3.33 -		while ((isalnum(c) || c == '_' || c == '-' || c == '.' || c == '/'
    3.34 -		       || c == '@' || c == ';')
    3.35 +		while ((isalnum(c) || c == '_' || c == '-' || c == '.' || c == '/' || c == '@' || c == ';')
    3.36  		       && (ptr < buf + size - 1)
    3.37  		       && (c != EOF)) {
    3.38  			*ptr = c;
    3.39 @@ -368,7 +365,7 @@
    3.40  		gboolean escape = FALSE;
    3.41  		c = fgetc(in);
    3.42  		while (((c != '\"') || escape) && (ptr < buf + size - 1)) {
    3.43 -			if (c != '\n') {	/* ignore line breaks */
    3.44 +			if (c != '\n') {  /* ignore line breaks */
    3.45  				if ((c == '\\') && (!escape)) {
    3.46  					escape = TRUE;
    3.47  				} else {
    3.48 @@ -410,8 +407,7 @@
    3.49  				return TRUE;
    3.50  			}
    3.51  		} else {
    3.52 -			fprintf(stderr, "'=' expected after %s, char was '%c'\n", lval,
    3.53 -					c);
    3.54 +			fprintf(stderr, "'=' expected after %s, char was '%c'\n", lval, c);
    3.55  		}
    3.56  	}
    3.57  	return FALSE;