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