1 /* $NetBSD: mail_conf.h,v 1.1.1.2 2011/03/02 19:32:15 tron 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 66 /* 67 * Lookup with function-call defaults. 68 */ 69 extern char *get_mail_conf_str_fn(const char *, const char *(*) (void), int, int); 70 extern int get_mail_conf_int_fn(const char *, int (*) (void), int, int); 71 extern long get_mail_conf_long_fn(const char *, long (*) (void), long, long); 72 extern int get_mail_conf_bool_fn(const char *, int (*) (void)); 73 extern int get_mail_conf_time_fn(const char *, const char *(*) (void), int, int, int); 74 extern int get_mail_conf_nint_fn(const char *, const char *(*) (void), int, int); 75 extern char *get_mail_conf_raw_fn(const char *, const char *(*) (void), int, int); 76 extern int get_mail_conf_nbool_fn(const char *, const char *(*) (void)); 77 78 /* 79 * Update dictionary. 80 */ 81 extern void set_mail_conf_str(const char *, const char *); 82 extern void set_mail_conf_int(const char *, int); 83 extern void set_mail_conf_long(const char *, long); 84 extern void set_mail_conf_bool(const char *, int); 85 extern void set_mail_conf_time(const char *, const char *); 86 extern void set_mail_conf_time_int(const char *, int); 87 extern void set_mail_conf_nint(const char *, const char *); 88 extern void set_mail_conf_nint_int(const char *, int); 89 extern void set_mail_conf_nbool(const char *, const char *); 90 91 #define set_mail_conf_nbool_int(name, value) \ 92 set_mail_conf_nbool((name), (value) ? CONFIG_BOOL_YES : CONFIG_BOOL_NO) 93 94 /* 95 * Tables that allow us to selectively copy values from the global 96 * configuration file to global variables. 97 */ 98 typedef struct { 99 const char *name; /* config variable name */ 100 const char *defval; /* default value or null */ 101 char **target; /* pointer to global variable */ 102 int min; /* min length or zero */ 103 int max; /* max length or zero */ 104 } CONFIG_STR_TABLE; 105 106 typedef struct { 107 const char *name; /* config variable name */ 108 const char *defval; /* default value or null */ 109 char **target; /* pointer to global variable */ 110 int min; /* min length or zero */ 111 int max; /* max length or zero */ 112 } CONFIG_RAW_TABLE; 113 114 typedef struct { 115 const char *name; /* config variable name */ 116 int defval; /* default value */ 117 int *target; /* pointer to global variable */ 118 int min; /* lower bound or zero */ 119 int max; /* upper bound or zero */ 120 } CONFIG_INT_TABLE; 121 122 typedef struct { 123 const char *name; /* config variable name */ 124 long defval; /* default value */ 125 long *target; /* pointer to global variable */ 126 long min; /* lower bound or zero */ 127 long max; /* upper bound or zero */ 128 } CONFIG_LONG_TABLE; 129 130 typedef struct { 131 const char *name; /* config variable name */ 132 int defval; /* default value */ 133 int *target; /* pointer to global variable */ 134 } CONFIG_BOOL_TABLE; 135 136 typedef struct { 137 const char *name; /* config variable name */ 138 const char *defval; /* default value + default unit */ 139 int *target; /* pointer to global variable */ 140 int min; /* lower bound or zero */ 141 int max; /* upper bound or zero */ 142 } CONFIG_TIME_TABLE; 143 144 typedef struct { 145 const char *name; /* config variable name */ 146 const char *defval; /* default value + default unit */ 147 int *target; /* pointer to global variable */ 148 int min; /* lower bound or zero */ 149 int max; /* upper bound or zero */ 150 } CONFIG_NINT_TABLE; 151 152 typedef struct { 153 const char *name; /* config variable name */ 154 const char *defval; /* default value */ 155 int *target; /* pointer to global variable */ 156 } CONFIG_NBOOL_TABLE; 157 158 extern void get_mail_conf_str_table(const CONFIG_STR_TABLE *); 159 extern void get_mail_conf_int_table(const CONFIG_INT_TABLE *); 160 extern void get_mail_conf_long_table(const CONFIG_LONG_TABLE *); 161 extern void get_mail_conf_bool_table(const CONFIG_BOOL_TABLE *); 162 extern void get_mail_conf_time_table(const CONFIG_TIME_TABLE *); 163 extern void get_mail_conf_nint_table(const CONFIG_NINT_TABLE *); 164 extern void get_mail_conf_raw_table(const CONFIG_RAW_TABLE *); 165 extern void get_mail_conf_nbool_table(const CONFIG_NBOOL_TABLE *); 166 167 /* 168 * Tables to initialize parameters from the global configuration file or 169 * from function calls. 170 */ 171 typedef struct { 172 const char *name; /* config variable name */ 173 const char *(*defval) (void); /* default value provider */ 174 char **target; /* pointer to global variable */ 175 int min; /* lower bound or zero */ 176 int max; /* upper bound or zero */ 177 } CONFIG_STR_FN_TABLE; 178 179 typedef struct { 180 const char *name; /* config variable name */ 181 const char *(*defval) (void); /* default value provider */ 182 char **target; /* pointer to global variable */ 183 int min; /* lower bound or zero */ 184 int max; /* upper bound or zero */ 185 } CONFIG_RAW_FN_TABLE; 186 187 typedef struct { 188 const char *name; /* config variable name */ 189 int (*defval) (void); /* default value provider */ 190 int *target; /* pointer to global variable */ 191 int min; /* lower bound or zero */ 192 int max; /* upper bound or zero */ 193 } CONFIG_INT_FN_TABLE; 194 195 typedef struct { 196 const char *name; /* config variable name */ 197 long (*defval) (void); /* default value provider */ 198 long *target; /* pointer to global variable */ 199 long min; /* lower bound or zero */ 200 long max; /* upper bound or zero */ 201 } CONFIG_LONG_FN_TABLE; 202 203 typedef struct { 204 const char *name; /* config variable name */ 205 int (*defval) (void); /* default value provider */ 206 int *target; /* pointer to global variable */ 207 } CONFIG_BOOL_FN_TABLE; 208 209 typedef struct { 210 const char *name; /* config variable name */ 211 const char *(*defval) (void); /* default value provider */ 212 int *target; /* pointer to global variable */ 213 int min; /* lower bound or zero */ 214 int max; /* upper bound or zero */ 215 } CONFIG_NINT_FN_TABLE; 216 217 typedef struct { 218 const char *name; /* config variable name */ 219 const char *(*defval) (void); /* default value provider */ 220 int *target; /* pointer to global variable */ 221 } CONFIG_NBOOL_FN_TABLE; 222 223 extern void get_mail_conf_str_fn_table(const CONFIG_STR_FN_TABLE *); 224 extern void get_mail_conf_int_fn_table(const CONFIG_INT_FN_TABLE *); 225 extern void get_mail_conf_long_fn_table(const CONFIG_LONG_FN_TABLE *); 226 extern void get_mail_conf_bool_fn_table(const CONFIG_BOOL_FN_TABLE *); 227 extern void get_mail_conf_raw_fn_table(const CONFIG_RAW_FN_TABLE *); 228 extern void get_mail_conf_nint_fn_table(const CONFIG_NINT_FN_TABLE *); 229 extern void get_mail_conf_nbool_fn_table(const CONFIG_NBOOL_FN_TABLE *); 230 231 /* LICENSE 232 /* .ad 233 /* .fi 234 /* The Secure Mailer license must be distributed with this software. 235 /* AUTHOR(S) 236 /* Wietse Venema 237 /* IBM T.J. Watson Research 238 /* P.O. Box 704 239 /* Yorktown Heights, NY 10598, USA 240 /*--*/ 241 242 #endif 243