1 /* $NetBSD: recipient.c,v 1.2 2017/02/14 01:16:49 christos 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 VSTRING *folded; 63 int rcpt_stat; 64 65 /* 66 * Make verbose logging easier to understand. 67 */ 68 state.level++; 69 if (msg_verbose) 70 MSG_LOG_STATE(myname, state); 71 72 /* 73 * Set up the recipient-specific attributes. The recipient's lookup 74 * handle is the full address. 75 */ 76 if (state.msg_attr.delivered == 0) 77 state.msg_attr.delivered = state.msg_attr.rcpt.address; 78 folded = vstring_alloc(100); 79 state.msg_attr.user = casefold(folded, state.msg_attr.rcpt.address); 80 81 /* 82 * Deliver 83 */ 84 if (msg_verbose) 85 deliver_attr_dump(&state.msg_attr); 86 87 if (deliver_mailbox(state, usr_attr, &rcpt_stat) == 0) 88 rcpt_stat = deliver_unknown(state); 89 90 /* 91 * Cleanup. 92 */ 93 vstring_free(folded); 94 95 return (rcpt_stat); 96 } 97