9. Expansion operator escape8bit, like escape but not touching newline etc..
10. Feature macros, generated from compile options. All start with "_HAVE_"
- and go on with some roughly recognisable name. Use the "-bP macros"
+ and go on with some roughly recognisable name. Option macros, for each
+ configuration-file option; all start with "_OPT_". Use the "-bP macros"
command-line option to see what is present.
11. Integer values for options can take a "G" multiplier.
descriptive text. */
set_process_info("initializing");
+readconf_features();
+readconf_options();
os_restarting_signal(SIGUSR1, usr1_handler);
/* SIGHUP is used to get the daemon to reconfigure. It gets set as appropriate
extern BOOL readconf_depends(driver_instance *, uschar *);
extern void readconf_driver_init(uschar *, driver_instance **,
driver_info *, int, void *, int, optionlist *, int);
+extern void readconf_features(void);
+extern void readconf_options(void);
extern uschar *readconf_find_option(void *);
extern void readconf_main(BOOL);
-extern void readconf_print(uschar *, uschar *, BOOL no_labels);
+extern void readconf_options_from_list(optionlist *, unsigned, uschar *);
+extern void readconf_options_routers(void);
+extern void readconf_options_transports(void);
+extern void readconf_print(uschar *, uschar *, BOOL);
extern uschar *readconf_printtime(int);
extern uschar *readconf_readname(uschar *, int, uschar *);
extern int readconf_readtime(const uschar *, int, BOOL);
(void *)(offsetof(auth_instance, set_id)) }
};
-int optionlist_auths_size = sizeof(optionlist_auths)/sizeof(optionlist);
+int optionlist_auths_size = nelem(optionlist_auths);
/* An empty host aliases list. */
static void save_config_line(const uschar* line);
static void save_config_position(const uschar *file, int line);
static void print_config(BOOL admin, BOOL terse);
+static void readconf_options_auths(void);
#define CSTATE_STACK_SIZE 10
router_instance *r;
transport_instance *t;
-for (i = 0; i < optionlist_config_size; i++)
+for (i = 0; i < nelem(optionlist_config); i++)
if (p == optionlist_config[i].value) return US optionlist_config[i].name;
for (r = routers; r; r = r->next)
if (Ustrcmp(name, "all") == 0)
{
for (ol = optionlist_config;
- ol < optionlist_config + optionlist_config_size; ol++)
+ ol < optionlist_config + nelem(optionlist_config); ol++)
{
if ((ol->type & opt_hidden) == 0)
print_ol(ol, US ol->name, NULL,
- optionlist_config, optionlist_config_size,
+ optionlist_config, nelem(optionlist_config),
no_labels);
}
return;
else
{
- print_ol(find_option(name, optionlist_config, optionlist_config_size),
- name, NULL, optionlist_config, optionlist_config_size, no_labels);
+ print_ol(find_option(name, optionlist_config, nelem(optionlist_config)),
+ name, NULL, optionlist_config, nelem(optionlist_config), no_labels);
return;
}
}
/*************************************************/
/* Create compile-time feature macros */
-static void
+void
readconf_features(void)
{
/* Probably we could work out a static initialiser for wherever
}
+void
+readconf_options_from_list(optionlist * opts, unsigned nopt, uschar * group)
+{
+int i;
+const uschar * s;
+
+/* Walk the array backwards to get substring-conflict names */
+for (i = nopt-1; i >= 0; i--) if (*(s = opts[i].name) && *s != '*')
+ read_macro_assignment(string_sprintf("_OPT_%T_%T=y", group, s));
+}
+
+
+void
+readconf_options(void)
+{
+readconf_options_from_list(optionlist_config, nelem(optionlist_config), US"MAIN");
+readconf_options_routers();
+readconf_options_transports();
+readconf_options_auths();
+}
+
+
/*************************************************
* Read main configuration options *
*************************************************/
uschar *s, *filename;
const uschar *list = config_main_filelist;
-/* First create compile-time feature macros */
-readconf_features();
-
/* Loop through the possible file names */
while((filename = string_nextinlist(&list, &sep, big_buffer, big_buffer_size))
* Initialize authenticators *
*************************************************/
+static void
+readconf_options_auths(void)
+{
+struct auth_info * ai;
+
+readconf_options_from_list(optionlist_auths, optionlist_auths_size, US"AU");
+
+for (ai = auths_available; ai->driver_name[0]; ai++)
+ readconf_options_from_list(ai->options, (unsigned)*ai->options_count, ai->driver_name);
+}
+
+
/* Read the authenticators section of the configuration file.
Arguments: none
auths_init(void)
{
auth_instance *au, *bu;
+
readconf_driver_init(US"authenticator",
(driver_instance **)(&auths), /* chain anchor */
(driver_info *)auths_available, /* available drivers */
int optionlist_routers_size = sizeof(optionlist_routers)/sizeof(optionlist);
+void
+readconf_options_routers(void)
+{
+struct router_info * ri;
+
+readconf_options_from_list(optionlist_routers, nelem(optionlist_routers), US"RT");
+
+for (ri = routers_available; ri->driver_name[0]; ri++)
+ readconf_options_from_list(ri->options, (unsigned)*ri->options_count, ri->driver_name);
+}
/*************************************************
* Set router pointer from name *
as a va_list item.
The formats are the usual printf() ones, with some omissions (never used) and
-two additions for strings: %S forces lower case, and %#s or %#S prints nothing
-for a NULL string. Without the # "NULL" is printed (useful in debugging). There
-is also the addition of %D and %M, which insert the date in the form used for
-datestamped log files.
+three additions for strings: %S forces lower case, %T forces upper case, and
+%#s or %#S prints nothing for a NULL string. Without thr # "NULL" is printed
+(useful in debugging). There is also the addition of %D and %M, which insert
+the date in the form used for datestamped log files.
Arguments:
buffer a buffer in which to put the formatted string
case 's':
case 'S': /* Forces *lower* case */
+ case 'T': /* Forces *upper* case */
s = va_arg(ap, char *);
if (s == NULL) s = null;
sprintf(CS p, "%*.*s", width, precision, s);
if (fp[-1] == 'S')
while (*p) { *p = tolower(*p); p++; }
+ else if (fp[-1] == 'T')
+ while (*p) { *p = toupper(*p); p++; }
else
while (*p) p++;
if (!yield) goto END_FORMAT;
(void *)offsetof(transport_instance, uid) }
};
-int optionlist_transports_size =
- sizeof(optionlist_transports)/sizeof(optionlist);
+int optionlist_transports_size = nelem(optionlist_transports);
+void
+readconf_options_transports(void)
+{
+struct transport_info * ti;
+
+readconf_options_from_list(optionlist_transports, nelem(optionlist_transports), US"TP");
+
+for (ti = transports_available; ti->driver_name[0]; ti++)
+ readconf_options_from_list(ti->options, (unsigned)*ti->options_count, ti->driver_name);
+}
+
/*************************************************
* Initialize transport list *
*************************************************/