7 /* initialize/cleanup shared state
11 /* SMTP_STATE *smtp_state_alloc()
13 /* void smtp_state_free(state)
16 /* smtp_state_init() initializes the shared state, and allocates
17 /* memory for buffers etc.
19 /* smtp_cleanup() destroys memory allocated by smtp_state_init().
27 /* The Secure Mailer license must be distributed with this software.
30 /* IBM T.J. Watson Research
32 /* Yorktown Heights, NY 10598, USA
39 /* Utility library. */
47 #include <mail_params.h>
49 /* Application-specific. */
52 #include "smtp_sasl.h"
54 /* smtp_state_alloc - initialize */
56 SMTP_STATE
*smtp_state_alloc(void)
58 SMTP_STATE
*state
= (SMTP_STATE
*) mymalloc(sizeof(*state
));
60 state
->misc_flags
= 0;
66 state
->space_left
= 0;
67 state
->nexthop_domain
= 0;
68 if (var_smtp_cache_conn
) {
69 state
->dest_label
= vstring_alloc(10);
70 state
->dest_prop
= vstring_alloc(10);
71 state
->endp_label
= vstring_alloc(10);
72 state
->endp_prop
= vstring_alloc(10);
73 state
->cache_used
= htable_create(1);
75 state
->dest_label
= 0;
77 state
->endp_label
= 0;
79 state
->cache_used
= 0;
81 state
->why
= dsb_create();
84 * The process name, "smtp" or "lmtp", is also used as the DSN server
85 * reply type and for SASL service information lookup. Since all three
86 * external representations are identical there is no reason to transform
87 * from some external form X to some Postfix-specific canonical internal
88 * form, and then to transform from the internal form to external forms Y
91 if (strcmp(var_procname
, "lmtp") == 0) {
92 state
->misc_flags
|= SMTP_MISC_FLAG_USE_LMTP
;
93 } else if (strcmp(var_procname
, "smtp") == 0) {
96 msg_fatal("unexpected process name \"%s\" - "
97 "specify \"smtp\" or \"lmtp\"",
103 /* smtp_state_free - destroy state */
105 void smtp_state_free(SMTP_STATE
*state
)
107 if (state
->dest_label
)
108 vstring_free(state
->dest_label
);
109 if (state
->dest_prop
)
110 vstring_free(state
->dest_prop
);
111 if (state
->endp_label
)
112 vstring_free(state
->endp_label
);
113 if (state
->endp_prop
)
114 vstring_free(state
->endp_prop
);
115 if (state
->cache_used
)
116 htable_free(state
->cache_used
, (void (*) (char *)) 0);
118 dsb_free(state
->why
);
120 myfree((char *) state
);