//!< left as the default to is_set_offset
//!< or is_set_ptr.
#define FR_TYPE_OK_MISSING (1 << 22) //!< OK if it's missing
+#define FR_TYPE_ON_READ (1 << 23) //!< run the parse callback during the file read phase
#define FR_BASE_TYPE(_t) (0xff & (_t))
/* @} **/
rad_assert(cp);
rad_assert(!(type & FR_TYPE_ATTRIBUTE) || tmpl); /* Attribute flag only valid for templates */
+ rad_assert((type & FR_TYPE_ON_READ) == 0);
if (required) cant_be_empty = true; /* May want to review this in the future... */
rule = cf_data_value(rule_cd);
+ /*
+ * Ignore ON_READ parse rules
+ */
+ if ((rule->type & FR_TYPE_ON_READ) != 0) continue;
+
/*
* Pre-allocate the config structure to hold default values
*/
*/
if (!_cf_data_add_static(CF_TO_ITEM(cs), rule, "CONF_PARSER", rule->name, filename, lineno)) {
CONF_DATA const *cd;
- CONF_PARSER const *old;
+ CONF_PARSER *old;
cd = cf_data_find(CF_TO_ITEM(cs), CONF_PARSER, rule->name);
old = cf_data_value(cd);
return 0;
}
+ /*
+ * Remove any ON_READ callbacks, and add the new
+ * rule in its place.
+ */
+ if ((old->type & FR_TYPE_ON_READ) != 0) {
+ (void) cf_remove(CF_TO_ITEM(cs), CF_TO_ITEM(cd));
+ talloc_const_free(cd);
+
+ if (!_cf_data_add_static(CF_TO_ITEM(cs), rule, "CONF_PARSER", rule->name, filename, lineno)) {
+ cf_log_err(cs, "Failed adding rule '%s'", rule->name);
+ cf_debug(cs);
+ return -1;
+ }
+ return 0;
+ }
+
/*
* If we have a duplicate sub-section, just
* recurse and add the new sub-rules to the
* - The item removed.
* - NULL if the item wasn't set.
*/
-static CONF_ITEM *cf_remove(CONF_ITEM *parent, CONF_ITEM *child)
+CONF_ITEM *cf_remove(CONF_ITEM *parent, CONF_ITEM *child)
{
CONF_ITEM *found;
bool in_ident1, in_ident2;