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