return fr_dlist_next(&ci->children, prev);
}
+static void cf_item_init(CONF_ITEM *ci, CONF_ITEM_TYPE type, CONF_ITEM *parent, char const *filename, int lineno)
+{
+ ci->type = type;
+ ci->parent = parent;
+
+ fr_dlist_init(&ci->children, CONF_ITEM, entry);
+
+ if (filename) cf_filename_set(ci, filename);
+ if (lineno) cf_lineno_set(ci, lineno);
+}
+
/** Return the top level #CONF_SECTION holding all other #CONF_ITEM
*
* @param[in] ci to traverse up from.
cs = talloc_zero(ctx, CONF_SECTION);
if (!cs) return NULL;
- cs->item.type = CONF_ITEM_SECTION;
- cs->item.parent = cf_section_to_item(parent);
- fr_dlist_init(&cs->item.children, CONF_ITEM, entry);
- if (filename) cf_filename_set(cs, filename);
- if (lineno) cf_lineno_set(cs, lineno);
+ cf_item_init(cf_section_to_item(cs), CONF_ITEM_SECTION, cf_section_to_item(parent), filename, lineno);
MEM(cs->name1 = talloc_typed_strdup(cs, name1));
if (name2) {
cp = talloc_zero(parent, CONF_PAIR);
if (!cp) return NULL;
- cp->item.type = CONF_ITEM_PAIR;
- cp->item.parent = cf_section_to_item(parent);
+ cf_item_init(cf_pair_to_item(cp), CONF_ITEM_PAIR, cf_section_to_item(parent), NULL, 0);
+
cp->lhs_quote = lhs_quote;
cp->rhs_quote = rhs_quote;
cp->op = op;
- cf_filename_set(cp, ""); /* will be over-written if necessary */
- fr_dlist_init(&cp->item.children, CONF_ITEM, entry);
cp->attr = talloc_typed_strdup(cp, attr);
if (!cp->attr) {
cd = talloc_zero(parent, CONF_DATA);
if (!cd) return NULL;
- cd->item.type = CONF_ITEM_DATA;
- cd->item.parent = parent;
- fr_dlist_init(&cd->item.children, CONF_ITEM, entry);
+ cf_item_init(cf_data_to_item(cd), CONF_ITEM_DATA, parent, NULL, 0);
/*
* strdup so if the data is freed, we can