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