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

« back to all changes in this revision

Viewing changes to src/lmtp/lmtp_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
/*      lmtp_session 3
 
4
/* SUMMARY
 
5
/*      LMTP_SESSION structure management
 
6
/* SYNOPSIS
 
7
/*      #include "lmtp.h"
 
8
/*
 
9
/*      LMTP_SESSION *lmtp_session_alloc(stream, host, addr, dest, type)
 
10
/*      VSTREAM *stream;
 
11
/*      const char *host;
 
12
/*      const char *addr;
 
13
/*      const char *dest;
 
14
/*      int     type;
 
15
/*
 
16
/*      LMTP_SESSION *lmtp_session_free(session)
 
17
/*      LMTP_SESSION *session;
 
18
/* DESCRIPTION
 
19
/*      This module maintains information about connections, including
 
20
/*      per-peer debugging.
 
21
/*
 
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.
 
30
/*
 
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.
 
35
/* LICENSE
 
36
/* .ad
 
37
/* .fi
 
38
/*      The Secure Mailer license must be distributed with this software.
 
39
/* SEE ALSO
 
40
/*      debug_peer(3), increase logging for selected peers
 
41
/* AUTHOR(S)
 
42
/*      Wietse Venema
 
43
/*      IBM T.J. Watson Research
 
44
/*      P.O. Box 704
 
45
/*      Yorktown Heights, NY 10598, USA
 
46
/*
 
47
/*      Alterations for LMTP by:
 
48
/*      Philip A. Prindeville
 
49
/*      Mirapoint, Inc.
 
50
/*      USA.
 
51
/*
 
52
/*      Additional work on LMTP by:
 
53
/*      Amos Gouaux
 
54
/*      University of Texas at Dallas
 
55
/*      P.O. Box 830688, MC34
 
56
/*      Richardson, TX 75083, USA
 
57
/*--*/
 
58
 
 
59
/* System library. */
 
60
 
 
61
#include <sys_defs.h>
 
62
 
 
63
/* Utility library. */
 
64
 
 
65
#include <mymalloc.h>
 
66
#include <vstream.h>
 
67
#include <stringops.h>
 
68
 
 
69
/* Global library. */
 
70
 
 
71
#include <debug_peer.h>
 
72
 
 
73
/* Application-specific. */
 
74
 
 
75
#include "lmtp.h"
 
76
 
 
77
/* lmtp_session_alloc - allocate and initialize LMTP_SESSION structure */
 
78
 
 
79
LMTP_SESSION *lmtp_session_alloc(VSTREAM *stream, const char *host,
 
80
                                         const char *addr, const char *dest)
 
81
{
 
82
    LMTP_SESSION *session;
 
83
 
 
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);
 
91
    return (session);
 
92
}
 
93
 
 
94
/* lmtp_session_free - destroy LMTP_SESSION structure and contents */
 
95
 
 
96
LMTP_SESSION *lmtp_session_free(LMTP_SESSION *session)
 
97
{
 
98
    debug_peer_restore();
 
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);
 
105
    return (0);
 
106
}