#include <sys_defs.h>
#include <time.h>
#include <mymalloc.h>
#include <vstream.h>
#include <vstring.h>
#include <mail_stream.h>
#include <cleanup_user.h>
#include <mail_proto.h>
#include <qmqpd.h>
QMQPD_STATE *qmqpd_state_alloc(VSTREAM *stream)
{
QMQPD_STATE *state;
state = (QMQPD_STATE *) mymalloc(sizeof(*state));
state->err = CLEANUP_STAT_OK;
state->client = stream;
state->message = vstring_alloc(1000);
state->buf = vstring_alloc(100);
state->time = time((time_t *) 0);
qmqpd_peer_init(state);
state->queue_id = 0;
state->cleanup = 0;
state->dest = 0;
state->rcpt_count = 0;
state->reason = 0;
state->sender = 0;
state->recipient = 0;
state->protocol = MAIL_PROTO_QMQP;
state->where = "initializing client connection";
state->why_rejected = vstring_alloc(10);
return (state);
}
void qmqpd_state_free(QMQPD_STATE *state)
{
vstring_free(state->message);
vstring_free(state->buf);
qmqpd_peer_reset(state);
if (state->queue_id)
myfree(state->queue_id);
if (state->dest)
mail_stream_cleanup(state->dest);
if (state->sender)
myfree(state->sender);
if (state->recipient)
myfree(state->recipient);
vstring_free(state->why_rejected);
myfree((char *) state);
}