5
/* LMTP_SESSION structure management
9
/* LMTP_SESSION *lmtp_session_alloc(stream, host, addr, dest, type)
16
/* LMTP_SESSION *lmtp_session_free(session)
17
/* LMTP_SESSION *session;
19
/* This module maintains information about connections, including
20
/* per-peer debugging.
22
/* lmtp_session_alloc() allocates memory for an LMTP_SESSION structure
23
/* and initializes it with the given stream and host name and address
24
/* information. The host name and address strings are copied.
25
/* The type argument specifies the transport type. The dest argument
26
/* specifies a string-valued name for the remote endpoint.
27
/* If the peer name or address matches the debug-peer_list configuration
28
/* parameter, the debugging level is incremented by the amount specified
29
/* in the debug_peer_level parameter.
31
/* lmtp_session_free() destroys an LMTP_SESSION structure and its
32
/* members, making memory available for reuse. The result value is
33
/* convenient null pointer. The debugging level is restored to the
34
/* value prior to the lmtp_session_alloc() call.
38
/* The Secure Mailer license must be distributed with this software.
40
/* debug_peer(3), increase logging for selected peers
43
/* IBM T.J. Watson Research
45
/* Yorktown Heights, NY 10598, USA
47
/* Alterations for LMTP by:
48
/* Philip A. Prindeville
52
/* Additional work on LMTP by:
54
/* University of Texas at Dallas
55
/* P.O. Box 830688, MC34
56
/* Richardson, TX 75083, USA
63
/* Utility library. */
67
#include <stringops.h>
71
#include <debug_peer.h>
73
/* Application-specific. */
77
/* lmtp_session_alloc - allocate and initialize LMTP_SESSION structure */
79
LMTP_SESSION *lmtp_session_alloc(VSTREAM *stream, const char *host,
80
const char *addr, const char *dest)
82
LMTP_SESSION *session;
84
session = (LMTP_SESSION *) mymalloc(sizeof(*session));
85
session->stream = stream;
86
session->host = mystrdup(host);
87
session->addr = mystrdup(addr);
88
session->namaddr = concatenate(host, "[", addr, "]", (char *) 0);
89
session->dest = mystrdup(dest);
90
debug_peer_check(host, addr);
94
/* lmtp_session_free - destroy LMTP_SESSION structure and contents */
96
LMTP_SESSION *lmtp_session_free(LMTP_SESSION *session)
99
vstream_fclose(session->stream);
100
myfree(session->host);
101
myfree(session->addr);
102
myfree(session->namaddr);
103
myfree(session->dest);
104
myfree((char *) session);