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