+ if rawget(config, name) and rawget(config[name].core, "component_module") then
+ error(format("Host %q clashes with previously defined %s Component %q, for services use a sub-domain like conference.%s",
+ name, config[name].core.component_module:gsub("^%a+$", { component = "external", muc = "MUC"}), name, name), 0);
+ end
+ rawset(env, "__currenthost", name);
+ -- Needs at least one setting to logically exist :)
+ set(name or "*", "core", "defined", true);
+ end
+ env.host = env.Host;
+
+ function env.Component(name)
+ if rawget(config, name) and rawget(config[name].core, "defined") and not rawget(config[name].core, "component_module") then
+ error(format("Component %q clashes with previously defined Host %q, for services use a sub-domain like conference.%s",
+ name, name, name), 0);
+ end
+ set(name, "core", "component_module", "component");
+ -- Don't load the global modules by default
+ set(name, "core", "load_global_modules", false);
+ rawset(env, "__currenthost", name);
+
+ return function (module)
+ if type(module) == "string" then
+ set(name, "core", "component_module", module);
+ end
+ end
+ end
+ env.component = env.Component;
+
+ function env.Include(file)
+ local f, err = io.open(file);
+ if f then
+ local data = f:read("*a");
+ local ok, err = parsers.lua.load(data, file);
+ if not ok then error(err:gsub("%[string.-%]", file), 0); end
+ end
+ if not f then error("Error loading included "..file..": "..err, 0); end
+ return f, err;