xref: /netbsd-src/external/ibm-public/postfix/dist/src/global/mail_conf.h (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1 /*	$NetBSD: mail_conf.h,v 1.2 2017/02/14 01:16:45 christos Exp $	*/
2 
3 #ifndef _MAIL_CONF_H_INCLUDED_
4 #define _MAIL_CONF_H_INCLUDED_
5 
6 /*++
7 /* NAME
8 /*	mail_conf 3h
9 /* SUMMARY
10 /*	global configuration parameter management
11 /* SYNOPSIS
12 /*	#include <mail_conf.h>
13 /* DESCRIPTION
14 /* .nf
15 
16  /*
17   * Well known names. These are not configurable. One has to start somewhere.
18   */
19 #define CONFIG_DICT	"mail_dict"	/* global Postfix dictionary */
20 
21  /*
22   * Environment variables.
23   */
24 #define CONF_ENV_PATH	"MAIL_CONFIG"	/* config database */
25 #define CONF_ENV_VERB	"MAIL_VERBOSE"	/* verbose mode on */
26 #define CONF_ENV_DEBUG	"MAIL_DEBUG"	/* live debugging */
27 #define CONF_ENV_LOGTAG	"MAIL_LOGTAG"	/* instance name */
28 
29  /*
30   * External representation for booleans.
31   */
32 #define CONFIG_BOOL_YES	"yes"
33 #define CONFIG_BOOL_NO	"no"
34 
35  /*
36   * Basic configuration management.
37   */
38 extern void mail_conf_read(void);
39 extern void mail_conf_suck(void);
40 extern void mail_conf_flush(void);
41 
42 extern void mail_conf_update(const char *, const char *);
43 extern const char *mail_conf_lookup(const char *);
44 extern const char *mail_conf_eval(const char *);
45 extern const char *mail_conf_eval_once(const char *);
46 extern const char *mail_conf_lookup_eval(const char *);
47 
48  /*
49   * Specific parameter lookup routines.
50   */
51 extern char *get_mail_conf_str(const char *, const char *, int, int);
52 extern int get_mail_conf_int(const char *, int, int, int);
53 extern long get_mail_conf_long(const char *, long, long, long);
54 extern int get_mail_conf_bool(const char *, int);
55 extern int get_mail_conf_time(const char *, const char *, int, int);
56 extern int get_mail_conf_nint(const char *, const char *, int, int);
57 extern char *get_mail_conf_raw(const char *, const char *, int, int);
58 extern int get_mail_conf_nbool(const char *, const char *);
59 
60 extern char *get_mail_conf_str2(const char *, const char *, const char *, int, int);
61 extern int get_mail_conf_int2(const char *, const char *, int, int, int);
62 extern long get_mail_conf_long2(const char *, const char *, long, long, long);
63 extern int get_mail_conf_time2(const char *, const char *, int, int, int, int);
64 extern int get_mail_conf_nint2(const char *, const char *, int, int, int);
65 extern void check_mail_conf_str(const char *, const char *, int, int);
66 extern void check_mail_conf_time(const char *, int, int, int);
67 extern void check_mail_conf_int(const char *, int, int, int);
68 
69  /*
70   * Lookup with function-call defaults.
71   */
72 extern char *get_mail_conf_str_fn(const char *, const char *(*) (void), int, int);
73 extern int get_mail_conf_int_fn(const char *, int (*) (void), int, int);
74 extern long get_mail_conf_long_fn(const char *, long (*) (void), long, long);
75 extern int get_mail_conf_bool_fn(const char *, int (*) (void));
76 extern int get_mail_conf_time_fn(const char *, const char *(*) (void), int, int, int);
77 extern int get_mail_conf_nint_fn(const char *, const char *(*) (void), int, int);
78 extern char *get_mail_conf_raw_fn(const char *, const char *(*) (void), int, int);
79 extern int get_mail_conf_nbool_fn(const char *, const char *(*) (void));
80 
81  /*
82   * Update dictionary.
83   */
84 extern void set_mail_conf_str(const char *, const char *);
85 extern void set_mail_conf_int(const char *, int);
86 extern void set_mail_conf_long(const char *, long);
87 extern void set_mail_conf_bool(const char *, int);
88 extern void set_mail_conf_time(const char *, const char *);
89 extern void set_mail_conf_time_int(const char *, int);
90 extern void set_mail_conf_nint(const char *, const char *);
91 extern void set_mail_conf_nint_int(const char *, int);
92 extern void set_mail_conf_nbool(const char *, const char *);
93 
94 #define set_mail_conf_nbool_int(name, value) \
95     set_mail_conf_nbool((name), (value) ? CONFIG_BOOL_YES : CONFIG_BOOL_NO)
96 
97  /*
98   * Tables that allow us to selectively copy values from the global
99   * configuration file to global variables.
100   */
101 typedef struct {
102     const char *name;			/* config variable name */
103     const char *defval;			/* default value or null */
104     char  **target;			/* pointer to global variable */
105     int     min;			/* min length or zero */
106     int     max;			/* max length or zero */
107 } CONFIG_STR_TABLE;
108 
109 typedef struct {
110     const char *name;			/* config variable name */
111     const char *defval;			/* default value or null */
112     char  **target;			/* pointer to global variable */
113     int     min;			/* min length or zero */
114     int     max;			/* max length or zero */
115 } CONFIG_RAW_TABLE;
116 
117 typedef struct {
118     const char *name;			/* config variable name */
119     int     defval;			/* default value */
120     int    *target;			/* pointer to global variable */
121     int     min;			/* lower bound or zero */
122     int     max;			/* upper bound or zero */
123 } CONFIG_INT_TABLE;
124 
125 typedef struct {
126     const char *name;			/* config variable name */
127     long    defval;			/* default value */
128     long   *target;			/* pointer to global variable */
129     long    min;			/* lower bound or zero */
130     long    max;			/* upper bound or zero */
131 } CONFIG_LONG_TABLE;
132 
133 typedef struct {
134     const char *name;			/* config variable name */
135     int     defval;			/* default value */
136     int    *target;			/* pointer to global variable */
137 } CONFIG_BOOL_TABLE;
138 
139 typedef struct {
140     const char *name;			/* config variable name */
141     const char *defval;			/* default value + default unit */
142     int    *target;			/* pointer to global variable */
143     int     min;			/* lower bound or zero */
144     int     max;			/* upper bound or zero */
145 } CONFIG_TIME_TABLE;
146 
147 typedef struct {
148     const char *name;			/* config variable name */
149     const char *defval;			/* default value + default unit */
150     int    *target;			/* pointer to global variable */
151     int     min;			/* lower bound or zero */
152     int     max;			/* upper bound or zero */
153 } CONFIG_NINT_TABLE;
154 
155 typedef struct {
156     const char *name;			/* config variable name */
157     const char *defval;			/* default value */
158     int    *target;			/* pointer to global variable */
159 } CONFIG_NBOOL_TABLE;
160 
161 extern void get_mail_conf_str_table(const CONFIG_STR_TABLE *);
162 extern void get_mail_conf_int_table(const CONFIG_INT_TABLE *);
163 extern void get_mail_conf_long_table(const CONFIG_LONG_TABLE *);
164 extern void get_mail_conf_bool_table(const CONFIG_BOOL_TABLE *);
165 extern void get_mail_conf_time_table(const CONFIG_TIME_TABLE *);
166 extern void get_mail_conf_nint_table(const CONFIG_NINT_TABLE *);
167 extern void get_mail_conf_raw_table(const CONFIG_RAW_TABLE *);
168 extern void get_mail_conf_nbool_table(const CONFIG_NBOOL_TABLE *);
169 
170  /*
171   * Tables to initialize parameters from the global configuration file or
172   * from function calls.
173   */
174 typedef struct {
175     const char *name;			/* config variable name */
176     const char *(*defval) (void);	/* default value provider */
177     char  **target;			/* pointer to global variable */
178     int     min;			/* lower bound or zero */
179     int     max;			/* upper bound or zero */
180 } CONFIG_STR_FN_TABLE;
181 
182 typedef struct {
183     const char *name;			/* config variable name */
184     const char *(*defval) (void);	/* default value provider */
185     char  **target;			/* pointer to global variable */
186     int     min;			/* lower bound or zero */
187     int     max;			/* upper bound or zero */
188 } CONFIG_RAW_FN_TABLE;
189 
190 typedef struct {
191     const char *name;			/* config variable name */
192     int     (*defval) (void);		/* default value provider */
193     int    *target;			/* pointer to global variable */
194     int     min;			/* lower bound or zero */
195     int     max;			/* upper bound or zero */
196 } CONFIG_INT_FN_TABLE;
197 
198 typedef struct {
199     const char *name;			/* config variable name */
200     long    (*defval) (void);		/* default value provider */
201     long   *target;			/* pointer to global variable */
202     long    min;			/* lower bound or zero */
203     long    max;			/* upper bound or zero */
204 } CONFIG_LONG_FN_TABLE;
205 
206 typedef struct {
207     const char *name;			/* config variable name */
208     int     (*defval) (void);		/* default value provider */
209     int    *target;			/* pointer to global variable */
210 } CONFIG_BOOL_FN_TABLE;
211 
212 typedef struct {
213     const char *name;			/* config variable name */
214     const char *(*defval) (void);	/* default value provider */
215     int    *target;			/* pointer to global variable */
216     int     min;			/* lower bound or zero */
217     int     max;			/* upper bound or zero */
218 } CONFIG_NINT_FN_TABLE;
219 
220 typedef struct {
221     const char *name;			/* config variable name */
222     const char *(*defval) (void);	/* default value provider */
223     int    *target;			/* pointer to global variable */
224 } CONFIG_NBOOL_FN_TABLE;
225 
226 extern void get_mail_conf_str_fn_table(const CONFIG_STR_FN_TABLE *);
227 extern void get_mail_conf_int_fn_table(const CONFIG_INT_FN_TABLE *);
228 extern void get_mail_conf_long_fn_table(const CONFIG_LONG_FN_TABLE *);
229 extern void get_mail_conf_bool_fn_table(const CONFIG_BOOL_FN_TABLE *);
230 extern void get_mail_conf_raw_fn_table(const CONFIG_RAW_FN_TABLE *);
231 extern void get_mail_conf_nint_fn_table(const CONFIG_NINT_FN_TABLE *);
232 extern void get_mail_conf_nbool_fn_table(const CONFIG_NBOOL_FN_TABLE *);
233 
234 /* LICENSE
235 /* .ad
236 /* .fi
237 /*	The Secure Mailer license must be distributed with this software.
238 /* AUTHOR(S)
239 /*	Wietse Venema
240 /*	IBM T.J. Watson Research
241 /*	P.O. Box 704
242 /*	Yorktown Heights, NY 10598, USA
243 /*--*/
244 
245 #endif
246