constification
[exim.git] / src / src / auths / get_data.c
CommitLineData
0756eb3c
PH
1/*************************************************
2* Exim - an Internet mail transport agent *
3*************************************************/
4
f9ba5e22 5/* Copyright (c) University of Cambridge 1995 - 2018 */
0756eb3c
PH
6/* See the file NOTICE for conditions of use and distribution. */
7
8#include "../exim.h"
9
10
11/*************************************************
12* Issue a challenge and get a response *
13*************************************************/
14
15/* This function is used by authentication drivers to output a challenge
16to the SMTP client and read the response line.
17
18Arguments:
19 aptr set to point to the response (which is in big_buffer)
20 challenge the challenge text (unencoded, may be binary)
21 challen the length of the challenge text
22
23Returns: OK on success
24 BAD64 if response too large for buffer
25 CANCELLED if response is "*"
26*/
27
28int
1f20760b 29auth_get_data(uschar **aptr, const uschar * challenge, int challen)
0756eb3c
PH
30{
31int c;
32int p = 0;
925ac8e4 33smtp_printf("334 %s\r\n", FALSE, b64encode(challenge, challen));
bd8fbe36 34while ((c = receive_getc(GETC_BUFFER_UNLIMITED)) != '\n' && c != EOF)
0756eb3c
PH
35 {
36 if (p >= big_buffer_size - 1) return BAD64;
37 big_buffer[p++] = c;
38 }
39if (p > 0 && big_buffer[p-1] == '\r') p--;
40big_buffer[p] = 0;
898d150f 41DEBUG(D_receive) debug_printf("SMTP<< %s\n", big_buffer);
0756eb3c
PH
42if (Ustrcmp(big_buffer, "*") == 0) return CANCELLED;
43*aptr = big_buffer;
44return OK;
45}
46
47/* End of get_data.c */