~ubuntu-branches/ubuntu/trusty/postfix/trusty-proposed

« back to all changes in this revision

Viewing changes to src/cleanup/cleanup_out_recipient.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2005-02-27 09:33:07 UTC
  • Revision ID: james.westby@ubuntu.com-20050227093307-cn789t27ibnlh6tf
Tags: upstream-2.1.5
ImportĀ upstreamĀ versionĀ 2.1.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*++
 
2
/* NAME
 
3
/*      cleanup_out_recipient 3
 
4
/* SUMMARY
 
5
/*      envelope recipient output filter
 
6
/* SYNOPSIS
 
7
/*      #include "cleanup.h"
 
8
/*
 
9
/*      void    cleanup_out_recipient(state, orig_recipient, recipient)
 
10
/*      CLEANUP_STATE *state;
 
11
/*      const char *orig_recipient;
 
12
/*      const char *recipient;
 
13
/* DESCRIPTION
 
14
/*      This module implements an envelope recipient output filter.
 
15
/*
 
16
/*      cleanup_out_recipient() performs virtual table expansion
 
17
/*      and recipient duplicate filtering, and appends the
 
18
/*      resulting recipients to the output stream.
 
19
/* CONFIGURATION
 
20
/* .ad
 
21
/* .fi
 
22
/* .IP local_duplicate_filter_limit
 
23
/*      Upper bound to the size of the recipient duplicate filter.
 
24
/*      Zero means no limit; this may cause the mail system to
 
25
/*      become stuck.
 
26
/* .IP virtual_alias_maps
 
27
/*      list of virtual address lookup tables.
 
28
/* LICENSE
 
29
/* .ad
 
30
/* .fi
 
31
/*      The Secure Mailer license must be distributed with this software.
 
32
/* AUTHOR(S)
 
33
/*      Wietse Venema
 
34
/*      IBM T.J. Watson Research
 
35
/*      P.O. Box 704
 
36
/*      Yorktown Heights, NY 10598, USA
 
37
/*--*/
 
38
 
 
39
/* System library. */
 
40
 
 
41
#include <sys_defs.h>
 
42
#include <string.h>
 
43
 
 
44
#ifdef STRCASECMP_IN_STRINGS_H
 
45
#include <strings.h>
 
46
#endif
 
47
 
 
48
/* Utility library. */
 
49
 
 
50
#include <argv.h>
 
51
 
 
52
/* Global library. */
 
53
 
 
54
#include <been_here.h>
 
55
#include <mail_params.h>
 
56
#include <rec_type.h>
 
57
#include <ext_prop.h>
 
58
#include <cleanup_user.h>
 
59
 
 
60
/* Application-specific. */
 
61
 
 
62
#include "cleanup.h"
 
63
 
 
64
/* cleanup_out_recipient - envelope recipient output filter */
 
65
 
 
66
void    cleanup_out_recipient(CLEANUP_STATE *state, const char *orcpt,
 
67
                                      const char *recip)
 
68
{
 
69
    ARGV   *argv;
 
70
    char  **cpp;
 
71
 
 
72
    /*
 
73
     * XXX Not elegant, but eliminates complexity in the record reading loop.
 
74
     */
 
75
    if (!var_enable_orcpt)
 
76
        orcpt = "";
 
77
 
 
78
    /*
 
79
     * Distinguish between different original recipient addresses that map
 
80
     * onto the same mailbox. The recipient will use our original recipient
 
81
     * message header to figure things out.
 
82
     */
 
83
#define STREQ(x, y) (strcmp((x), (y)) == 0)
 
84
 
 
85
    if ((state->flags & CLEANUP_FLAG_MAP_OK) == 0
 
86
        || cleanup_virt_alias_maps == 0) {
 
87
        if ((STREQ(orcpt, recip) ? been_here(state->dups, "%s", orcpt) :
 
88
             been_here(state->dups, "%s\n%s", orcpt, recip)) == 0) {
 
89
            cleanup_out_string(state, REC_TYPE_ORCP, orcpt);
 
90
            cleanup_out_string(state, REC_TYPE_RCPT, recip);
 
91
            state->rcpt_count++;
 
92
        }
 
93
    } else {
 
94
        argv = cleanup_map1n_internal(state, recip, cleanup_virt_alias_maps,
 
95
                                  cleanup_ext_prop_mask & EXT_PROP_VIRTUAL);
 
96
        for (cpp = argv->argv; *cpp; cpp++) {
 
97
            if ((STREQ(orcpt, *cpp) ? been_here(state->dups, "%s", orcpt) :
 
98
                 been_here(state->dups, "%s\n%s", orcpt, *cpp)) == 0) {
 
99
                cleanup_out_string(state, REC_TYPE_ORCP, orcpt);
 
100
                cleanup_out_string(state, REC_TYPE_RCPT, *cpp);
 
101
                state->rcpt_count++;
 
102
            }
 
103
        }
 
104
        argv_free(argv);
 
105
    }
 
106
}