changeset 15:f671821d8222

code beautifying; 0 -> \0 if appropriate
author meillo@marmaro.de
date Thu, 06 Nov 2008 09:18:38 +0100 (2008-11-06)
parents a8f3424347dc
children 163aa299bedb
files src/deliver.c src/expand.c src/fail_msg.c src/get.c src/header.c src/listen.c src/local.c src/log.c src/lookup.c src/online.c src/parse.c src/peopen.c src/permissions.c src/pop3_in.c src/queue.c src/readsock.c src/rewrite.c src/route.c src/smtp_in.c src/smtp_out.c src/spool.c src/tables.c src/timeival.c
diffstat 23 files changed, 136 insertions(+), 179 deletions(-) [+]
line wrap: on
line diff
--- a/src/deliver.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/deliver.c	Thu Nov 06 09:18:38 2008 +0100
@@ -16,15 +16,15 @@
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
-#include "masqmail.h"
-#include "smtp_out.h"
 #include <fnmatch.h>
 #include <sysexits.h>
 #include <netdb.h>
 
+#include "masqmail.h"
+#include "smtp_out.h"
+
 /* collect failed/defered rcpts for failure/warning messages */
-/* returns TRUE if either there are no failures or a
-   failure message has been successfully sent */
+/* returns TRUE if either there are no failures or a failure message has been successfully sent */
 gboolean
 delivery_failures(message * msg, GList * rcpt_list, gchar * err_fmt, ...)
 {
@@ -92,11 +92,8 @@
 		address *ret_path = msg->return_path;
 		header *retpath_hdr, *envto_hdr;
 
-		/* we need a private copy of the hdr list because we add headers here
-		   that belong to the rcpt only.
-		   g_list_copy copies only the nodes, so it is safe to
-		   g_list_free it
-		 */
+		/* we need a private copy of the hdr list because we add headers here that belong to the rcpt only.
+		   g_list_copy copies only the nodes, so it is safe to g_list_free it */
 		hdr_list = g_list_copy(msg->hdr_list);
 		retpath_hdr = create_header(HEAD_ENVELOPE_TO, "Envelope-to: %s\n", addr_string(env_addr));
 		envto_hdr = create_header(HEAD_RETURN_PATH, "Return-path: %s\n", addr_string(ret_path));
@@ -109,7 +106,8 @@
 			if (pipe_out(msg, hdr_list, rcpt, &(rcpt->local_part[1]),
 			    (conf.pipe_fromline ? MSGSTR_FROMLINE : 0)
 			    | (conf.pipe_fromhack ? MSGSTR_FROMHACK : 0))) {
-				logwrite(LOG_NOTICE, "%s => %s <%s@%s> with pipe\n", msg->uid, rcpt->local_part, env_addr->local_part, env_addr->domain);
+				logwrite(LOG_NOTICE, "%s => %s <%s@%s> with pipe\n",
+				         msg->uid, rcpt->local_part, env_addr->local_part, env_addr->domain);
 				addr_mark_delivered(rcpt);
 				ok = TRUE;
 			} else {
@@ -216,9 +214,7 @@
 	return ok;
 }
 
-/* make a list of rcpt's of a message that are local
-   return a new copy of the list
-*/
+/* make a list of rcpt's of a message that are local return a new copy of the list */
 void
 msg_rcptlist_local(GList * rcpt_list, GList ** p_local_list, GList ** p_nonlocal_list)
 {
@@ -315,11 +311,9 @@
 	return ok;
 }
 
-/* deliver list of messages to one host
-   and finishes them if the message was delivered to at least one rcpt.
+/* deliver list of messages to one host and finishes them if the message was delivered to at least one rcpt.
    Returns TRUE if at least one msg was delivered to at least one rcpt.
 */
-
 gboolean
 deliver_msglist_host_smtp(connect_route * route, GList * msgout_list, gchar * host, GList * res_list)
 {
@@ -368,8 +362,7 @@
 				gboolean flag, ok_msg = FALSE, ok_fail = FALSE;
 				message *msg = msgout->msg;
 
-				/* we may have to read the data at this point
-				   and remember if we did */
+				/* we may have to read the data at this point and remember if we did */
 				flag = (msg->data_list == NULL);
 				if (flag) {
 					if (!spool_read_data(msg)) {
@@ -380,7 +373,8 @@
 
 				smtp_out_msg(psb, msg, msgout->return_path, msgout->rcpt_list, msgout->hdr_list);
 
-				ok_fail = delivery_failures(msg, msgout->rcpt_list, "while connected with %s, the server replied\n\t%s", host, psb->buffer);
+				ok_fail = delivery_failures(msg, msgout->rcpt_list,
+				                            "while connected with %s, the server replied\n\t%s", host, psb->buffer);
 
 				if ((psb->error == smtp_eof)
 				    || (psb->error == smtp_timeout)) {
@@ -437,11 +431,9 @@
 					addr_mark_defered(rcpt);
 				}
 				if (route->wrapper
-				    ? delivery_failures(msgout->msg, msgout->rcpt_list,
-				                        "could not open wrapper:\n\t%s",
+				    ? delivery_failures(msgout->msg, msgout->rcpt_list, "could not open wrapper:\n\t%s",
 				                        strerror(errno))
-				    : delivery_failures(msgout->msg, msgout->rcpt_list,
-				                        "could not open connection to %s:%d :\n\t%s",
+				    : delivery_failures(msgout->msg, msgout->rcpt_list, "could not open connection to %s:%d :\n\t%s",
 				                        host, port, h_errno != 0 ? hstrerror(h_errno) : strerror(errno)))
 					deliver_finish(msgout);
 			}
@@ -470,8 +462,7 @@
 {
 	gboolean ok = FALSE;
 
-	DEBUG(5)
-		debugf("deliver_route_msgout_list entered, route->name = %s\n", route->name);
+	DEBUG(5) debugf("deliver_route_msgout_list entered, route->name = %s\n", route->name);
 
 	if (route->mail_host != NULL) {
 		/* this is easy... */
@@ -506,8 +497,7 @@
 
 /*
   calls route_prepare_msg()
-  delivers messages in msg_list using route
-  by calling deliver_route_msgout_list()
+  delivers messages in msg_list using route by calling deliver_route_msgout_list()
 */
 gboolean
 deliver_route_msg_list(connect_route * route, GList * msgout_list)
@@ -524,12 +514,10 @@
 		GList *rcpt_list_non_delivered = NULL;
 		GList *rcpt_node;
 
-		/* we have to delete already delivered rcpt's
-		   because a previous route may have delivered to it */
+		/* we have to delete already delivered rcpt's because a previous route may have delivered to it */
 		foreach(msgout_cloned->rcpt_list, rcpt_node) {
 			address *rcpt = (address *) (rcpt_node->data);
-			/* failed addresses already have been bounced
-			   - there should be a better way to handle those. */
+			/* failed addresses already have been bounced - there should be a better way to handle those. */
 			if (!addr_is_delivered(rcpt) && !addr_is_failed(rcpt)
 			    && !(rcpt->flags & ADDR_FLAG_LAST_ROUTE))
 				rcpt_list_non_delivered = g_list_append(rcpt_list_non_delivered, rcpt);
@@ -591,10 +579,9 @@
 	}
 }
 
-/* after delivery attempts, we check if there are any
-   rcpt addresses left in the message.
-   If all addresses have been completed, the spool files will
-   be deleted, otherwise the header spool will be written back.
+/* after delivery attempts, we check if there are any rcpt addresses left in the message.
+   If all addresses have been completed, the spool files will be deleted,
+   otherwise the header spool will be written back.
    We never changed the data spool, so there is no need to write that back.
 
    returns TRUE if all went well.
@@ -616,10 +603,8 @@
 		if (!addr_is_finished_children(rcpt))
 			finished = FALSE;
 		else {
-			/* if ALL children have been delivered,
-			   mark parent as delivered.
-			   if there is one or more not delivered,
-			   it must have failed, we mark the parent as failed as well.
+			/* if ALL children have been delivered, mark parent as delivered.
+			   if there is one or more not delivered, it must have failed, we mark the parent as failed as well.
 			 */
 			if (addr_is_delivered_children(rcpt)) {
 				addr_mark_delivered(rcpt);
--- a/src/expand.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/expand.c	Thu Nov 06 09:18:38 2008 +0100
@@ -96,7 +96,7 @@
 					j++;
 				}
 			}
-			*vq = 0;
+			*vq = '\0';
 
 			if (j < MAX_VAR) {
 				/* search var */
@@ -120,7 +120,7 @@
 			p++;
 		}
 	}
-	*q = 0;
+	*q = '\0';
 
 	if (i >= (result_len - 1))
 		return -3;
--- a/src/fail_msg.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/fail_msg.c	Thu Nov 06 09:18:38 2008 +0100
@@ -29,7 +29,7 @@
 	address *ret_path = NULL;
 
 	/* do not bounce bounces, send to postmaster instead */
-	if (msg->return_path->local_part[0] == 0) {
+	if (msg->return_path->local_part[0] == '\0') {
 		GList *node;
 
 		ret_path = create_address_qualified("postmaster", TRUE, conf.host_name);
@@ -79,8 +79,7 @@
 								fputs(hdr->header, out);
 							}
 						} else if (strncmp(fmt, "@msg_body", 9) == 0) {
-							/* we may have to read the data at this point
-							   and remember if we did */
+							/* we may have to read the data at this point and remember if we did */
 							gboolean flag = (msg->data_list == NULL);
 							if (flag) {
 								if (!spool_read_data(msg)) {
--- a/src/get.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/get.c	Thu Nov 06 09:18:38 2008 +0100
@@ -62,8 +62,10 @@
 	   and the server name, to prevent more than one connection at the same time
 	   to the same server and the same user. This way concurrent connections
 	   are possible to different servers or different users */
-	hitch_name = g_strdup_printf("%s/masqmail-get-%s@%s-%d.lock", conf.lock_dir, gc->login_user, gc->server_name, getpid());
-	lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock", conf.lock_dir, gc->login_user, gc->server_name);
+	hitch_name = g_strdup_printf("%s/masqmail-get-%s@%s-%d.lock",
+	                             conf.lock_dir, gc->login_user, gc->server_name, getpid());
+	lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock",
+	                            conf.lock_dir, gc->login_user, gc->server_name);
 
 	ok = dot_lock(lock_name, hitch_name);
 	if (!ok)
@@ -98,7 +100,8 @@
 static gboolean
 get_unlock(get_conf * gc)
 {
-	gchar *lock_name lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock", conf.lock_dir, gc->login_user, gc->server_name);
+	gchar *lock_name lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock",
+	                                             conf.lock_dir, gc->login_user, gc->server_name);
 
 	dot_unlock(lock_name);
 	g_free(lock_name);
@@ -109,7 +112,8 @@
 static void
 get_unlock(get_conf * gc, int fd)
 {
-	gchar *lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock", conf.lock_dir, gc->login_user, gc->server_name);
+	gchar *lock_name = g_strdup_printf("%s/masqmail-get-%s@%s.lock",
+	                                   conf.lock_dir, gc->login_user, gc->server_name);
 
 	flock(fd, LOCK_UN);
 	close(fd);
@@ -351,8 +355,7 @@
 				}
 			}
 		} else {
-			/* If select returns 0, the interval time has elapsed.
-			   We start a new get process */
+			/* If select returns 0, the interval time has elapsed. We start a new get process */
 			int pid;
 			signal(SIGCHLD, sigchld_handler);
 			if ((pid = fork()) == 0) {
@@ -384,7 +387,8 @@
 		ok = pop3_login(gc->server_name, gc->server_port, resolve_list, gc->login_user, gc->login_pass, flags);
 	} else if (strcmp(gc->protocol, "apop") == 0) {
 		DEBUG(3) debugf ("attempting to login for user %s, host = %s with apop\n", gc->login_user, gc->server_name);
-		ok = pop3_login(gc->server_name, gc->server_port, resolve_list, gc->login_user, gc->login_pass, flags | POP3_FLAG_APOP);
+		ok = pop3_login(gc->server_name, gc->server_port, resolve_list, gc->login_user,
+		                gc->login_pass, flags | POP3_FLAG_APOP);
 	} else {
 		logwrite(LOG_ALERT, "get protocol %s unknown\n", gc->protocol);
 	}
--- a/src/header.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/header.c	Thu Nov 06 09:18:38 2008 +0100
@@ -18,30 +18,18 @@
 #include "masqmail.h"
 
 header_name header_names[] = {
-	{"From", HEAD_FROM,}
-	,
-	{"Sender", HEAD_SENDER,}
-	,
-	{"To", HEAD_TO,}
-	,
-	{"Cc", HEAD_CC,}
-	,
-	{"Bcc", HEAD_BCC,}
-	,
-	{"Date", HEAD_DATE,}
-	,
-	{"Message-Id", HEAD_MESSAGE_ID,}
-	,
-	{"Reply-To", HEAD_REPLY_TO,}
-	,
-	{"Subject", HEAD_SUBJECT,}
-	,
-	{"Return-Path", HEAD_RETURN_PATH,}
-	,
-	{"Envelope-To", HEAD_ENVELOPE_TO,}
-	,
-	{"Received", HEAD_RECEIVED}
-	,
+	{"From", HEAD_FROM,},
+	{"Sender", HEAD_SENDER,},
+	{"To", HEAD_TO,},
+	{"Cc", HEAD_CC,},
+	{"Bcc", HEAD_BCC,},
+	{"Date", HEAD_DATE,},
+	{"Message-Id", HEAD_MESSAGE_ID,},
+	{"Reply-To", HEAD_REPLY_TO,},
+	{"Subject", HEAD_SUBJECT,},
+	{"Return-Path", HEAD_RETURN_PATH,},
+	{"Envelope-To", HEAD_ENVELOPE_TO,},
+	{"Received", HEAD_RECEIVED},
 };
 
 /* this was borrowed from exim and slightly changed */
@@ -100,7 +88,7 @@
 
 			while (*p != ':' && q < buf + 63 && *p)
 				*(q++) = *(p++);
-			*q = 0;
+			*q = '\0';
 
 			if (strcasecmp(buf, hdr_str) == 0)
 				found_list = g_list_append(found_list, hdr);
@@ -149,7 +137,7 @@
 	q = tmp_hdr;
 
 	if (p[len - 1] == '\n')
-		p[len - 1] = 0;
+		p[len - 1] = '\0';
 
 	while (*p) {
 		gint i, l;
@@ -184,7 +172,7 @@
 			i++;
 		}
 		*(q++) = '\n';
-		*(q++) = *(p++);		/* this is either space, tab or 0 */
+		*(q++) = *(p++);  /* this is either space, tab or 0 */
 	}
 	{
 		gchar *new_hdr;
@@ -257,7 +245,7 @@
 
 	while (*p && (*p != ':') && (q < buf + 63))
 		*(q++) = *(p++);
-	*q = 0;
+	*q = '\0';
 
 	if (*p != ':')
 		return NULL;
--- a/src/listen.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/listen.c	Thu Nov 06 09:18:38 2008 +0100
@@ -16,10 +16,11 @@
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
-#include "masqmail.h"
 #include <sys/wait.h>
 #include <sys/types.h>
 
+#include "masqmail.h"
+
 static int volatile sighup_seen = 0;
 
 static void
@@ -132,8 +133,7 @@
 	signal(SIGHUP, sighup_handler);
 	signal(SIGCHLD, sigchld_handler);
 
-	/* now that we have our socket(s),
-	   we can give up root privileges */
+	/* now that we have our socket(s), we can give up root privileges */
 	if (!conf.run_as_user) {
 		if (setegid(conf.mail_gid) != 0) {
 			logwrite(LOG_ALERT, "could not change gid to %d: %s\n", conf.mail_gid, strerror(errno));
@@ -172,8 +172,7 @@
 			}
 		}
 		/* Block until input arrives on one or more active sockets,
-		   or signal arrives,
-		   or queuing interval time elapsed (if qival > 0) */
+		   or signal arrives, or queuing interval time elapsed (if qival > 0) */
 		read_fd_set = active_fd_set;
 		if ((sel_ret = select(FD_SETSIZE, &read_fd_set, NULL, NULL, qival > 0 ? &tm : NULL)) < 0) {
 			if (errno != EINTR) {
--- a/src/local.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/local.c	Thu Nov 06 09:18:38 2008 +0100
@@ -16,9 +16,10 @@
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
+#include <sys/wait.h>
+
 #include "masqmail.h"
 #include "peopen.h"
-#include <sys/wait.h>
 
 static void
 message_stream(FILE * out, message * msg, GList * hdr_list, guint flags)
@@ -92,9 +93,7 @@
 				if (fcntl(fileno(out), F_SETLK, &lock) != -1) {
 #endif
 					fchmod(fileno(out), 0600);
-
 					message_stream(out, msg, hdr_list, MSGSTR_FROMLINE | MSGSTR_FROMHACK);
-
 					ok = TRUE;
 
 					/* close when still user */
@@ -211,10 +210,9 @@
 					if (i == 3) {
 						FILE *out;
 						mode_t saved_mode = umask(066);
-						/* the qmail style unique works only if delivering
-						   with different process. We do not fork for each delivery,
-						   so our uid is more unique. Hope it is compatible with all
-						   MUAs.
+						/* the qmail style unique works only if delivering with different process.
+						   We do not fork for each delivery, so our uid is more unique.
+						   Hope it is compatible with all MUAs.
 						 */
 						gchar *filename = g_strdup_printf("%s/tmp/%s.%s", path, msg->uid, conf.host_name);
 
@@ -227,7 +225,8 @@
 							if (fflush(out) == EOF)
 								ok = FALSE;
 							else if (fdatasync(fileno(out)) != 0) {
-								if (errno != EINVAL)  /* some fs do not support this..  I hope this also means that it is not necessary */
+								if (errno != EINVAL)
+									/* some fs do not support this..  I hope this also means that it is not necessary */
 									ok = FALSE;
 							}
 							fclose(out);
--- a/src/log.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/log.c	Thu Nov 06 09:18:38 2008 +0100
@@ -16,9 +16,9 @@
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
-#include "masqmail.h"
+#include <sysexits.h>
 
-#include "sysexits.h"
+#include "masqmail.h"
 
 static char *_sysexit_strings[] = {
 	"command line usage error",
@@ -109,8 +109,7 @@
 void
 vlogwrite(int pri, const char *fmt, va_list args)
 {
-	if ((conf.do_verbose && (pri & LOG_VERBOSE)) || (pri == LOG_ALERT)
-		|| (pri == LOG_WARNING)) {
+	if ((conf.do_verbose && (pri & LOG_VERBOSE)) || (pri == LOG_ALERT) || (pri == LOG_WARNING)) {
 		va_list args_copy;
 		va_copy(args_copy, args);
 		vfprintf(stdout, fmt, args_copy);
@@ -120,7 +119,6 @@
 
 	pri &= ~LOG_VERBOSE;
 	if (pri) {
-
 		if (conf.use_syslog)
 			vsyslog(pri, fmt, args);
 		else {
@@ -159,7 +157,6 @@
 
 	if (debugfile) {
 		fprintf(debugfile, "%s [%d] ", buf, getpid());
-
 		vfprintf(debugfile, fmt, args);
 		fflush(debugfile);
 	} else {
--- a/src/lookup.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/lookup.c	Thu Nov 06 09:18:38 2008 +0100
@@ -23,10 +23,8 @@
 #include "masqmail.h"
 
 #ifdef RESOLV_TEST
-
 #undef DEBUG
 #define DEBUG(x) if(x > 0)
-
 #define debugf g_print
 #endif
 
@@ -343,26 +341,20 @@
 	GList *addr_list = NULL, *node;
 
 	g_print("starting res_init()\n");
-
 	g_print("retrans = %d, retry = %d\n", _res.retrans, _res.retry);
-
 	if (res_init() == 0) {
-
 		addr_list = resolve_dns_a(NULL, argv[1]);
 		g_print("A:\n");
-
 		foreach(addr_list, node) {
 			mxip_addr *p_mxip = (mxip_addr *) (node->data);
-
 			printf("name = %s\n IP = %s\n", p_mxip->name, inet_ntoa(*(struct in_addr *) &(p_mxip->ip)));
 		}
 		addr_list = resolve_dns_mx(NULL, argv[1]);
 		g_print("MX:\n");
-
 		foreach(addr_list, node) {
 			mxip_addr *p_mxip = (mxip_addr *) (node->data);
-
-			printf("name = %s\n IP = %s pref = %d\n", p_mxip->name, inet_ntoa(*(struct in_addr *) &(p_mxip->ip)), p_mxip->pref);
+			printf("name = %s\n IP = %s pref = %d\n", p_mxip->name,
+			       inet_ntoa(*(struct in_addr *) &(p_mxip->ip)), p_mxip->pref);
 		}
 		{
 			guint32 ip;
@@ -371,6 +363,5 @@
 		}
 	} else
 		printf("res_init() failed.\n");
-
 }
 #endif
--- a/src/online.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/online.c	Thu Nov 06 09:18:38 2008 +0100
@@ -18,6 +18,7 @@
 
 #include <sys/stat.h>
 #include <sys/wait.h>
+
 #include "masqmail.h"
 #include "mserver.h"
 #include "peopen.h"
--- a/src/parse.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/parse.c	Thu Nov 06 09:18:38 2008 +0100
@@ -125,7 +125,8 @@
 }
 
 gboolean
-parse_address_rfc822(gchar* string, gchar** local_begin, gchar** local_end, gchar** domain_begin, gchar** domain_end, gchar** address_end)
+parse_address_rfc822(gchar* string, gchar** local_begin, gchar** local_end, gchar** domain_begin,
+                     gchar** domain_end, gchar** address_end)
 {
 	gint angle_brackets = 0;
 
@@ -262,7 +263,8 @@
 }
 
 gboolean
-parse_address_rfc821(gchar* string, gchar** local_begin, gchar** local_end, gchar** domain_begin, gchar** domain_end, gchar** address_end)
+parse_address_rfc821(gchar* string, gchar** local_begin, gchar** local_end, gchar** domain_begin,
+                     gchar** domain_end, gchar** address_end)
 {
 	gint angle_brackets = 0;
 
@@ -352,7 +354,6 @@
 
   parses both rfc 821 and rfc 822 addresses, depending on flag is_rfc821
 */
-
 address*
 _create_address(gchar * string, gchar ** end, gboolean is_rfc821)
 {
@@ -364,7 +365,8 @@
 		address *addr = g_malloc(sizeof(address));
 		addr->address = g_strdup("");
 		addr->local_part = g_strdup("");
-		addr->domain = g_strdup("");  /* 'NULL' address (failure notice), "" makes sure it will not be qualified with a hostname */
+		addr->domain = g_strdup("");  /* 'NULL' address (failure notice),
+		                                 "" makes sure it will not be qualified with a hostname */
 		return addr;
 	}
 
@@ -375,7 +377,6 @@
 		address *addr = g_malloc(sizeof(address));
 		gchar *p = addr_end;
 
-
 		memset(addr, 0, sizeof(address));
 
 		if (loc_beg[0] == '|') {
@@ -397,7 +398,8 @@
 			addr->domain = g_strndup(dom_beg, dom_end - dom_beg);
 		} else {
 			if (addr->local_part[0] == 0)
-				addr->domain = g_strdup("");  /* 'NULL' address (failure notice), "" makes sure it will not be qualified with a hostname */
+				addr->domain = g_strdup("");  /* 'NULL' address (failure notice),
+				                                 "" makes sure it will not be qualified with a hostname */
 			else
 				addr->domain = NULL;
 		}
--- a/src/peopen.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/peopen.c	Thu Nov 06 09:18:38 2008 +0100
@@ -7,10 +7,9 @@
 #include <unistd.h>
 #include <string.h>
 #include <sys/types.h>
+#include <sysexits.h>
 
 #include "peopen.h"
-#include "sysexits.h"
-
 #include "masqmail.h"
 
 static void
@@ -35,6 +34,7 @@
 	int i = 0;
 
 	arr = (char **) malloc(sizeof(char *) * count);
+	/* FIXME: check return value of malloc() */
 
 	p = cmd;
 	while (*p && i < (count - 1)) {
@@ -43,7 +43,7 @@
 		q = buf;
 		while (*p && !isspace(*p))
 			*q++ = *p++;
-		*q = 0;
+		*q = '\0';
 		arr[i++] = strdup(buf);
 		while (*p && isspace(*p))
 			p++;
--- a/src/permissions.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/permissions.c	Thu Nov 06 09:18:38 2008 +0100
@@ -16,10 +16,11 @@
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
-#include "masqmail.h"
 #include <pwd.h>
 #include <grp.h>
 
+#include "masqmail.h"
+
 /* is there really no function in libc for this? */
 gboolean
 is_ingroup(uid_t uid, gid_t gid)
--- a/src/pop3_in.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/pop3_in.c	Thu Nov 06 09:18:38 2008 +0100
@@ -17,13 +17,13 @@
 
 /* see RFC 1725 */
 
+#include <sys/wait.h>
+#include <sys/stat.h>
+
 #include "masqmail.h"
 #include "pop3_in.h"
 #include "readsock.h"
 
-#include <sys/wait.h>
-#include <sys/stat.h>
-
 #ifdef USE_LIB_CRYPTO
 #include <openssl/md5.h>
 #else
@@ -376,7 +376,7 @@
 			while (*p && (*p != '>') && (i < 254))
 				buf[i++] = *(p++);
 			buf[i++] = '>';
-			buf[i] = 0;
+			buf[i] = '\0';
 
 			popb->timestamp = g_strdup(buf);
 
@@ -448,14 +448,10 @@
 	gint sock;
 
 	DEBUG(5) debugf("pop3_in_open_child entered, cmd = %s\n", cmd);
-
 	sock = child(cmd);
-
 	if (sock > 0) {
-
 		popb = create_pop3base(sock, flags);
 		popb->remote_host = NULL;
-
 		return popb;
 	}
 	logwrite(LOG_ALERT, "child failed (sock = %d): %s\n", sock, strerror(errno));
@@ -566,7 +562,7 @@
 		msg->rcpt_list = g_list_append(NULL, copy_address(rcpt));
 
 		if ((err = accept_message(popb->in, msg, ACC_MAIL_FROM_HEAD
-		    | (conf.do_save_envelope_to ? ACC_SAVE_ENVELOPE_TO : 0)))
+		                          | (conf.do_save_envelope_to ? ACC_SAVE_ENVELOPE_TO : 0)))
 		    == AERR_OK)
 			return msg;
 
@@ -591,11 +587,8 @@
 pop3_in_quit(pop3_base * popb)
 {
 	pop3_printf(popb->out, "QUIT\r\n");
-
 	DEBUG(4) debugf("QUIT\n");
-
 	signal(SIGALRM, SIG_DFL);
-
 	return TRUE;
 }
 
@@ -620,7 +613,8 @@
 }
 
 gboolean
-pop3_get(pop3_base * popb, gchar * user, gchar * pass, address * rcpt, address * return_path, gint max_count, gint max_size, gboolean max_size_delete)
+pop3_get(pop3_base * popb, gchar * user, gchar * pass, address * rcpt, address * return_path,
+         gint max_count, gint max_size, gboolean max_size_delete)
 {
 	gboolean ok = FALSE;
 	gint num_children = 0;
@@ -634,7 +628,8 @@
 			if (pop3_in_stat(popb)) {
 				if (popb->msg_cnt > 0) {
 
-					logwrite(LOG_NOTICE | LOG_VERBOSE, "%d message(s) for user %s at %s\n", popb->msg_cnt, user, popb->remote_host);
+					logwrite(LOG_NOTICE | LOG_VERBOSE, "%d message(s) for user %s at %s\n",
+					         popb->msg_cnt, user, popb->remote_host);
 
 					if (pop3_in_list(popb)) {
 						gboolean do_get = !(popb->flags & POP3_FLAG_UIDL);
--- a/src/queue.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/queue.c	Thu Nov 06 09:18:38 2008 +0100
@@ -16,11 +16,11 @@
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
-#include "masqmail.h"
-
 #include <sys/stat.h>
 #include <glob.h>
 
+#include "masqmail.h"
+
 static void
 mix_arr(int *buf, int len)
 {
--- a/src/readsock.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/readsock.c	Thu Nov 06 09:18:38 2008 +0100
@@ -16,14 +16,15 @@
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
-/*#include "masqmail.h"*/
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <setjmp.h>
 #include <unistd.h>
 #include <ctype.h>
+
 #include "readsock.h"
+/*#include "masqmail.h"*/
 
 jmp_buf jmp_timeout;
 
@@ -80,7 +81,7 @@
 		c = fgetc(in);
 	}
 
-	buf[p] = 0;
+	buf[p] = '\0';
 
 	if (c == EOF)
 		return -1;
@@ -90,7 +91,7 @@
 	}
 
 	buf[p++] = c;  /* \n */
-	buf[p] = 0;
+	buf[p] = '\0';
 
 	return p;
 }
@@ -177,7 +178,7 @@
 		if (flags & READSOCKL_CVT_CRLF) {
 			if ((buf[p - 2] == '\r') && (buf[p - 1] == '\n')) {
 				buf[p - 2] = '\n';
-				buf[p - 1] = 0;
+				buf[p - 1] = '\0';
 				p--;
 			}
 		}
--- a/src/rewrite.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/rewrite.c	Thu Nov 06 09:18:38 2008 +0100
@@ -54,7 +54,7 @@
 			if (*p == ',')
 				p++;
 
-			new_hdr = g_strconcat(new_hdr, rewr_string, *p != 0 ? "," : NULL, NULL);
+			new_hdr = g_strconcat(new_hdr, rewr_string, *p != '\0' ? "," : NULL, NULL);
 
 		} else
 			return FALSE;
--- a/src/route.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/route.c	Thu Nov 06 09:18:38 2008 +0100
@@ -16,8 +16,9 @@
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
+#include <fnmatch.h>
+
 #include "masqmail.h"
-#include <fnmatch.h>
 
 msgout_perhost*
 create_msgout_perhost(gchar * host)
@@ -85,7 +86,8 @@
 						DEBUG(6) debugf("header = %s\n", new_hdr->header);
 						msgout->xtra_hdr_list = g_list_append(msgout->xtra_hdr_list, new_hdr);
 					} else {
-						logwrite(LOG_ALERT, "error in set_address_header_domain(%s, %s)\n", new_hdr->value, route->set_h_from_domain);
+						logwrite(LOG_ALERT, "error in set_address_header_domain(%s, %s)\n",
+						         new_hdr->value, route->set_h_from_domain);
 					}
 				}
 			}
@@ -170,7 +172,8 @@
 			if (hdr->id == HEAD_SENDER) {
 				header *new_hdr;
 
-				new_hdr = create_header(HEAD_SENDER, "Sender: %s@%s\n", msgout->return_path->local_part, msgout->return_path->domain);
+				new_hdr = create_header(HEAD_SENDER, "Sender: %s@%s\n",
+				                        msgout->return_path->local_part, msgout->return_path->domain);
 				hdr_node->data = new_hdr;
 				/* we need this list only to carefully free the extra headers: */
 				msgout->xtra_hdr_list = g_list_append(msgout->xtra_hdr_list, new_hdr);
@@ -322,8 +325,7 @@
 			}
 		}
 
-		/* rewrite return path
-		   if there is a table, use that
+		/* rewrite return path if there is a table, use that
 		   if an address is found and if it has a domain, use that
 		 */
 		if (route->map_return_path_addresses) {
@@ -382,9 +384,8 @@
 				/* there is already a rcpt for this host */
 				msg_out *msgout_last = (msg_out *) ((g_list_last(mo_ph->msgout_list))->data);
 				if (msgout_last->msg == msgout->msg) {
-					/* if it is also the same message, it must be the last one
-					   appended to mo_ph->msgout_list (since outer loop goes through
-					   msgout_list) */
+					/* if it is also the same message, it must be the last one appended
+					   to mo_ph->msgout_list (since outer loop goes through msgout_list) */
 					msgout_last->rcpt_list = g_list_append(msgout_last->rcpt_list, rcpt);
 				} else {
 					/* if not, we append a new msgout */
--- a/src/smtp_in.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/smtp_in.c	Thu Nov 06 09:18:38 2008 +0100
@@ -31,24 +31,15 @@
 #ifdef ENABLE_SMTP_SERVER
 
 smtp_cmd smtp_cmds[] = {
-	{SMTP_HELO, "HELO",}
-	,
-	{SMTP_EHLO, "EHLO",}
-	,
-	{SMTP_MAIL_FROM, "MAIL FROM:",}
-	,
-	{SMTP_RCPT_TO, "RCPT TO:",}
-	,
-	{SMTP_DATA, "DATA",}
-	,
-	{SMTP_QUIT, "QUIT",}
-	,
-	{SMTP_RSET, "RSET",}
-	,
-	{SMTP_NOOP, "NOOP",}
-	,
-	{SMTP_HELP, "HELP"}
-	,
+	{SMTP_HELO, "HELO",},
+	{SMTP_EHLO, "EHLO",},
+	{SMTP_MAIL_FROM, "MAIL FROM:",},
+	{SMTP_RCPT_TO, "RCPT TO:",},
+	{SMTP_DATA, "DATA",},
+	{SMTP_QUIT, "QUIT",},
+	{SMTP_RSET, "RSET",},
+	{SMTP_NOOP, "NOOP",},
+	{SMTP_HELP, "HELP"},
 };
 
 static smtp_cmd_id
@@ -65,7 +56,6 @@
 /* this is a quick hack: we expect the address to be syntactically correct
    and containing the mailbox only:
 */
-
 static gboolean
 get_address(gchar * line, gchar * addr)
 {
--- a/src/smtp_out.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/smtp_out.c	Thu Nov 06 09:18:38 2008 +0100
@@ -168,7 +168,7 @@
 		}
 		for (i = 0; i < 4; i++)
 			code[i] = psb->buffer[buf_pos + i];
-		code[i] = 0;
+		code[i] = '\0';
 		psb->last_code = atoi(code);
 
 		buf_pos += len;
@@ -223,7 +223,7 @@
 	if (*p && (*p != '\n')) {
 		while (*p && (*p != '\n') && (*p != '\r') && (q < buf + SMTP_BUF_LEN - 1))
 			*(q++) = *(p++);
-		*q = 0;
+		*q = '\0';
 		return g_strdup(buf);
 	}
 	return NULL;
@@ -356,7 +356,8 @@
 	   beginning with a dot is prepended with another dot.
 	 */
 	gchar *ptr;
-	gboolean new_line = TRUE;  /* previous versions assumed that each item was exactly one line. This is no longer the case */
+	gboolean new_line = TRUE;  /* previous versions assumed that each item was exactly one line.
+	                              This is no longer the case */
 
 	ptr = data;
 	while (*ptr) {
@@ -567,7 +568,7 @@
 
 			for (i = 0; i < 16; i++)
 				sprintf(&(digest_string[i + i]), "%02x", (unsigned int) (digest[i]));
-			digest_string[32] = 0;
+			digest_string[32] = '\0';
 
 			DEBUG(5) debugf("digest = %s\n", digest_string);
 
@@ -746,7 +747,8 @@
 							ok = FALSE;
 							break;
 						} else {
-							logwrite(LOG_NOTICE, "%s == %s host=%s failed: %s", msg->uid, addr_string(rcpt), psb->remote_host, psb->buffer);
+							logwrite(LOG_NOTICE, "%s == %s host=%s failed: %s",
+							         msg->uid, addr_string(rcpt), psb->remote_host, psb->buffer);
 							if (psb->error == smtp_trylater) {
 								addr_mark_defered(rcpt);
 							} else {
--- a/src/spool.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/spool.c	Thu Nov 06 09:18:38 2008 +0100
@@ -16,8 +16,9 @@
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
+#include <sys/stat.h>
+
 #include "masqmail.h"
-#include <sys/stat.h>
 #include "dotlock.h"
 
 static gint
@@ -39,7 +40,7 @@
 	if ((p > 0) && (buf[p - 1] == '\r'))
 		p--;
 	buf[p++] = '\n';
-	buf[p] = 0;
+	buf[p] = '\0';
 
 	return p;
 }
@@ -68,7 +69,7 @@
 {
 	address *rcpt = NULL;
 
-	if (line[3] != 0) {
+	if (line[3] != '\0') {
 		if (line[4] != '|') {
 			rcpt = create_address(&(line[4]), TRUE);
 		} else {
--- a/src/tables.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/tables.c	Thu Nov 06 09:18:38 2008 +0100
@@ -16,8 +16,9 @@
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
+#include <fnmatch.h>
+
 #include "masqmail.h"
-#include <fnmatch.h>
 
 table_pair*
 create_pair(gchar * key, gpointer value)
@@ -52,9 +53,9 @@
 
 	p = line;
 	q = buf;
-	while ((*p != 0) && (*p != delim) && q < buf + 255)
+	while ((*p != '\0') && (*p != delim) && q < buf + 255)
 		*(q++) = *(p++);
-	*q = 0;
+	*q = '\0';
 
 	pair = g_malloc(sizeof(table_pair));
 	pair->key = g_strdup(g_strstrip(buf));
--- a/src/timeival.c	Wed Oct 29 21:21:26 2008 +0100
+++ b/src/timeival.c	Thu Nov 06 09:18:38 2008 +0100
@@ -33,7 +33,7 @@
 		(*pos)++;
 	}
 	(*pos)++;
-	*q = 0;
+	*q = '\0';
 	val = atoi(buf);
 
 	/* fall through: */