]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add unlang_compile_subsection
authorAlan T. DeKok <aland@freeradius.org>
Mon, 26 Jun 2017 14:39:31 +0000 (10:39 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 26 Jun 2017 14:45:11 +0000 (10:45 -0400)
needed by various proto_radius_foo processors

src/include/modules.h
src/main/unlang_compile.c

index 28e31cbc6b85d01febac2d4418e86a79e94fd2f4..91b1967a57925bca601a29c600c4106e9d3bf41d 100644 (file)
@@ -223,6 +223,7 @@ rlm_rcode_t unlang_interpret(REQUEST *request, CONF_SECTION *cs, rlm_rcode_t def
 rlm_rcode_t    unlang_interpret_synchronous(REQUEST *request, CONF_SECTION *cs, rlm_rcode_t action);
 
 int            unlang_compile(CONF_SECTION *cs, rlm_components_t component);
+int            unlang_compile_subsection(CONF_SECTION *server_cs, char const *name1, char const *name2, rlm_components_t component);
 
 /** A callback when the the timeout occurs
  *
index 830432c11229f125cef49ebd3e15cd5b009e39ed..0584c911ee9ee27665deea7aa4991ef8da93f8c7 100644 (file)
@@ -3043,3 +3043,32 @@ int unlang_compile(CONF_SECTION *cs, rlm_components_t component)
        dump_tree(c, c->debug_name);
        return 0;
 }
+
+/** Compile a named subsection
+ *
+ * @param server_cs the server CONF_SECTION
+ * @param name1 the first name of the subsection to compile
+ * @param name2 the second name of the subsection to compile.
+ * @param component the component to compile
+ * @return
+ *     - <0 on error
+ *     - 0 on section was not found
+ *     - 1 on successfully compiled
+ *
+ */
+int unlang_compile_subsection(CONF_SECTION *server_cs, char const *name1, char const *name2, rlm_components_t component)
+{
+       CONF_SECTION *cs;
+
+       cs = cf_section_find(server_cs, name1, name2);
+       if (!cs) return 0;
+
+       cf_log_debug(cs, "Compiling policies - %s %s {...}", name1, name2);
+
+       if (unlang_compile(cs, component) < 0) {
+               cf_log_err(cs, "Failed compiling '%s %s { ... }' section", name1, name2);
+               return -1;
+       }
+
+       return 1;
+}