summaryrefslogtreecommitdiffstats
path: root/src/lmtp_proto.h
blob: 11d994e698de442debcdcfcfabc171c24d863df5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef RSPAMD_LMTP_PROTO_H
#define RSPAMD_LMTP_PROTO_H

#include "config.h"

struct worker_task;

enum lmtp_state {
	LMTP_READ_LHLO,
	LMTP_READ_FROM,
	LMTP_READ_RCPT,
	LMTP_READ_DATA,
	LMTP_READ_MESSAGE,
	LMTP_READ_DOT,
};

struct rspamd_lmtp_proto {
	struct worker_task *task;
	enum lmtp_state state;
};

/**
 * Read one line of user's input for specified task
 * @param lmtp lmtp object
 * @param line line of user's input
 * @return 0 if line was successfully parsed and -1 if we have protocol error
 */
gint read_lmtp_input_line (struct rspamd_lmtp_proto *lmtp, f_str_t *line);

/**
 * Deliver message via lmtp/smtp or pipe to LDA
 * @param task task object
 * @return 0 if we wrote message and -1 if there was some error
 */
gint lmtp_deliver_message (struct worker_task *task);

/**
 * Write reply for specified lmtp object
 * @param lmtp lmtp object
 * @return 0 if we wrote reply and -1 if there was some error
 */
gint write_lmtp_reply (struct rspamd_lmtp_proto *lmtp);

#endif