summaryrefslogtreecommitdiffstats
path: root/src/smtp/smtp_misc.c
blob: 43a176fa8daa326ee779c6af1f7edba466b819c9 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*++
/* NAME
/*	smtp_misc 3
/* SUMMARY
/*	SMTP client address rewriting
/* SYNOPSIS
/*	#include <smtp_addr.h>
/*
/*	void	smtp_rewrite_generic_internal(
/*	VSTRING *dst,
/*	const char *src);
/*
/*	void	smtp_quote_822_address_flags(
/*	VSTRING *dst,
/*	const char *src,
/*	int flags);
/*
/*	void	smtp_quote_821_address(
/*	VSTRING *dst,
/*	const char *src);
/* DESCRIPTION
/*	smtp_rewrite_generic_internal() rewrites a non-empty address
/*	if generic mapping is enabled, otherwise copies it literally.
/*
/*	smtp_quote_822_address_flags() is a wrapper around
/*	quote_822_local_flags(), except for the empty address which
/*	is copied literally.
/*
/*	smtp_quote_821_address() is a wrapper around quote_821_local(),
/*	except for the empty address or with "smtp_quote_rfc821_envelope
/*	= no"; in those cases the address is copied literally.
/* DIAGNOSTICS
/*	Fatal: out of memory.
/* LICENSE
/* .ad
/* .fi
/*	The Secure Mailer license must be distributed with this software.
/* AUTHOR(S)
/*	Wietse Venema
/*	Google, Inc.
/*	111 8th Avenue
/*	New York, NY 10011, USA
/*--*/

 /*
  * System library.
  */
#include <sys_defs.h>

 /*
  * Utility library.
  */
#include <vstring.h>

 /*
  * Global library.
  */
#include <ext_prop.h>
#include <mail_params.h>
#include <quote_821_local.h>
#include <quote_822_local.h>

 /*
  * Application-specific.
  */
#include <smtp.h>

/* smtp_rewrite_generic_internal - generic non-empty address rewriting */

void    smtp_rewrite_generic_internal(VSTRING *dst, const char *src)
{
    vstring_strcpy(dst, src);
    if (*src && smtp_generic_maps)
	smtp_map11_internal(dst, smtp_generic_maps,
			    smtp_ext_prop_mask & EXT_PROP_GENERIC);
}

/* smtp_quote_822_address_flags - quote non-empty header address */

void    smtp_quote_822_address_flags(VSTRING *dst, const char *src, int flags)
{
    if (*src) {
	quote_822_local_flags(dst, src, flags);
    } else if (flags & QUOTE_FLAG_APPEND) {
	vstring_strcat(dst, src);
    } else {
	vstring_strcpy(dst, src);
    }
}

/* smtp_quote_821_address - quote non-empty envelope address */

void    smtp_quote_821_address(VSTRING *dst, const char *src)
{
    if (*src && var_smtp_quote_821_env) {
	quote_821_local(dst, src);
    } else {
	vstring_strcpy(dst, src);
    }
}