1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) The Exim Maintainers 2023 */
6 /* Copyright (c) University of Cambridge 1995 - 2015 */
7 /* See the file NOTICE for conditions of use and distribution. */
8 /* SPDX-License-Identifier: GPL-2.0-or-later */
10 /* Support functions for calling from local_scan(). These are mostly just
11 wrappers for various internal functions. */
17 /*************************************************
18 * Match a domain in a list *
19 *************************************************/
23 domain the domain we are testing
26 Returns: OK/FAIL/DEFER
30 lss_match_domain(uschar *domain, uschar *list)
32 return match_isinlist(CUS domain, CUSS &list, 0, &domainlist_anchor, NULL, MCL_DOMAIN,
38 /*************************************************
39 * Match a local part in a list *
40 *************************************************/
44 local_part the local part we are testing
45 list the local part list
46 caseless TRUE for caseless matching
48 Returns: OK/FAIL/DEFER
52 lss_match_local_part(uschar *local_part, uschar *list, BOOL caseless)
54 return match_isinlist(CUS local_part, CUSS &list, 0, &localpartlist_anchor, NULL,
55 MCL_LOCALPART, caseless, NULL);
60 /*************************************************
61 * Match an address in a list *
62 *************************************************/
66 address the address we are testing
68 caseless TRUE for caseless matching
70 Returns: OK/FAIL/DEFER
74 lss_match_address(uschar *address, uschar *list, BOOL caseless)
76 return match_address_list(CUS address, caseless, TRUE, CUSS &list, NULL, -1, 0, NULL);
81 /*************************************************
82 * Match a host in a list *
83 *************************************************/
87 host name the name of the host we are testing, or NULL if this is the
88 sender host and its name hasn't yet been looked up
89 host address the IP address of the host, or an empty string for a local
93 Returns: OK/FAIL/DEFER
94 ERROR if failed to find host name when needed
98 lss_match_host(uschar *host_name, uschar *host_address, uschar *list)
100 return verify_check_this_host(CUSS &list, NULL, host_name, host_address, NULL);
105 /*************************************************
106 * Base 64 encode/decode *
107 *************************************************/
109 /* These functions just give less "internal" names to the functions.
112 clear points to the clear text bytes
113 len the number of bytes to encode
115 Returns: a pointer to the zero-terminated base 64 string, which
120 lss_b64encode(uschar * clear, int len)
122 return b64encode(CUS clear, len);
127 code points to the coded string, zero-terminated
128 ptr where to put the pointer to the result, which is in
131 Returns: the number of bytes in the result,
132 or -1 if the input was malformed
134 A zero is added on to the end to make it easy in cases where the result is to
135 be interpreted as text. This is not included in the count. */
138 lss_b64decode(uschar * code, uschar ** ptr)
140 return b64decode(code, ptr, code);