Finishing off the previous commit.
typedef struct {
char const *name1;
char const *name2;
+ rlm_components_t component;
} module_section_name_t;
* This function is called from the virtual server bootstrap routine,
* which happens before module_bootstrap();
*/
-int module_section_register(char const *name1, char const *name2)
+int module_section_register(char const *name1, char const *name2, rlm_components_t component)
{
module_section_name_t *sname;
sname->name1 = name1;
sname->name2 = name2;
+ sname->component = component;
if (!rbtree_insert(module_section_name_tree, sname)) {
talloc_free(sname);
}
-/** See if a named section exists
+/** Find the component for a section
*
*/
-bool module_section_exists(char const *name1, char const *name2)
+int module_section_component(rlm_components_t *component, char const *name1, char const *name2)
{
module_section_name_t *sname;
if (name2 != CF_IDENT_ANY) {
sname = rbtree_finddata(module_section_name_tree,
&(module_section_name_t) {
- .name1 = name2,
- .name2 = CF_IDENT_ANY,
- });
- if (sname) return true;
+ .name1 = name1,
+ .name2 = CF_IDENT_ANY,
+ });
+ if (sname) goto done;
}
/*
.name1 = name1,
.name2 = name2,
});
- return (sname != NULL);
+ if (!sname) return -1;
+
+done:
+ *component = sname->component;
+
+ return 0;
}
int module_instance_read_only(TALLOC_CTX *ctx, char const *name);
-int module_section_register(char const *name1, char const *name2);
+int module_section_register(char const *name1, char const *name2, rlm_components_t component);
-bool module_section_exists(char const *name1, char const *name2);
+int module_section_component(rlm_components_t *component, char const *name1, char const *name2);
/** @{ */
for (j = 0; list[j].name != NULL; j++) {
if (list[j].name == CF_IDENT_ANY) continue;
- if (module_section_register(list[j].name, list[j].name2) < 0) {
+ if (module_section_register(list[j].name, list[j].name2, list[j].component) < 0) {
cf_log_err(conf, "Failed registering section name for %s",
app_process->name);
return -1;
/*
* Allow for named subsections, to change processing method types.
*/
- if (name2 && module_section_exists(modrefname, name2)) {
- /*
- * @todo - change the parse rules?
- */
- cf_log_err(ci, "Placeholder not implemented");
- return NULL;
+ if (name2 && (module_section_component(&component, modrefname, name2) == 0)) {
+ UPDATE_CTX2;
+
+ c = compile_group(parent, &unlang_ctx2, cs, UNLANG_GROUP_TYPE_SIMPLE, parent_group_type, UNLANG_TYPE_GROUP);
+ if (!c) return NULL;
+
+ c->name = modrefname;
+ c->debug_name = talloc_typed_asprintf(c, "%s %s", modrefname, name2);
+ return c;
}
#ifdef WITH_UNLANG