masqmail

changeset 403:7954b82040b3

Broke long lines.
author markus schnalke <meillo@marmaro.de>
date Wed, 29 Feb 2012 09:46:34 +0100
parents eedc23877cd5
children 899c97e877a5
files src/deliver.c
diffstat 1 files changed, 75 insertions(+), 39 deletions(-) [+]
line diff
     1.1 --- a/src/deliver.c	Tue Feb 21 16:11:28 2012 +0100
     1.2 +++ b/src/deliver.c	Wed Feb 29 09:46:34 2012 +0100
     1.3 @@ -44,10 +44,11 @@
     1.4  		address *rcpt = (address *) (rcpt_node->data);
     1.5  
     1.6  		if (addr_is_defered(rcpt)) {
     1.7 -			if ((now - msg->received_time) >= conf.max_defer_time) {
     1.8 +			if ((now - msg->received_time) >= conf.max_defer_time){
     1.9  				addr_mark_failed(rcpt);
    1.10  			} else {
    1.11 -				defered_list = g_list_prepend(defered_list, rcpt);
    1.12 +				defered_list = g_list_prepend(defered_list,
    1.13 +						rcpt);
    1.14  			}
    1.15  		}
    1.16  		if (addr_is_failed(rcpt)) {
    1.17 @@ -55,11 +56,13 @@
    1.18  		}
    1.19  	}
    1.20  	if (failed_list) {
    1.21 -		ok_fail = fail_msg(msg, conf.errmsg_file, failed_list, err_fmt, args);
    1.22 +		ok_fail = fail_msg(msg, conf.errmsg_file, failed_list,
    1.23 +				err_fmt, args);
    1.24  		g_list_free(failed_list);
    1.25  	}
    1.26  	if (defered_list) {
    1.27 -		ok_warn = warn_msg(msg, conf.warnmsg_file, defered_list, err_fmt, args);
    1.28 +		ok_warn = warn_msg(msg, conf.warnmsg_file, defered_list,
    1.29 +				err_fmt, args);
    1.30  		g_list_free(defered_list);
    1.31  	}
    1.32  	va_end(args);
    1.33 @@ -73,14 +76,20 @@
    1.34  }
    1.35  
    1.36  gboolean
    1.37 -deliver_local_mbox(message *msg, GList *hdr_list, address *rcpt, address *env_addr)
    1.38 +deliver_local_mbox(message *msg, GList *hdr_list, address *rcpt,
    1.39 +		address *env_addr)
    1.40  {
    1.41  	DEBUG(1) debugf("attempting to deliver %s with mbox\n", msg->uid);
    1.42  	if (append_file(msg, hdr_list, rcpt->local_part)) {
    1.43  		if (env_addr != rcpt) {
    1.44 -			logwrite(LOG_NOTICE, "%s => %s@%s <%s@%s> with mbox\n", msg->uid, rcpt->local_part, rcpt->domain, env_addr->local_part, env_addr->domain);
    1.45 +			logwrite(LOG_NOTICE, "%s => %s@%s <%s@%s> with mbox\n",
    1.46 +					msg->uid, rcpt->local_part,
    1.47 +					rcpt->domain, env_addr->local_part,
    1.48 +					env_addr->domain);
    1.49  		} else {
    1.50 -			logwrite(LOG_NOTICE, "%s => <%s@%s> with mbox\n", msg->uid, rcpt->local_part, rcpt->domain);
    1.51 +			logwrite(LOG_NOTICE, "%s => <%s@%s> with mbox\n",
    1.52 +					msg->uid, rcpt->local_part,
    1.53 +					rcpt->domain);
    1.54  		}
    1.55  		addr_mark_delivered(rcpt);
    1.56  		return TRUE;
    1.57 @@ -96,17 +105,19 @@
    1.58  }
    1.59  
    1.60  gboolean
    1.61 -deliver_local_pipe(message *msg, GList *hdr_list, address *rcpt, address *env_addr)
    1.62 +deliver_local_pipe(message *msg, GList *hdr_list, address *rcpt,
    1.63 +		address *env_addr)
    1.64  {
    1.65 -	guint flags;
    1.66 +	guint flags = 0;
    1.67  
    1.68  	DEBUG(1) debugf("attempting to deliver %s with pipe\n", msg->uid);
    1.69  
    1.70 -	flags = (conf.pipe_fromline) ? MSGSTR_FROMLINE : 0;
    1.71 +	flags |= (conf.pipe_fromline) ? MSGSTR_FROMLINE : 0;
    1.72  	flags |= (conf.pipe_fromhack) ? MSGSTR_FROMHACK : 0;
    1.73  	if (pipe_out(msg, hdr_list, rcpt, &(rcpt->local_part[1]), flags)) {
    1.74  		logwrite(LOG_NOTICE, "%s => %s <%s@%s> with pipe\n",
    1.75 -		         msg->uid, rcpt->local_part, env_addr->local_part, env_addr->domain);
    1.76 +				msg->uid, rcpt->local_part,
    1.77 +				env_addr->local_part, env_addr->domain);
    1.78  		addr_mark_delivered(rcpt);
    1.79  		return TRUE;
    1.80  	}
    1.81 @@ -121,12 +132,13 @@
    1.82  }
    1.83  
    1.84  gboolean
    1.85 -deliver_local_mda(message *msg, GList *hdr_list, address *rcpt, address *env_addr)
    1.86 +deliver_local_mda(message *msg, GList *hdr_list, address *rcpt,
    1.87 +		address *env_addr)
    1.88  {
    1.89  	gboolean ok = FALSE;
    1.90  	gchar *cmd = g_malloc(256);
    1.91  	GList *var_table = var_table_rcpt(var_table_msg(NULL, msg), rcpt);
    1.92 -	guint flags;
    1.93 +	guint flags = 0;
    1.94  
    1.95  	DEBUG(1) debugf("attempting to deliver %s with mda\n", msg->uid);
    1.96  
    1.97 @@ -136,11 +148,11 @@
    1.98  		return FALSE;
    1.99  	}
   1.100  
   1.101 -	flags = (conf.mda_fromline) ? MSGSTR_FROMLINE : 0;
   1.102 +	flags |= (conf.mda_fromline) ? MSGSTR_FROMLINE : 0;
   1.103  	flags |= (conf.mda_fromhack) ? MSGSTR_FROMHACK : 0;
   1.104  	if (pipe_out(msg, hdr_list, rcpt, cmd, flags)) {
   1.105  		logwrite(LOG_NOTICE, "%s => %s@%s with mda (cmd = '%s')\n",
   1.106 -		         msg->uid, rcpt->local_part, rcpt->domain, cmd);
   1.107 +				msg->uid, rcpt->local_part, rcpt->domain, cmd);
   1.108  		addr_mark_delivered(rcpt);
   1.109  		ok = TRUE;
   1.110  	} else if ((errno != (1024 + EX_TEMPFAIL)) && (errno != EAGAIN)) {
   1.111 @@ -166,11 +178,13 @@
   1.112  
   1.113  	flag = (msg->data_list == NULL);
   1.114  	if (flag && !spool_read_data(msg)) {
   1.115 -		logwrite(LOG_ALERT, "could not open data spool file for %s\n", msg->uid);
   1.116 +		logwrite(LOG_ALERT, "could not open data spool file for %s\n",
   1.117 +				msg->uid);
   1.118  		return FALSE;
   1.119  	}
   1.120  
   1.121 -	for (rcpt_node = g_list_first(rcpt_list); rcpt_node; rcpt_node = g_list_next(rcpt_node)) {
   1.122 +	for (rcpt_node = g_list_first(rcpt_list); rcpt_node;
   1.123 +			rcpt_node = g_list_next(rcpt_node)) {
   1.124  		GList *hdr_list;
   1.125  		address *rcpt = (address *) (rcpt_node->data);
   1.126  		address *env_addr = addr_find_ancestor(rcpt);
   1.127 @@ -183,46 +197,58 @@
   1.128  		**  copies only the nodes, so it is safe to g_list_free it
   1.129  		*/
   1.130  		hdr_list = g_list_copy(msg->hdr_list);
   1.131 -		retpath_hdr = create_header(HEAD_ENVELOPE_TO, "Envelope-to: %s\n", addr_string(env_addr));
   1.132 -		envto_hdr = create_header(HEAD_RETURN_PATH, "Return-path: %s\n", addr_string(ret_path));
   1.133 +		retpath_hdr = create_header(HEAD_ENVELOPE_TO,
   1.134 +				"Envelope-to: %s\n", addr_string(env_addr));
   1.135 +		envto_hdr = create_header(HEAD_RETURN_PATH,
   1.136 +				"Return-path: %s\n", addr_string(ret_path));
   1.137  
   1.138  		hdr_list = g_list_prepend(hdr_list, envto_hdr);
   1.139  		hdr_list = g_list_prepend(hdr_list, retpath_hdr);
   1.140  
   1.141 -		if (rcpt->local_part[0] == '|') {
   1.142 +		if (*rcpt->local_part == '|') {
   1.143  			/*
   1.144  			**  probably for expanded aliases, but why not done
   1.145  			**  like with the mda? //meillo 2010-12-06
   1.146  			*/
   1.147 -			if (deliver_local_pipe(msg, hdr_list, rcpt, env_addr)) {
   1.148 +			if (deliver_local_pipe(msg, hdr_list, rcpt,
   1.149 +					env_addr)) {
   1.150  				ok = TRUE;
   1.151  			}
   1.152  		} else {
   1.153 -			/* figure out which mailbox type should be used for this user */
   1.154 +			/* figure out which mailbox type should be used
   1.155 +			** for this user */
   1.156  			gchar *user = rcpt->local_part;
   1.157  			gchar *mbox_type = conf.mbox_default;
   1.158  
   1.159 -			if (g_list_find_custom (conf.mbox_users, user, _g_list_strcasecmp)) {
   1.160 +			if (g_list_find_custom(conf.mbox_users, user,
   1.161 +					_g_list_strcasecmp)) {
   1.162  				mbox_type = "mbox";
   1.163 -			} else if (g_list_find_custom (conf.mda_users, user, _g_list_strcasecmp)) {
   1.164 +			} else if (g_list_find_custom (conf.mda_users, user,
   1.165 +					_g_list_strcasecmp)) {
   1.166  				mbox_type = "mda";
   1.167  			}
   1.168  
   1.169 -			if (strcmp(mbox_type, "mbox") == 0) {
   1.170 -				if (deliver_local_mbox(msg, hdr_list, rcpt, env_addr)) {
   1.171 +			if (strcmp(mbox_type, "mbox")==0) {
   1.172 +				if (deliver_local_mbox(msg, hdr_list, rcpt,
   1.173 +						env_addr)) {
   1.174  					ok = TRUE;
   1.175  				}
   1.176  			} else if (strcmp(mbox_type, "mda") == 0) {
   1.177  				if (conf.mda) {
   1.178 -					if (deliver_local_mda(msg, hdr_list, rcpt, env_addr)) {
   1.179 +					if (deliver_local_mda(msg, hdr_list,
   1.180 +							rcpt, env_addr)) {
   1.181  						ok = TRUE;
   1.182  					}
   1.183  				} else {
   1.184 -					logwrite(LOG_ALERT, "mbox type is mda, but no mda command given in configuration\n");
   1.185 +					logwrite(LOG_ALERT, "mbox type is "
   1.186 +							"mda, but no mda "
   1.187 +							"command given in "
   1.188 +							"configuration\n");
   1.189  				}
   1.190  
   1.191  			} else {
   1.192 -				logwrite(LOG_ALERT, "unknown mbox type '%s'\n", mbox_type);
   1.193 +				logwrite(LOG_ALERT, "unknown mbox type '%s'\n",
   1.194 +						mbox_type);
   1.195  			}
   1.196  		}
   1.197  
   1.198 @@ -231,7 +257,8 @@
   1.199  
   1.200  		g_list_free(hdr_list);
   1.201  	}
   1.202 -	ok_fail = delivery_failures(msg, rcpt_list, "%s (%d)", ext_strerror(errno), errno);
   1.203 +	ok_fail = delivery_failures(msg, rcpt_list, "%s (%d)",
   1.204 +			ext_strerror(errno), errno);
   1.205  
   1.206  	if (flag) {
   1.207  		msg_free_data(msg);
   1.208 @@ -261,12 +288,17 @@
   1.209  
   1.210  		/* search for local host list: */
   1.211  		foreach(conf.local_hosts, dom_node) {
   1.212 -			if (fnmatch(dom_node->data, rcpt->domain, FNM_CASEFOLD)==0) {
   1.213 -				*p_local_list = g_list_append(*p_local_list, rcpt);
   1.214 -				DEBUG(5) debugf("<%s@%s> is local\n", rcpt->local_part, rcpt->domain);
   1.215 +			if (fnmatch(dom_node->data, rcpt->domain,
   1.216 +					FNM_CASEFOLD)==0) {
   1.217 +				*p_local_list = g_list_append(*p_local_list,
   1.218 +						rcpt);
   1.219 +				DEBUG(5) debugf("<%s@%s> is local\n",
   1.220 +						rcpt->local_part,
   1.221 +						rcpt->domain);
   1.222  				break;
   1.223  			} else {
   1.224 -				*p_nonlocal_list = g_list_append(*p_nonlocal_list, rcpt);
   1.225 +				*p_nonlocal_list = g_list_append(
   1.226 +						*p_nonlocal_list, rcpt);
   1.227  			}
   1.228  		}
   1.229  	}
   1.230 @@ -287,11 +319,13 @@
   1.231  		message *msg = msgout->msg;
   1.232  		GList *rcpt_node, *rcpt_list = msgout->rcpt_list;
   1.233  
   1.234 -		DEBUG(1) debugf("attempting to deliver %s with pipe\n", msg->uid);
   1.235 +		DEBUG(1) debugf("attempting to deliver %s with pipe\n",
   1.236 +				msg->uid);
   1.237  
   1.238  		flag = (msg->data_list == NULL);
   1.239  		if (flag && !spool_read_data(msg)) {
   1.240 -			logwrite(LOG_ALERT, "could not open data spool file for %s\n", msg->uid);
   1.241 +			logwrite(LOG_ALERT, "could not open data spool file "
   1.242 +					"for %s\n", msg->uid);
   1.243  			continue;
   1.244  		}
   1.245  
   1.246 @@ -299,10 +333,12 @@
   1.247  		foreach(rcpt_list, rcpt_node) {
   1.248  			address *rcpt = (address *) (rcpt_node->data);
   1.249  			gchar *cmd = g_malloc(256);
   1.250 -			GList *var_table = var_table_rcpt(var_table_msg(NULL, msg), rcpt);
   1.251 +			GList *var_table = var_table_rcpt(var_table_msg(NULL,
   1.252 +					msg), rcpt);
   1.253  
   1.254 -			DEBUG(1) debugf("attempting to deliver %s to %s@%s with pipe\n",
   1.255 -			                msg->uid, rcpt->local_part, rcpt->domain);
   1.256 +			DEBUG(1) debugf("attempting to deliver %s to %s@%s "
   1.257 +					"with pipe\n", msg->uid,
   1.258 +					rcpt->local_part, rcpt->domain);
   1.259  
   1.260  			if (!expand(var_table, route->pipe, cmd, 256)) {
   1.261  				logwrite(LOG_ALERT, "could not expand string `%s'\n", route->pipe);