SPDX: license tags (mostly by guesswork)
[exim.git] / src / src / lss.c
1 /*************************************************
2 *     Exim - an Internet mail transport agent    *
3 *************************************************/
4
5 /* Copyright (c) University of Cambridge 1995 - 2015 */
6 /* See the file NOTICE for conditions of use and distribution. */
7 /* SPDX-License-Identifier: GPL-2.0-only */
8
9 /* Support functions for calling from local_scan(). These are mostly just
10 wrappers for various internal functions. */
11
12
13 #include "exim.h"
14
15
16 /*************************************************
17 *            Match a domain in a list            *
18 *************************************************/
19
20 /*
21 Arguments:
22   domain         the domain we are testing
23   list           the domain list
24
25 Returns:         OK/FAIL/DEFER
26 */
27
28 int
29 lss_match_domain(uschar *domain, uschar *list)
30 {
31 return match_isinlist(CUS domain, CUSS &list, 0, &domainlist_anchor, NULL, MCL_DOMAIN,
32   TRUE, NULL);
33 }
34
35
36
37 /*************************************************
38 *            Match a local part in a list        *
39 *************************************************/
40
41 /*
42 Arguments:
43   local_part     the local part we are testing
44   list           the local part list
45   caseless       TRUE for caseless matching
46
47 Returns:         OK/FAIL/DEFER
48 */
49
50 int
51 lss_match_local_part(uschar *local_part, uschar *list, BOOL caseless)
52 {
53 return match_isinlist(CUS local_part, CUSS &list, 0, &localpartlist_anchor, NULL,
54   MCL_LOCALPART, caseless, NULL);
55 }
56
57
58
59 /*************************************************
60 *            Match an address in a list          *
61 *************************************************/
62
63 /*
64 Arguments:
65   address        the address we are testing
66   list           the address list
67   caseless       TRUE for caseless matching
68
69 Returns:         OK/FAIL/DEFER
70 */
71
72 int
73 lss_match_address(uschar *address, uschar *list, BOOL caseless)
74 {
75 return match_address_list(CUS address, caseless, TRUE, CUSS &list, NULL, -1, 0, NULL);
76 }
77
78
79
80 /*************************************************
81 *            Match a host in a list              *
82 *************************************************/
83
84 /*
85 Arguments:
86   host name      the name of the host we are testing, or NULL if this is the
87                    sender host and its name hasn't yet been looked up
88   host address   the IP address of the host, or an empty string for a local
89                    message
90   list           the host list
91
92 Returns:         OK/FAIL/DEFER
93                  ERROR if failed to find host name when needed
94 */
95
96 int
97 lss_match_host(uschar *host_name, uschar *host_address, uschar *list)
98 {
99 return verify_check_this_host(CUSS &list, NULL, host_name, host_address, NULL);
100 }
101
102
103
104 /*************************************************
105 *           Base 64 encode/decode                *
106 *************************************************/
107
108 /* These functions just give less "internal" names to the functions.
109
110 Arguments:
111   clear       points to the clear text bytes
112   len         the number of bytes to encode
113
114 Returns:      a pointer to the zero-terminated base 64 string, which
115               is in working store
116 */
117
118 uschar *
119 lss_b64encode(uschar * clear, int len)
120 {
121 return b64encode(CUS clear, len);
122 }
123
124 /*
125 Arguments:
126   code        points to the coded string, zero-terminated
127   ptr         where to put the pointer to the result, which is in
128               dynamic store
129
130 Returns:      the number of bytes in the result,
131               or -1 if the input was malformed
132
133 A zero is added on to the end to make it easy in cases where the result is to
134 be interpreted as text. This is not included in the count. */
135
136 int
137 lss_b64decode(uschar *code, uschar **ptr)
138 {
139 return b64decode(code, ptr);
140 }
141
142
143 /* End of lss.c */