#include <sys_defs.h>
#include <mymalloc.h>
#include <vstring.h>
#include <msg.h>
#include <mail_params.h>
#include "smtp.h"
#include "smtp_sasl.h"
SMTP_STATE *smtp_state_alloc(void)
{
SMTP_STATE *state = (SMTP_STATE *) mymalloc(sizeof(*state));
state->misc_flags = 0;
state->src = 0;
state->service = 0;
state->request = 0;
state->session = 0;
state->status = 0;
state->space_left = 0;
state->nexthop_domain = 0;
if (var_smtp_cache_conn) {
state->dest_label = vstring_alloc(10);
state->dest_prop = vstring_alloc(10);
state->endp_label = vstring_alloc(10);
state->endp_prop = vstring_alloc(10);
state->cache_used = htable_create(1);
} else {
state->dest_label = 0;
state->dest_prop = 0;
state->endp_label = 0;
state->endp_prop = 0;
state->cache_used = 0;
}
state->why = dsb_create();
if (strcmp(var_procname, "lmtp") == 0) {
state->misc_flags |= SMTP_MISC_FLAG_USE_LMTP;
} else if (strcmp(var_procname, "smtp") == 0) {
} else {
msg_fatal("unexpected process name \"%s\" - "
"specify \"smtp\" or \"lmtp\"",
var_procname);
}
return (state);
}
void smtp_state_free(SMTP_STATE *state)
{
if (state->dest_label)
vstring_free(state->dest_label);
if (state->dest_prop)
vstring_free(state->dest_prop);
if (state->endp_label)
vstring_free(state->endp_label);
if (state->endp_prop)
vstring_free(state->endp_prop);
if (state->cache_used)
htable_free(state->cache_used, (void (*) (char *)) 0);
if (state->why)
dsb_free(state->why);
myfree((char *) state);
}