Home | History | Annotate | Line # | Download | only in global
      1 /*	$NetBSD: mail_conf.h,v 1.4 2026/05/09 18:49:16 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 extern void mail_conf_checkdir(const char *);
     42 
     43 extern void mail_conf_update(const char *, const char *);
     44 extern const char *mail_conf_lookup(const char *);
     45 extern const char *mail_conf_eval(const char *);
     46 extern const char *mail_conf_eval_once(const char *);
     47 extern const char *mail_conf_lookup_eval(const char *);
     48 
     49  /*
     50   * Specific parameter lookup routines.
     51   */
     52 extern char *get_mail_conf_str(const char *, const char *, int, int);
     53 extern int get_mail_conf_int(const char *, int, int, int);
     54 extern long get_mail_conf_long(const char *, long, long, long);
     55 extern int get_mail_conf_bool(const char *, int);
     56 extern int get_mail_conf_time(const char *, const char *, int, int);
     57 extern int get_mail_conf_nint(const char *, const char *, int, int);
     58 extern char *get_mail_conf_raw(const char *, const char *, int, int);
     59 extern int get_mail_conf_nbool(const char *, const char *);
     60 
     61 extern char *get_mail_conf_str2(const char *, const char *, const char *, int, int);
     62 extern int get_mail_conf_int2(const char *, const char *, int, int, int);
     63 extern long get_mail_conf_long2(const char *, const char *, long, long, long);
     64 extern int get_mail_conf_time2(const char *, const char *, int, int, int, int);
     65 extern int get_mail_conf_nint2(const char *, const char *, int, int, int);
     66 extern void check_mail_conf_str(const char *, const char *, int, int);
     67 extern void check_mail_conf_time(const char *, int, int, int);
     68 extern void check_mail_conf_int(const char *, int, int, int);
     69 
     70  /*
     71   * Lookup with function-call defaults.
     72   */
     73 extern char *get_mail_conf_str_fn(const char *, const char *(*) (void), int, int);
     74 extern int get_mail_conf_int_fn(const char *, int (*) (void), int, int);
     75 extern long get_mail_conf_long_fn(const char *, long (*) (void), long, long);
     76 extern int get_mail_conf_bool_fn(const char *, int (*) (void));
     77 extern int get_mail_conf_time_fn(const char *, const char *(*) (void), int, int, int);
     78 extern int get_mail_conf_nint_fn(const char *, const char *(*) (void), int, int);
     79 extern char *get_mail_conf_raw_fn(const char *, const char *(*) (void), int, int);
     80 extern int get_mail_conf_nbool_fn(const char *, const char *(*) (void));
     81 
     82  /*
     83   * Update dictionary.
     84   */
     85 extern void set_mail_conf_str(const char *, const char *);
     86 extern void set_mail_conf_int(const char *, int);
     87 extern void set_mail_conf_long(const char *, long);
     88 extern void set_mail_conf_bool(const char *, int);
     89 extern void set_mail_conf_time(const char *, const char *);
     90 extern void set_mail_conf_time_int(const char *, int);
     91 extern void set_mail_conf_nint(const char *, const char *);
     92 extern void set_mail_conf_nint_int(const char *, int);
     93 extern void set_mail_conf_nbool(const char *, const char *);
     94 
     95 #define set_mail_conf_nbool_int(name, value) \
     96     set_mail_conf_nbool((name), (value) ? CONFIG_BOOL_YES : CONFIG_BOOL_NO)
     97 
     98  /*
     99   * Tables that allow us to selectively copy values from the global
    100   * configuration file to global variables.
    101   */
    102 typedef struct {
    103     const char *name;			/* config variable name */
    104     const char *defval;			/* default value or null */
    105     char  **target;			/* pointer to global variable */
    106     int     min;			/* min length or zero */
    107     int     max;			/* max length or zero */
    108 } CONFIG_STR_TABLE;
    109 
    110 typedef struct {
    111     const char *name;			/* config variable name */
    112     const char *defval;			/* default value or null */
    113     char  **target;			/* pointer to global variable */
    114     int     min;			/* min length or zero */
    115     int     max;			/* max length or zero */
    116 } CONFIG_RAW_TABLE;
    117 
    118 typedef struct {
    119     const char *name;			/* config variable name */
    120     int     defval;			/* default value */
    121     int    *target;			/* pointer to global variable */
    122     int     min;			/* lower bound or zero */
    123     int     max;			/* upper bound or zero */
    124 } CONFIG_INT_TABLE;
    125 
    126 typedef struct {
    127     const char *name;			/* config variable name */
    128     long    defval;			/* default value */
    129     long   *target;			/* pointer to global variable */
    130     long    min;			/* lower bound or zero */
    131     long    max;			/* upper bound or zero */
    132 } CONFIG_LONG_TABLE;
    133 
    134 typedef struct {
    135     const char *name;			/* config variable name */
    136     bool    defval;			/* default value */
    137     bool   *target;			/* pointer to global variable */
    138 } CONFIG_BOOL_TABLE;
    139 
    140 typedef struct {
    141     const char *name;			/* config variable name */
    142     const char *defval;			/* default value + default unit */
    143     int    *target;			/* pointer to global variable */
    144     int     min;			/* lower bound or zero */
    145     int     max;			/* upper bound or zero */
    146 } CONFIG_TIME_TABLE;
    147 
    148 typedef struct {
    149     const char *name;			/* config variable name */
    150     const char *defval;			/* default value + default unit */
    151     int    *target;			/* pointer to global variable */
    152     int     min;			/* lower bound or zero */
    153     int     max;			/* upper bound or zero */
    154 } CONFIG_NINT_TABLE;
    155 
    156 typedef struct {
    157     const char *name;			/* config variable name */
    158     const char *defval;			/* default value */
    159     bool   *target;			/* pointer to global variable */
    160 } CONFIG_NBOOL_TABLE;
    161 
    162 extern void get_mail_conf_str_table(const CONFIG_STR_TABLE *);
    163 extern void get_mail_conf_int_table(const CONFIG_INT_TABLE *);
    164 extern void get_mail_conf_long_table(const CONFIG_LONG_TABLE *);
    165 extern void get_mail_conf_bool_table(const CONFIG_BOOL_TABLE *);
    166 extern void get_mail_conf_time_table(const CONFIG_TIME_TABLE *);
    167 extern void get_mail_conf_nint_table(const CONFIG_NINT_TABLE *);
    168 extern void get_mail_conf_raw_table(const CONFIG_RAW_TABLE *);
    169 extern void get_mail_conf_nbool_table(const CONFIG_NBOOL_TABLE *);
    170 
    171  /*
    172   * Tables to initialize parameters from the global configuration file or
    173   * from function calls.
    174   */
    175 typedef struct {
    176     const char *name;			/* config variable name */
    177     const char *(*defval) (void);	/* default value provider */
    178     char  **target;			/* pointer to global variable */
    179     int     min;			/* lower bound or zero */
    180     int     max;			/* upper bound or zero */
    181 } CONFIG_STR_FN_TABLE;
    182 
    183 typedef struct {
    184     const char *name;			/* config variable name */
    185     const char *(*defval) (void);	/* default value provider */
    186     char  **target;			/* pointer to global variable */
    187     int     min;			/* lower bound or zero */
    188     int     max;			/* upper bound or zero */
    189 } CONFIG_RAW_FN_TABLE;
    190 
    191 typedef struct {
    192     const char *name;			/* config variable name */
    193     int     (*defval) (void);		/* default value provider */
    194     int    *target;			/* pointer to global variable */
    195     int     min;			/* lower bound or zero */
    196     int     max;			/* upper bound or zero */
    197 } CONFIG_INT_FN_TABLE;
    198 
    199 typedef struct {
    200     const char *name;			/* config variable name */
    201     long    (*defval) (void);		/* default value provider */
    202     long   *target;			/* pointer to global variable */
    203     long    min;			/* lower bound or zero */
    204     long    max;			/* upper bound or zero */
    205 } CONFIG_LONG_FN_TABLE;
    206 
    207 typedef struct {
    208     const char *name;			/* config variable name */
    209     int     (*defval) (void);		/* default value provider */
    210     int    *target;			/* pointer to global variable */
    211 } CONFIG_BOOL_FN_TABLE;
    212 
    213 typedef struct {
    214     const char *name;			/* config variable name */
    215     const char *(*defval) (void);	/* default value provider */
    216     int    *target;			/* pointer to global variable */
    217     int     min;			/* lower bound or zero */
    218     int     max;			/* upper bound or zero */
    219 } CONFIG_NINT_FN_TABLE;
    220 
    221 typedef struct {
    222     const char *name;			/* config variable name */
    223     const char *(*defval) (void);	/* default value provider */
    224     int    *target;			/* pointer to global variable */
    225 } CONFIG_NBOOL_FN_TABLE;
    226 
    227 extern void get_mail_conf_str_fn_table(const CONFIG_STR_FN_TABLE *);
    228 extern void get_mail_conf_int_fn_table(const CONFIG_INT_FN_TABLE *);
    229 extern void get_mail_conf_long_fn_table(const CONFIG_LONG_FN_TABLE *);
    230 extern void get_mail_conf_bool_fn_table(const CONFIG_BOOL_FN_TABLE *);
    231 extern void get_mail_conf_raw_fn_table(const CONFIG_RAW_FN_TABLE *);
    232 extern void get_mail_conf_nint_fn_table(const CONFIG_NINT_FN_TABLE *);
    233 extern void get_mail_conf_nbool_fn_table(const CONFIG_NBOOL_FN_TABLE *);
    234 
    235 /* LICENSE
    236 /* .ad
    237 /* .fi
    238 /*	The Secure Mailer license must be distributed with this software.
    239 /* AUTHOR(S)
    240 /*	Wietse Venema
    241 /*	IBM T.J. Watson Research
    242 /*	P.O. Box 704
    243 /*	Yorktown Heights, NY 10598, USA
    244 /*
    245 /*	Wietse Venema
    246 /*	Google, Inc.
    247 /*	111 8th Avenue
    248 /*	New York, NY 10011, USA
    249 /*--*/
    250 
    251 #endif
    252