CONF_SECTION *cf_section_sub_find(const CONF_SECTION *, const char *name);
CONF_SECTION *cf_section_sub_find_name2(const CONF_SECTION *, const char *name1, const char *name2);
char *cf_section_value_find(const CONF_SECTION *, const char *attr);
+CONF_SECTION *cf_top_section(const CONF_SECTION *cs);
void *cf_data_find(CONF_SECTION *, const char *);
int cf_data_add(CONF_SECTION *, const char *, void *, void (*)(void *));
return NULL;
}
+
+CONF_SECTION *cf_top_section(const CONF_SECTION *cs)
+{
+ while (cs->item.parent != NULL) {
+ cs = cs->item.parent;
+ }
+
+ return cs;
+}
+
+
/*
* Expand the variables in an input string.
*/
* We can't use mainconfig.config, because we're in the
* process of re-building it, and it isn't set up yet...
*/
- for (parentcs = outercs;
- parentcs->item.parent != NULL;
- parentcs = parentcs->item.parent) {
- /* do nothing */
- }
+ parentcs = cf_top_section(outercs);
p = output;
ptr = input;
CONF_SECTION *parentcs;
t2 = getword(&ptr, buf2, sizeof(buf2));
- for (parentcs = current;
- parentcs->item.parent != NULL;
- parentcs = parentcs->item.parent) {
- /* do nothing */
- }
+ parentcs = cf_top_section(current);
ci = cf_reference_item(parentcs, this, buf2);
if (!ci || (ci->type != CONF_ITEM_SECTION)) {