blob: 7f913d2dfdb9e2119cf3a178e61b9d63cee45c73 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/*++
/* NAME
/* smtp_session 3
/* SUMMARY
/* SMTP_SESSION structure management
/* SYNOPSIS
/* #include "smtp.h"
/*
/* SMTP_SESSION *smtp_session_alloc(stream, host, addr)
/* VSTREAM *stream;
/* char *host;
/* char *addr;
/*
/* void smtp_session_free(session)
/* SMTP_SESSION *session;
/* DESCRIPTION
/* smtp_session_alloc() allocates memory for an SMTP_SESSION structure
/* and initializes it with the given stream and host name and address
/* information. The host name and address strings are copied. The code
/* assumes that the stream is connected to the "best" alternative.
/*
/* smtp_session_free() destroys an SMTP_SESSION structure and its
/* members, making memory available for reuse.
/* LICENSE
/* .ad
/* .fi
/* The Secure Mailer license must be distributed with this software.
/* AUTHOR(S)
/* Wietse Venema
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
/*--*/
/* System library. */
#include <sys_defs.h>
/* Utility library. */
#include <mymalloc.h>
#include <vstream.h>
#include <stringops.h>
/* Application-specific. */
#include "smtp.h"
/* smtp_session_alloc - allocate and initialize SMTP_SESSION structure */
SMTP_SESSION *smtp_session_alloc(VSTREAM *stream, char *host, char *addr)
{
SMTP_SESSION *session;
session = (SMTP_SESSION *) mymalloc(sizeof(*session));
session->stream = stream;
session->host = mystrdup(host);
session->addr = mystrdup(addr);
session->namaddr = concatenate(host, "[", addr, "]", (char *) 0);
session->best = 1;
return (session);
}
/* smtp_session_free - destroy SMTP_SESSION structure and contents */
void smtp_session_free(SMTP_SESSION *session)
{
vstream_fclose(session->stream);
myfree(session->host);
myfree(session->addr);
myfree(session->namaddr);
myfree((char *) session);
}
|