aboutsummaryrefslogtreecommitdiffstats
path: root/src/smtp_utils.h
blob: b32b8235e08c8ea9ab0c8b63f6a69bd7ff88690e (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef SMTP_UTILS_H_
#define SMTP_UTILS_H_

#include "config.h"
#include "main.h"
#include "smtp.h"

/**
 * @file smtp_utils.h
 * Contains utilities for smtp protocol handling
 */

struct smtp_upstream {
	struct upstream up;

	const gchar *name;
	struct in_addr addr;
	guint16 port;
	gboolean is_unix;
};

#define MAX_SMTP_UPSTREAMS 128

struct smtp_session;

/**
 * Send message to upstream
 * @param session session object
 */
gboolean smtp_send_upstream_message (struct smtp_session *session);

/**
 * Create connection to upstream
 * @param session session object
 */
gboolean create_smtp_upstream_connection (struct smtp_session *session);

/**
 * Create temporary file for smtp session
 */
gboolean make_smtp_tempfile (struct smtp_session *session);

/**
 * Write reply to upstream
 * @param session session object
 */
gboolean write_smtp_reply (struct smtp_session *session);

/**
 * Frees smtp session object
 */
void free_smtp_session (gpointer arg);

/**
 * Parse upstreams line
 * @param upstreams pointer to the array of upstreams (must be at least MAX_SMTP_UPSTREAMS size)
 * @param line description line
 * @param count targeted count
 * @return
 */
gboolean parse_upstreams_line (memory_pool_t *pool, struct smtp_upstream *upstreams, const gchar *line, gsize *count);

#endif /* SMTP_UTILS_H_ */