1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) The Exim Maintainers 2022 */
6 /* Copyright (c) University of Cambridge 1995 - 2018 */
7 /* See the file NOTICE for conditions of use and distribution. */
12 /*************************************************
13 * Encode byte-string in xtext *
14 *************************************************/
16 /* This function encodes a string of bytes, containing any values whatsoever,
17 as "xtext", as defined in RFC 1891 and required by the SMTP AUTH extension (RFC
21 clear points to the clear text bytes
22 len the number of bytes to encode
24 Returns: a pointer to the zero-terminated xtext string, which
29 auth_xtextencode(uschar *clear, int len)
38 /* We have to do a prepass to find out how many specials there are,
39 in order to get the right amount of store. */
42 count += ((x = *p++) < 33 || x > 127 || x == '+' || x == '=')? 3 : 1;
44 pp = code = store_get(count, clear);
49 if ((x = *p++) < 33 || x > 127 || x == '+' || x == '=')
50 pp += sprintf(CS pp, "+%.02x", x); /* There's always room */
58 /* End of xtextencode.c */