5
/* SMTP_SESSION structure management
9
/* SMTP_SESSION *smtp_session_alloc(stream, host, addr)
14
/* void smtp_session_free(session)
15
/* SMTP_SESSION *session;
17
/* smtp_session_alloc() allocates memory for an SMTP_SESSION structure
18
/* and initializes it with the given stream and host name and address
19
/* information. The host name and address strings are copied. The code
20
/* assumes that the stream is connected to the "best" alternative.
22
/* smtp_session_free() destroys an SMTP_SESSION structure and its
23
/* members, making memory available for reuse.
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. */
43
#include <stringops.h>
45
/* Application-specific. */
49
/* smtp_session_alloc - allocate and initialize SMTP_SESSION structure */
51
SMTP_SESSION *smtp_session_alloc(VSTREAM *stream, char *host, char *addr)
53
SMTP_SESSION *session;
55
session = (SMTP_SESSION *) mymalloc(sizeof(*session));
56
session->stream = stream;
57
session->host = mystrdup(host);
58
session->addr = mystrdup(addr);
59
session->namaddr = concatenate(host, "[", addr, "]", (char *) 0);
64
/* smtp_session_free - destroy SMTP_SESSION structure and contents */
66
void smtp_session_free(SMTP_SESSION *session)
68
vstream_fclose(session->stream);
69
myfree(session->host);
70
myfree(session->addr);
71
myfree(session->namaddr);
72
myfree((char *) session);