~ubuntu-branches/ubuntu/hoary/postfix/hoary-security

« back to all changes in this revision

Viewing changes to src/smtp/smtp_session.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-10-06 11:50:33 UTC
  • Revision ID: james.westby@ubuntu.com-20041006115033-ooo6yfg6kmoteu04
Tags: upstream-2.1.3
ImportĀ upstreamĀ versionĀ 2.1.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*++
 
2
/* NAME
 
3
/*      smtp_session 3
 
4
/* SUMMARY
 
5
/*      SMTP_SESSION structure management
 
6
/* SYNOPSIS
 
7
/*      #include "smtp.h"
 
8
/*
 
9
/*      SMTP_SESSION *smtp_session_alloc(stream, host, addr)
 
10
/*      VSTREAM *stream;
 
11
/*      char    *host;
 
12
/*      char    *addr;
 
13
/*
 
14
/*      void    smtp_session_free(session)
 
15
/*      SMTP_SESSION *session;
 
16
/* DESCRIPTION
 
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.
 
21
/*
 
22
/*      smtp_session_free() destroys an SMTP_SESSION structure and its
 
23
/*      members, making memory available for reuse.
 
24
/* LICENSE
 
25
/* .ad
 
26
/* .fi
 
27
/*      The Secure Mailer license must be distributed with this software.
 
28
/* AUTHOR(S)
 
29
/*      Wietse Venema
 
30
/*      IBM T.J. Watson Research
 
31
/*      P.O. Box 704
 
32
/*      Yorktown Heights, NY 10598, USA
 
33
/*--*/
 
34
 
 
35
/* System library. */
 
36
 
 
37
#include <sys_defs.h>
 
38
 
 
39
/* Utility library. */
 
40
 
 
41
#include <mymalloc.h>
 
42
#include <vstream.h>
 
43
#include <stringops.h>
 
44
 
 
45
/* Application-specific. */
 
46
 
 
47
#include "smtp.h"
 
48
 
 
49
/* smtp_session_alloc - allocate and initialize SMTP_SESSION structure */
 
50
 
 
51
SMTP_SESSION *smtp_session_alloc(VSTREAM *stream, char *host, char *addr)
 
52
{
 
53
    SMTP_SESSION *session;
 
54
 
 
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);
 
60
    session->best = 1;
 
61
    return (session);
 
62
}
 
63
 
 
64
/* smtp_session_free - destroy SMTP_SESSION structure and contents */
 
65
 
 
66
void    smtp_session_free(SMTP_SESSION *session)
 
67
{
 
68
    vstream_fclose(session->stream);
 
69
    myfree(session->host);
 
70
    myfree(session->addr);
 
71
    myfree(session->namaddr);
 
72
    myfree((char *) session);
 
73
}