summaryrefslogtreecommitdiffstats
path: root/src/master/mail_server.h
blob: 93703daf7517257824245571da1ec0cb734e930b (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*++
/* NAME
/*	mail_server 3h
/* SUMMARY
/*	skeleton servers
/* SYNOPSIS
/*	#include <mail_server.h>
/* DESCRIPTION
/* .nf

 /*
  * Utility library.
  */
#include <vstream.h>
#include <htable.h>

 /*
  * Global library.
  */
#include <mail_conf.h>

 /*
  * External interface. Tables are defined in mail_conf.h.
  */
#define MAIL_SERVER_INT_TABLE	1
#define MAIL_SERVER_STR_TABLE	2
#define MAIL_SERVER_BOOL_TABLE	3
#define MAIL_SERVER_TIME_TABLE	4
#define MAIL_SERVER_RAW_TABLE	5
#define MAIL_SERVER_NINT_TABLE	6
#define MAIL_SERVER_NBOOL_TABLE	7
#define MAIL_SERVER_LONG_TABLE	8

#define	MAIL_SERVER_PRE_INIT	10
#define MAIL_SERVER_POST_INIT	11
#define MAIL_SERVER_LOOP	12
#define MAIL_SERVER_EXIT	13
#define MAIL_SERVER_PRE_ACCEPT	14
#define MAIL_SERVER_SOLITARY	15
#define MAIL_SERVER_UNLIMITED	16
#define MAIL_SERVER_PRE_DISCONN	17
#define MAIL_SERVER_PRIVILEGED	18
#define MAIL_SERVER_WATCHDOG	19

#define MAIL_SERVER_IN_FLOW_DELAY	20
#define MAIL_SERVER_SLOW_EXIT	21
#define MAIL_SERVER_BOUNCE_INIT	22
#define MAIL_SERVER_RETIRE_ME	23
#define MAIL_SERVER_POST_ACCEPT	24

typedef void (*MAIL_SERVER_INIT_FN) (char *, char **);
typedef int (*MAIL_SERVER_LOOP_FN) (char *, char **);
typedef void (*MAIL_SERVER_EXIT_FN) (char *, char **);
typedef void (*MAIL_SERVER_ACCEPT_FN) (char *, char **);
typedef void (*MAIL_SERVER_POST_ACCEPT_FN) (VSTREAM *, char *, char **, HTABLE *);
typedef void (*MAIL_SERVER_DISCONN_FN) (VSTREAM *, char *, char **);
typedef void (*MAIL_SERVER_SLOW_EXIT_FN) (char *, char **);

/* Type-checked API for external use. */
#define CA_MAIL_SERVER_INT_TABLE(v)	MAIL_SERVER_INT_TABLE, CHECK_CPTR(MAIL_SERVER, CONFIG_INT_TABLE, (v))
#define CA_MAIL_SERVER_STR_TABLE(v)	MAIL_SERVER_STR_TABLE, CHECK_CPTR(MAIL_SERVER, CONFIG_STR_TABLE, (v))
#define CA_MAIL_SERVER_BOOL_TABLE(v)	MAIL_SERVER_BOOL_TABLE, CHECK_CPTR(MAIL_SERVER, CONFIG_BOOL_TABLE, (v))
#define CA_MAIL_SERVER_TIME_TABLE(v)	MAIL_SERVER_TIME_TABLE, CHECK_CPTR(MAIL_SERVER, CONFIG_TIME_TABLE, (v))
#define CA_MAIL_SERVER_RAW_TABLE(v)	MAIL_SERVER_RAW_TABLE, CHECK_CPTR(MAIL_SERVER, CONFIG_RAW_TABLE, (v))
#define CA_MAIL_SERVER_NINT_TABLE(v)	MAIL_SERVER_NINT_TABLE, CHECK_CPTR(MAIL_SERVER, CONFIG_NINT_TABLE, (v))
#define CA_MAIL_SERVER_NBOOL_TABLE(v)	MAIL_SERVER_NBOOL_TABLE, CHECK_CPTR(MAIL_SERVER, CONFIG_NBOOL_TABLE, (v))
#define CA_MAIL_SERVER_LONG_TABLE(v)	MAIL_SERVER_LONG_TABLE, CHECK_CPTR(MAIL_SERVER, CONFIG_LONG_TABLE, (v))
#define CA_MAIL_SERVER_PRE_INIT(v)	MAIL_SERVER_PRE_INIT, CHECK_VAL(MAIL_SERVER, MAIL_SERVER_INIT_FN, (v))
#define CA_MAIL_SERVER_POST_INIT(v)	MAIL_SERVER_POST_INIT, CHECK_VAL(MAIL_SERVER, MAIL_SERVER_INIT_FN, (v))
#define CA_MAIL_SERVER_LOOP(v)		MAIL_SERVER_LOOP, CHECK_VAL(MAIL_SERVER, MAIL_SERVER_LOOP_FN, (v))
#define CA_MAIL_SERVER_EXIT(v)		MAIL_SERVER_EXIT, CHECK_VAL(MAIL_SERVER, MAIL_SERVER_EXIT_FN, (v))
#define CA_MAIL_SERVER_PRE_ACCEPT(v)	MAIL_SERVER_PRE_ACCEPT, CHECK_VAL(MAIL_SERVER, MAIL_SERVER_ACCEPT_FN, (v))
#define CA_MAIL_SERVER_POST_ACCEPT(v)	MAIL_SERVER_POST_ACCEPT, CHECK_VAL(MAIL_SERVER, MAIL_SERVER_POST_ACCEPT_FN, (v))
#define CA_MAIL_SERVER_SOLITARY	MAIL_SERVER_SOLITARY
#define CA_MAIL_SERVER_UNLIMITED	MAIL_SERVER_UNLIMITED
#define CA_MAIL_SERVER_PRE_DISCONN(v)	MAIL_SERVER_PRE_DISCONN, CHECK_VAL(MAIL_SERVER, MAIL_SERVER_DISCONN_FN, (v))
#define CA_MAIL_SERVER_PRIVILEGED	MAIL_SERVER_PRIVILEGED
#define CA_MAIL_SERVER_WATCHDOG(v)	MAIL_SERVER_WATCHDOG, CHECK_PTR(MAIL_SERVER, int, (v))
#define CA_MAIL_SERVER_IN_FLOW_DELAY	MAIL_SERVER_IN_FLOW_DELAY
#define CA_MAIL_SERVER_SLOW_EXIT(v)	MAIL_SERVER_SLOW_EXIT, CHECK_VAL(MAIL_SERVER, MAIL_SERVER_SLOW_EXIT_FN, (v))
#define CA_MAIL_SERVER_BOUNCE_INIT(v, w) MAIL_SERVER_BOUNCE_INIT, CHECK_PTR(MAIL_SERVER, char, (v)), CHECK_PPTR(MAIL_SERVER, char, (w))
#define CA_MAIL_SERVER_RETIRE_ME	MAIL_SERVER_RETIRE_ME

CHECK_VAL_HELPER_DCL(MAIL_SERVER, MAIL_SERVER_SLOW_EXIT_FN);
CHECK_VAL_HELPER_DCL(MAIL_SERVER, MAIL_SERVER_LOOP_FN);
CHECK_VAL_HELPER_DCL(MAIL_SERVER, MAIL_SERVER_INIT_FN);
CHECK_VAL_HELPER_DCL(MAIL_SERVER, MAIL_SERVER_EXIT_FN);
CHECK_VAL_HELPER_DCL(MAIL_SERVER, MAIL_SERVER_DISCONN_FN);
CHECK_VAL_HELPER_DCL(MAIL_SERVER, MAIL_SERVER_ACCEPT_FN);
CHECK_VAL_HELPER_DCL(MAIL_SERVER, MAIL_SERVER_POST_ACCEPT_FN);
CHECK_PTR_HELPER_DCL(MAIL_SERVER, int);
CHECK_PTR_HELPER_DCL(MAIL_SERVER, char);
CHECK_PPTR_HELPER_DCL(MAIL_SERVER, char);
CHECK_CPTR_HELPER_DCL(MAIL_SERVER, CONFIG_TIME_TABLE);
CHECK_CPTR_HELPER_DCL(MAIL_SERVER, CONFIG_STR_TABLE);
CHECK_CPTR_HELPER_DCL(MAIL_SERVER, CONFIG_RAW_TABLE);
CHECK_CPTR_HELPER_DCL(MAIL_SERVER, CONFIG_NINT_TABLE);
CHECK_CPTR_HELPER_DCL(MAIL_SERVER, CONFIG_NBOOL_TABLE);
CHECK_CPTR_HELPER_DCL(MAIL_SERVER, CONFIG_LONG_TABLE);
CHECK_CPTR_HELPER_DCL(MAIL_SERVER, CONFIG_INT_TABLE);
CHECK_CPTR_HELPER_DCL(MAIL_SERVER, CONFIG_BOOL_TABLE);

 /*
  * single_server.c
  */
typedef void (*SINGLE_SERVER_FN) (VSTREAM *, char *, char **);
extern NORETURN single_server_main(int, char **, SINGLE_SERVER_FN,...);

 /*
  * multi_server.c
  */
typedef void (*MULTI_SERVER_FN) (VSTREAM *, char *, char **);
extern NORETURN multi_server_main(int, char **, MULTI_SERVER_FN,...);
extern void multi_server_disconnect(VSTREAM *);
extern int multi_server_drain(void);

 /*
  * event_server.c
  */
typedef void (*EVENT_SERVER_FN) (VSTREAM *, char *, char **);
extern NORETURN event_server_main(int, char **, EVENT_SERVER_FN,...);
extern void event_server_disconnect(VSTREAM *);
extern int event_server_drain(void);

 /*
  * trigger_server.c
  */
typedef void (*TRIGGER_SERVER_FN) (char *, ssize_t, char *, char **);
extern NORETURN trigger_server_main(int, char **, TRIGGER_SERVER_FN,...);

#define TRIGGER_BUF_SIZE	1024

 /*
  * dgram_server.c
  */
typedef void (*DGRAM_SERVER_FN) (char *, ssize_t, char *, char **);
extern NORETURN dgram_server_main(int, char **, DGRAM_SERVER_FN,...);

#define DGRAM_BUF_SIZE	4096

/* LICENSE
/* .ad
/* .fi
/*	The Secure Mailer license must be distributed with this software.
/* AUTHOR(S)
/*	Wietse Venema
/*	IBM T.J. Watson Research
/*	P.O. Box 704
/*	Yorktown Heights, NY 10598, USA
/*
/*	Wietse Venema
/*	Google, Inc.
/*	111 8th Avenue
/*	New York, NY 10011, USA
/*--*/