comparison src/deliver.c @ 366:41958685480d

Switched to `type *name' style Andrew Koenig's ``C Traps and Pitfalls'' (Ch.2.1) convinced me that it is best to go with the way C had been designed. The ``declaration reflects use'' concept conflicts with a ``type* name'' notation. Hence I switched.
author markus schnalke <meillo@marmaro.de>
date Thu, 22 Sep 2011 15:07:40 +0200
parents 08932c629849
children b27f66555ba8
comparison
equal deleted inserted replaced
365:934a223e4ee8 366:41958685480d
25 #include "smtp_out.h" 25 #include "smtp_out.h"
26 26
27 /* collect failed/defered rcpts for failure/warning messages */ 27 /* collect failed/defered rcpts for failure/warning messages */
28 /* returns TRUE if either there are no failures or a failure message has been successfully sent */ 28 /* returns TRUE if either there are no failures or a failure message has been successfully sent */
29 gboolean 29 gboolean
30 delivery_failures(message * msg, GList * rcpt_list, gchar * err_fmt, ...) 30 delivery_failures(message *msg, GList *rcpt_list, gchar *err_fmt, ...)
31 { 31 {
32 gboolean ok_fail = TRUE, ok_warn = TRUE; 32 gboolean ok_fail = TRUE, ok_warn = TRUE;
33 time_t now = time(NULL); 33 time_t now = time(NULL);
34 34
35 GList *failed_list = NULL, *defered_list = NULL, *rcpt_node; 35 GList *failed_list = NULL, *defered_list = NULL, *rcpt_node;
67 { 67 {
68 return (gint) strcasecmp(a, b); 68 return (gint) strcasecmp(a, b);
69 } 69 }
70 70
71 gboolean 71 gboolean
72 deliver_local_mbox(message* msg, GList* hdr_list, address* rcpt, address* env_addr) 72 deliver_local_mbox(message *msg, GList *hdr_list, address *rcpt, address *env_addr)
73 { 73 {
74 DEBUG(1) debugf("attempting to deliver %s with mbox\n", msg->uid); 74 DEBUG(1) debugf("attempting to deliver %s with mbox\n", msg->uid);
75 if (append_file(msg, hdr_list, rcpt->local_part)) { 75 if (append_file(msg, hdr_list, rcpt->local_part)) {
76 if (env_addr != rcpt) { 76 if (env_addr != rcpt) {
77 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); 77 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);
90 } 90 }
91 return FALSE; 91 return FALSE;
92 } 92 }
93 93
94 gboolean 94 gboolean
95 deliver_local_pipe(message* msg, GList* hdr_list, address* rcpt, address* env_addr) 95 deliver_local_pipe(message *msg, GList *hdr_list, address *rcpt, address *env_addr)
96 { 96 {
97 guint flags; 97 guint flags;
98 98
99 DEBUG(1) debugf("attempting to deliver %s with pipe\n", msg->uid); 99 DEBUG(1) debugf("attempting to deliver %s with pipe\n", msg->uid);
100 100
115 } 115 }
116 return FALSE; 116 return FALSE;
117 } 117 }
118 118
119 gboolean 119 gboolean
120 deliver_local_mda(message* msg, GList* hdr_list, address* rcpt, address* env_addr) 120 deliver_local_mda(message *msg, GList *hdr_list, address *rcpt, address *env_addr)
121 { 121 {
122 gboolean ok = FALSE; 122 gboolean ok = FALSE;
123 gchar *cmd = g_malloc(256); 123 gchar *cmd = g_malloc(256);
124 GList *var_table = var_table_rcpt(var_table_msg(NULL, msg), rcpt); 124 GList *var_table = var_table_rcpt(var_table_msg(NULL, msg), rcpt);
125 guint flags; 125 guint flags;
149 destroy_table(var_table); 149 destroy_table(var_table);
150 return ok; 150 return ok;
151 } 151 }
152 152
153 gboolean 153 gboolean
154 deliver_local(msg_out * msgout) 154 deliver_local(msg_out *msgout)
155 { 155 {
156 message *msg = msgout->msg; 156 message *msg = msgout->msg;
157 GList *rcpt_list = msgout->rcpt_list; 157 GList *rcpt_list = msgout->rcpt_list;
158 GList *rcpt_node; 158 GList *rcpt_node;
159 gboolean ok = FALSE, flag = FALSE, ok_fail = FALSE; 159 gboolean ok = FALSE, flag = FALSE, ok_fail = FALSE;
236 } 236 }
237 237
238 /* make a list of rcpt's of a message that are local 238 /* make a list of rcpt's of a message that are local
239 return a new copy of the list */ 239 return a new copy of the list */
240 void 240 void
241 msg_rcptlist_local(GList * rcpt_list, GList ** p_local_list, GList ** p_nonlocal_list) 241 msg_rcptlist_local(GList *rcpt_list, GList **p_local_list, GList **p_nonlocal_list)
242 { 242 {
243 GList *rcpt_node; 243 GList *rcpt_node;
244 244
245 foreach(rcpt_list, rcpt_node) { 245 foreach(rcpt_list, rcpt_node) {
246 address *rcpt = (address *) (rcpt_node->data); 246 address *rcpt = (address *) (rcpt_node->data);
260 } 260 }
261 } 261 }
262 } 262 }
263 263
264 gboolean 264 gboolean
265 deliver_msglist_host_pipe(connect_route * route, GList * msgout_list, gchar * host, GList * res_list) 265 deliver_msglist_host_pipe(connect_route *route, GList *msgout_list, gchar *host, GList *res_list)
266 { 266 {
267 gboolean ok = TRUE; 267 gboolean ok = TRUE;
268 GList *msgout_node; 268 GList *msgout_node;
269 269
270 DEBUG(5) debugf("deliver_msglist_host_pipe entered\n"); 270 DEBUG(5) debugf("deliver_msglist_host_pipe entered\n");
332 /* deliver list of messages to one host and finishes them if the message was 332 /* deliver list of messages to one host and finishes them if the message was
333 delivered to at least one rcpt. 333 delivered to at least one rcpt.
334 Returns TRUE if at least one msg was delivered to at least one rcpt. 334 Returns TRUE if at least one msg was delivered to at least one rcpt.
335 */ 335 */
336 gboolean 336 gboolean
337 deliver_msglist_host_smtp(connect_route * route, GList * msgout_list, gchar * host, GList * res_list) 337 deliver_msglist_host_smtp(connect_route *route, GList *msgout_list, gchar *host, GList *res_list)
338 { 338 {
339 gboolean ok = FALSE; 339 gboolean ok = FALSE;
340 GList *msgout_node; 340 GList *msgout_node;
341 smtp_base *psb; 341 smtp_base *psb;
342 gint port = 25; 342 gint port = 25;
462 destroy_smtpbase(psb); 462 destroy_smtpbase(psb);
463 return ok; 463 return ok;
464 } 464 }
465 465
466 gboolean 466 gboolean
467 deliver_msglist_host(connect_route * route, GList * msgout_list, gchar * host, GList * res_list) 467 deliver_msglist_host(connect_route *route, GList *msgout_list, gchar *host, GList *res_list)
468 { 468 {
469 469
470 if (route->pipe) { 470 if (route->pipe) {
471 DEBUG(5) debugf("with pipe\n"); 471 DEBUG(5) debugf("with pipe\n");
472 return deliver_msglist_host_pipe(route, msgout_list, host, res_list); 472 return deliver_msglist_host_pipe(route, msgout_list, host, res_list);
478 478
479 /* 479 /*
480 delivers messages in msgout_list using route 480 delivers messages in msgout_list using route
481 */ 481 */
482 gboolean 482 gboolean
483 deliver_route_msgout_list(connect_route * route, GList * msgout_list) 483 deliver_route_msgout_list(connect_route *route, GList *msgout_list)
484 { 484 {
485 gboolean ok = FALSE; 485 gboolean ok = FALSE;
486 GList *mo_ph_list; 486 GList *mo_ph_list;
487 GList *mo_ph_node; 487 GList *mo_ph_node;
488 488
520 /* 520 /*
521 calls route_prepare_msg() 521 calls route_prepare_msg()
522 delivers messages in msg_list using route by calling deliver_route_msgout_list() 522 delivers messages in msg_list using route by calling deliver_route_msgout_list()
523 */ 523 */
524 gboolean 524 gboolean
525 deliver_route_msg_list(connect_route * route, GList * msgout_list) 525 deliver_route_msg_list(connect_route *route, GList *msgout_list)
526 { 526 {
527 GList *msgout_list_deliver = NULL; 527 GList *msgout_list_deliver = NULL;
528 GList *msgout_node; 528 GList *msgout_node;
529 gboolean ok = TRUE; 529 gboolean ok = TRUE;
530 530
560 destroy_msg_out(msgout_cloned); 560 destroy_msg_out(msgout_cloned);
561 continue; 561 continue;
562 } 562 }
563 563
564 /* filter by allowed envelope rcpts */ 564 /* filter by allowed envelope rcpts */
565 GList* rcpt_list_allowed = NULL; 565 GList *rcpt_list_allowed = NULL;
566 GList* rcpt_list_notallowed = NULL; 566 GList *rcpt_list_notallowed = NULL;
567 route_split_rcpts(route, msgout_cloned->rcpt_list, &rcpt_list_allowed, &rcpt_list_notallowed); 567 route_split_rcpts(route, msgout_cloned->rcpt_list, &rcpt_list_allowed, &rcpt_list_notallowed);
568 if (!rcpt_list_allowed) { 568 if (!rcpt_list_allowed) {
569 destroy_msg_out(msgout_cloned); 569 destroy_msg_out(msgout_cloned);
570 continue; 570 continue;
571 } 571 }
598 598
599 /* copy pointers of delivered addresses to the msg's non_rcpt_list, 599 /* copy pointers of delivered addresses to the msg's non_rcpt_list,
600 to make sure that they will not be delivered again. 600 to make sure that they will not be delivered again.
601 */ 601 */
602 void 602 void
603 update_non_rcpt_list(msg_out * msgout) 603 update_non_rcpt_list(msg_out *msgout)
604 { 604 {
605 GList *rcpt_node; 605 GList *rcpt_node;
606 message *msg = msgout->msg; 606 message *msg = msgout->msg;
607 607
608 foreach(msgout->rcpt_list, rcpt_node) { 608 foreach(msgout->rcpt_list, rcpt_node) {
619 the data spool, so there is no need to write that back. 619 the data spool, so there is no need to write that back.
620 620
621 returns TRUE if all went well. 621 returns TRUE if all went well.
622 */ 622 */
623 gboolean 623 gboolean
624 deliver_finish(msg_out * msgout) 624 deliver_finish(msg_out *msgout)
625 { 625 {
626 GList *rcpt_node; 626 GList *rcpt_node;
627 message *msg = msgout->msg; 627 message *msg = msgout->msg;
628 gboolean finished = TRUE; 628 gboolean finished = TRUE;
629 629
666 DEBUG(2) debugf("spool header for %s written back.\n", msg->uid); 666 DEBUG(2) debugf("spool header for %s written back.\n", msg->uid);
667 return TRUE; 667 return TRUE;
668 } 668 }
669 669
670 int 670 int
671 deliver_remote(GList* remote_msgout_list) 671 deliver_remote(GList *remote_msgout_list)
672 { 672 {
673 int ok = TRUE; 673 int ok = TRUE;
674 GList *route_list = NULL; 674 GList *route_list = NULL;
675 GList *route_node; 675 GList *route_node;
676 GList *rf_list = NULL; 676 GList *rf_list = NULL;
730 /* 730 /*
731 This function splits the list of rcpt addresses 731 This function splits the list of rcpt addresses
732 into local and remote addresses and processes them accordingly. 732 into local and remote addresses and processes them accordingly.
733 */ 733 */
734 gboolean 734 gboolean
735 deliver_msg_list(GList * msg_list, guint flags) 735 deliver_msg_list(GList *msg_list, guint flags)
736 { 736 {
737 GList *msgout_list = NULL; 737 GList *msgout_list = NULL;
738 GList *msg_node; 738 GList *msg_node;
739 GList *local_msgout_list = NULL; 739 GList *local_msgout_list = NULL;
740 GList *remote_msgout_list = NULL; 740 GList *remote_msgout_list = NULL;
779 aliased_rcpt_list = alias_expand(alias_table, rcpt_list, msgout->msg->non_rcpt_list); 779 aliased_rcpt_list = alias_expand(alias_table, rcpt_list, msgout->msg->non_rcpt_list);
780 g_list_free(rcpt_list); 780 g_list_free(rcpt_list);
781 rcpt_list = aliased_rcpt_list; 781 rcpt_list = aliased_rcpt_list;
782 } 782 }
783 783
784 /* split_rcpts(rcpt_list, NULL, &local_rcpt_list, * NULL, &other_rcpt_list); */ 784 /* split_rcpts(rcpt_list, NULL, &local_rcpt_list, NULL, &other_rcpt_list); */
785 local_rcpt_list = local_rcpts(rcpt_list); 785 local_rcpt_list = local_rcpts(rcpt_list);
786 other_rcpt_list = remote_rcpts(rcpt_list); 786 other_rcpt_list = remote_rcpts(rcpt_list);
787 g_list_free(rcpt_list); 787 g_list_free(rcpt_list);
788 788
789 /* local recipients */ 789 /* local recipients */
843 (mode_accept and smtp_in) and should be delivered immediately 843 (mode_accept and smtp_in) and should be delivered immediately
844 (neither -odq nor do_queue). Only this one message will be tried to 844 (neither -odq nor do_queue). Only this one message will be tried to
845 deliver then. 845 deliver then.
846 */ 846 */
847 gboolean 847 gboolean
848 deliver(message * msg) 848 deliver(message *msg)
849 { 849 {
850 gboolean ok; 850 gboolean ok;
851 GList *msg_list = g_list_append(NULL, msg); 851 GList *msg_list = g_list_append(NULL, msg);
852 852
853 ok = deliver_msg_list(msg_list, DLVR_ALL); 853 ok = deliver_msg_list(msg_list, DLVR_ALL);