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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
#ifndef _MAIL_CONF_H_INCLUDED_
#define _MAIL_CONF_H_INCLUDED_
/*++
/* NAME
/* mail_conf 3h
/* SUMMARY
/* global configuration parameter management
/* SYNOPSIS
/* #include <mail_conf.h>
/* DESCRIPTION
/* .nf
/*
* Well known names. These are not configurable. One has to start somewhere.
*/
#define CONFIG_DICT "mail_dict" /* global Postfix dictionary */
/*
* Environment variables.
*/
#define CONF_ENV_PATH "MAIL_CONFIG" /* config database */
#define CONF_ENV_VERB "MAIL_VERBOSE" /* verbose mode on */
#define CONF_ENV_DEBUG "MAIL_DEBUG" /* live debugging */
#define CONF_ENV_LOGTAG "MAIL_LOGTAG" /* instance name */
/*
* External representation for booleans.
*/
#define CONFIG_BOOL_YES "yes"
#define CONFIG_BOOL_NO "no"
/*
* Basic configuration management.
*/
extern void mail_conf_read(void);
extern void mail_conf_suck(void);
extern void mail_conf_flush(void);
extern void mail_conf_checkdir(const char *);
extern void mail_conf_update(const char *, const char *);
extern const char *mail_conf_lookup(const char *);
extern const char *mail_conf_eval(const char *);
extern const char *mail_conf_eval_once(const char *);
extern const char *mail_conf_lookup_eval(const char *);
/*
* Specific parameter lookup routines.
*/
extern char *get_mail_conf_str(const char *, const char *, int, int);
extern int get_mail_conf_int(const char *, int, int, int);
extern long get_mail_conf_long(const char *, long, long, long);
extern int get_mail_conf_bool(const char *, int);
extern int get_mail_conf_time(const char *, const char *, int, int);
extern int get_mail_conf_nint(const char *, const char *, int, int);
extern char *get_mail_conf_raw(const char *, const char *, int, int);
extern int get_mail_conf_nbool(const char *, const char *);
extern char *get_mail_conf_str2(const char *, const char *, const char *, int, int);
extern int get_mail_conf_int2(const char *, const char *, int, int, int);
extern long get_mail_conf_long2(const char *, const char *, long, long, long);
extern int get_mail_conf_time2(const char *, const char *, int, int, int, int);
extern int get_mail_conf_nint2(const char *, const char *, int, int, int);
extern void check_mail_conf_str(const char *, const char *, int, int);
extern void check_mail_conf_time(const char *, int, int, int);
extern void check_mail_conf_int(const char *, int, int, int);
/*
* Lookup with function-call defaults.
*/
extern char *get_mail_conf_str_fn(const char *, const char *(*) (void), int, int);
extern int get_mail_conf_int_fn(const char *, int (*) (void), int, int);
extern long get_mail_conf_long_fn(const char *, long (*) (void), long, long);
extern int get_mail_conf_bool_fn(const char *, int (*) (void));
extern int get_mail_conf_time_fn(const char *, const char *(*) (void), int, int, int);
extern int get_mail_conf_nint_fn(const char *, const char *(*) (void), int, int);
extern char *get_mail_conf_raw_fn(const char *, const char *(*) (void), int, int);
extern int get_mail_conf_nbool_fn(const char *, const char *(*) (void));
/*
* Update dictionary.
*/
extern void set_mail_conf_str(const char *, const char *);
extern void set_mail_conf_int(const char *, int);
extern void set_mail_conf_long(const char *, long);
extern void set_mail_conf_bool(const char *, int);
extern void set_mail_conf_time(const char *, const char *);
extern void set_mail_conf_time_int(const char *, int);
extern void set_mail_conf_nint(const char *, const char *);
extern void set_mail_conf_nint_int(const char *, int);
extern void set_mail_conf_nbool(const char *, const char *);
#define set_mail_conf_nbool_int(name, value) \
set_mail_conf_nbool((name), (value) ? CONFIG_BOOL_YES : CONFIG_BOOL_NO)
/*
* Tables that allow us to selectively copy values from the global
* configuration file to global variables.
*/
typedef struct {
const char *name; /* config variable name */
const char *defval; /* default value or null */
char **target; /* pointer to global variable */
int min; /* min length or zero */
int max; /* max length or zero */
} CONFIG_STR_TABLE;
typedef struct {
const char *name; /* config variable name */
const char *defval; /* default value or null */
char **target; /* pointer to global variable */
int min; /* min length or zero */
int max; /* max length or zero */
} CONFIG_RAW_TABLE;
typedef struct {
const char *name; /* config variable name */
int defval; /* default value */
int *target; /* pointer to global variable */
int min; /* lower bound or zero */
int max; /* upper bound or zero */
} CONFIG_INT_TABLE;
typedef struct {
const char *name; /* config variable name */
long defval; /* default value */
long *target; /* pointer to global variable */
long min; /* lower bound or zero */
long max; /* upper bound or zero */
} CONFIG_LONG_TABLE;
typedef struct {
const char *name; /* config variable name */
int defval; /* default value */
int *target; /* pointer to global variable */
} CONFIG_BOOL_TABLE;
typedef struct {
const char *name; /* config variable name */
const char *defval; /* default value + default unit */
int *target; /* pointer to global variable */
int min; /* lower bound or zero */
int max; /* upper bound or zero */
} CONFIG_TIME_TABLE;
typedef struct {
const char *name; /* config variable name */
const char *defval; /* default value + default unit */
int *target; /* pointer to global variable */
int min; /* lower bound or zero */
int max; /* upper bound or zero */
} CONFIG_NINT_TABLE;
typedef struct {
const char *name; /* config variable name */
const char *defval; /* default value */
int *target; /* pointer to global variable */
} CONFIG_NBOOL_TABLE;
extern void get_mail_conf_str_table(const CONFIG_STR_TABLE *);
extern void get_mail_conf_int_table(const CONFIG_INT_TABLE *);
extern void get_mail_conf_long_table(const CONFIG_LONG_TABLE *);
extern void get_mail_conf_bool_table(const CONFIG_BOOL_TABLE *);
extern void get_mail_conf_time_table(const CONFIG_TIME_TABLE *);
extern void get_mail_conf_nint_table(const CONFIG_NINT_TABLE *);
extern void get_mail_conf_raw_table(const CONFIG_RAW_TABLE *);
extern void get_mail_conf_nbool_table(const CONFIG_NBOOL_TABLE *);
/*
* Tables to initialize parameters from the global configuration file or
* from function calls.
*/
typedef struct {
const char *name; /* config variable name */
const char *(*defval) (void); /* default value provider */
char **target; /* pointer to global variable */
int min; /* lower bound or zero */
int max; /* upper bound or zero */
} CONFIG_STR_FN_TABLE;
typedef struct {
const char *name; /* config variable name */
const char *(*defval) (void); /* default value provider */
char **target; /* pointer to global variable */
int min; /* lower bound or zero */
int max; /* upper bound or zero */
} CONFIG_RAW_FN_TABLE;
typedef struct {
const char *name; /* config variable name */
int (*defval) (void); /* default value provider */
int *target; /* pointer to global variable */
int min; /* lower bound or zero */
int max; /* upper bound or zero */
} CONFIG_INT_FN_TABLE;
typedef struct {
const char *name; /* config variable name */
long (*defval) (void); /* default value provider */
long *target; /* pointer to global variable */
long min; /* lower bound or zero */
long max; /* upper bound or zero */
} CONFIG_LONG_FN_TABLE;
typedef struct {
const char *name; /* config variable name */
int (*defval) (void); /* default value provider */
int *target; /* pointer to global variable */
} CONFIG_BOOL_FN_TABLE;
typedef struct {
const char *name; /* config variable name */
const char *(*defval) (void); /* default value provider */
int *target; /* pointer to global variable */
int min; /* lower bound or zero */
int max; /* upper bound or zero */
} CONFIG_NINT_FN_TABLE;
typedef struct {
const char *name; /* config variable name */
const char *(*defval) (void); /* default value provider */
int *target; /* pointer to global variable */
} CONFIG_NBOOL_FN_TABLE;
extern void get_mail_conf_str_fn_table(const CONFIG_STR_FN_TABLE *);
extern void get_mail_conf_int_fn_table(const CONFIG_INT_FN_TABLE *);
extern void get_mail_conf_long_fn_table(const CONFIG_LONG_FN_TABLE *);
extern void get_mail_conf_bool_fn_table(const CONFIG_BOOL_FN_TABLE *);
extern void get_mail_conf_raw_fn_table(const CONFIG_RAW_FN_TABLE *);
extern void get_mail_conf_nint_fn_table(const CONFIG_NINT_FN_TABLE *);
extern void get_mail_conf_nbool_fn_table(const CONFIG_NBOOL_FN_TABLE *);
/* 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
/*--*/
#endif
|