struct settings_instance {
pool_t pool;
+ struct settings_root *root;
struct settings_mmap *mmap;
ARRAY_TYPE(settings_override) overrides;
};
unsigned int source_linenum,
const void **set_r, const char **error_r)
{
- struct settings_root *root = NULL;
+ struct settings_root *scan_root, *root = NULL;
struct settings_mmap *mmap = NULL;
- struct settings_instance *instance = NULL;
+ struct settings_instance *scan_instance, *instance = NULL;
struct event *lookup_event, *scan_event = event;
const char *str, *filter_name = NULL;
bool filter_name_required = FALSE;
}
do {
+ scan_root = event_get_ptr(scan_event, SETTINGS_EVENT_ROOT);
+ scan_instance = event_get_ptr(scan_event,
+ SETTINGS_EVENT_INSTANCE);
+
if (root == NULL)
- root = event_get_ptr(scan_event, SETTINGS_EVENT_ROOT);
- if (instance == NULL) {
- instance = event_get_ptr(scan_event,
- SETTINGS_EVENT_INSTANCE);
+ root = scan_root;
+ else if ((scan_root != NULL && root != scan_root) ||
+ (scan_instance != NULL && root != scan_instance->root)) {
+ /* settings root changed - ignore the rest of the
+ event hierarchy. */
+ break;
}
+ if (instance == NULL && scan_instance != NULL) {
+ instance = scan_instance;
+ root = instance->root;
+ }
+
str = event_get_ptr(scan_event, SETTINGS_EVENT_FILTER_NAME);
if (str != NULL) {
event_strlist_append(lookup_event,
settings_instance_new(struct settings_root *root)
{
struct settings_instance *instance = settings_instance_alloc();
+ instance->root = root;
instance->mmap = root->mmap;
return instance;
}
settings_instance_dup(const struct settings_instance *src)
{
struct settings_instance *dest = settings_instance_alloc();
+ dest->root = src->root;
dest->mmap = src->mmap;
if (!array_is_created(&src->overrides))
#define SETTINGS_EVENT_INSTANCE "settings_instance"
/* Used by settings_get() to find struct settings_root via the event.
- This is set automatically by lib-master for all created root events. */
+ This is set automatically by lib-master for all created root events.
+
+ If a new root is created in the event hierarchy (or an instance with a new
+ root is used), only the settings under the new root are used. This allows
+ specifying the exact wanted settings in the code, and they can't be changed
+ with config file or command line options. */
#define SETTINGS_EVENT_ROOT "settings_root"
/* Used by settings_get() to access the named filter. This is copied to the