No empty .Rs/.Re
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / smtpd / smtpd_xforward.c
blob77a665b36176b701aeac52225bbdee0291188632
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* smtpd_xforward 3
6 /* SUMMARY
7 /* maintain XCLIENT information
8 /* SYNOPSIS
9 /* #include "smtpd.h"
11 /* void smtpd_xforward_init(state)
12 /* SMTPD_STATE *state;
14 /* void smtpd_xforward_preset(state)
15 /* SMTPD_STATE *state;
17 /* void smtpd_xforward_reset(state)
18 /* SMTPD_STATE *state;
19 /* DESCRIPTION
20 /* smtpd_xforward_init() zeroes the attributes for storage of
21 /* XFORWARD command parameters.
23 /* smtpd_xforward_preset() takes the result from smtpd_xforward_init()
24 /* and sets all fields to the same "unknown" value that regular
25 /* client attributes would have.
27 /* smtpd_xforward_reset() restores the state from smtpd_xforward_init().
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 /*--*/
39 /* System library. */
41 #include <sys_defs.h>
43 /* Utility library. */
45 #include <mymalloc.h>
46 #include <msg.h>
48 /* Global library. */
50 #include <mail_proto.h>
52 /* Application-specific. */
54 #include <smtpd.h>
56 /* smtpd_xforward_init - initialize XCLIENT attributes */
58 void smtpd_xforward_init(SMTPD_STATE *state)
60 state->xforward.flags = 0;
61 state->xforward.name = 0;
62 state->xforward.addr = 0;
63 state->xforward.port = 0;
64 state->xforward.namaddr = 0;
65 state->xforward.protocol = 0;
66 state->xforward.helo_name = 0;
67 state->xforward.ident = 0;
68 state->xforward.domain = 0;
71 /* smtpd_xforward_preset - set xforward attributes to "unknown" */
73 void smtpd_xforward_preset(SMTPD_STATE *state)
77 * Sanity checks.
79 if (state->xforward.flags)
80 msg_panic("smtpd_xforward_preset: bad flags: 0x%x",
81 state->xforward.flags);
84 * This is a temporary solution. Unknown forwarded attributes get the
85 * same values as unknown normal attributes, so that we don't break
86 * assumptions in pre-existing code.
88 state->xforward.flags = SMTPD_STATE_XFORWARD_INIT;
89 state->xforward.name = mystrdup(CLIENT_NAME_UNKNOWN);
90 state->xforward.addr = mystrdup(CLIENT_ADDR_UNKNOWN);
91 state->xforward.port = mystrdup(CLIENT_PORT_UNKNOWN);
92 state->xforward.namaddr = mystrdup(CLIENT_NAMADDR_UNKNOWN);
93 state->xforward.rfc_addr = mystrdup(CLIENT_ADDR_UNKNOWN);
94 /* Leave helo at zero. */
95 state->xforward.protocol = mystrdup(CLIENT_PROTO_UNKNOWN);
96 /* Leave ident at zero. */
97 /* Leave domain context at zero. */
100 /* smtpd_xforward_reset - reset XCLIENT attributes */
102 void smtpd_xforward_reset(SMTPD_STATE *state)
104 #define FREE_AND_WIPE(s) { if (s) myfree(s); s = 0; }
106 state->xforward.flags = 0;
107 FREE_AND_WIPE(state->xforward.name);
108 FREE_AND_WIPE(state->xforward.addr);
109 FREE_AND_WIPE(state->xforward.port);
110 FREE_AND_WIPE(state->xforward.namaddr);
111 FREE_AND_WIPE(state->xforward.rfc_addr);
112 FREE_AND_WIPE(state->xforward.protocol);
113 FREE_AND_WIPE(state->xforward.helo_name);
114 FREE_AND_WIPE(state->xforward.ident);
115 FREE_AND_WIPE(state->xforward.domain);