1 /* $NetBSD: recipient.c,v 1.1.1.1 2009/06/23 10:09:02 tron Exp $ */ 2 3 /*++ 4 /* NAME 5 /* recipient 3 6 /* SUMMARY 7 /* deliver to one local recipient 8 /* SYNOPSIS 9 /* #include "virtual.h" 10 /* 11 /* int deliver_recipient(state, usr_attr) 12 /* LOCAL_STATE state; 13 /* USER_ATTR *usr_attr; 14 /* DESCRIPTION 15 /* deliver_recipient() delivers a message to a local recipient. 16 /* 17 /* Arguments: 18 /* .IP state 19 /* The attributes that specify the message, sender, and more. 20 /* .IP usr_attr 21 /* Attributes describing user rights and mailbox location. 22 /* DIAGNOSTICS 23 /* deliver_recipient() returns non-zero when delivery should be 24 /* tried again. 25 /* SEE ALSO 26 /* mailbox(3) delivery to UNIX-style mailbox 27 /* maildir(3) delivery to qmail-style maildir 28 /* LICENSE 29 /* .ad 30 /* .fi 31 /* The Secure Mailer license must be distributed with this software. 32 /* AUTHOR(S) 33 /* Wietse Venema 34 /* IBM T.J. Watson Research 35 /* P.O. Box 704 36 /* Yorktown Heights, NY 10598, USA 37 /*--*/ 38 39 /* System library. */ 40 41 #include <sys_defs.h> 42 43 /* Utility library. */ 44 45 #include <msg.h> 46 #include <mymalloc.h> 47 #include <stringops.h> 48 49 /* Global library. */ 50 51 #include <bounce.h> 52 53 /* Application-specific. */ 54 55 #include "virtual.h" 56 57 /* deliver_recipient - deliver one local recipient */ 58 59 int deliver_recipient(LOCAL_STATE state, USER_ATTR usr_attr) 60 { 61 const char *myname = "deliver_recipient"; 62 int rcpt_stat; 63 64 /* 65 * Make verbose logging easier to understand. 66 */ 67 state.level++; 68 if (msg_verbose) 69 MSG_LOG_STATE(myname, state); 70 71 /* 72 * Set up the recipient-specific attributes. The recipient's lookup 73 * handle is the full address. 74 */ 75 if (state.msg_attr.delivered == 0) 76 state.msg_attr.delivered = state.msg_attr.rcpt.address; 77 state.msg_attr.user = mystrdup(state.msg_attr.rcpt.address); 78 lowercase(state.msg_attr.user); 79 80 /* 81 * Deliver 82 */ 83 if (msg_verbose) 84 deliver_attr_dump(&state.msg_attr); 85 86 if (deliver_mailbox(state, usr_attr, &rcpt_stat) == 0) 87 rcpt_stat = deliver_unknown(state); 88 89 /* 90 * Cleanup. 91 */ 92 myfree(state.msg_attr.user); 93 94 return (rcpt_stat); 95 } 96