Imported Upstream version 4.84
[hcoop/debian/exim4.git] / src / auths / get_no64_data.c
1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
4
5 /* Copyright (c) University of Cambridge 1995 - 2012 */
6 /* See the file NOTICE for conditions of use and distribution. */
7
8 #include "../exim.h"
9
10
11 /*************************************************
12 * Issue a non-b64 challenge and get a response *
13 *************************************************/
14
15 /* This function is used by authentication drivers to output a challenge
16 to the SMTP client and read the response line. This version does not use base
17 64 encoding for the text on the 334 line. It is used by the SPA, dovecot
18 and gsasl authenticators.
19
20 Arguments:
21 aptr set to point to the response (which is in big_buffer)
22 challenge the challenge text (unencoded)
23
24 Returns: OK on success
25 BAD64 if response too large for buffer
26 CANCELLED if response is "*"
27 */
28
29 int
30 auth_get_no64_data(uschar **aptr, uschar *challenge)
31 {
32 int c;
33 int p = 0;
34 smtp_printf("334 %s\r\n", challenge);
35 while ((c = receive_getc()) != '\n' && c != EOF)
36 {
37 if (p >= big_buffer_size - 1) return BAD64;
38 big_buffer[p++] = c;
39 }
40 if (p > 0 && big_buffer[p-1] == '\r') p--;
41 big_buffer[p] = 0;
42 if (Ustrcmp(big_buffer, "*") == 0) return CANCELLED;
43 *aptr = big_buffer;
44 return OK;
45 }
46
47 /* End of get_no64_data.c */