Index: src/conf.c =================================================================== --- src/conf.c (revision 3582) +++ src/conf.c (revision 3583) @@ -45,7 +45,7 @@ int conf_lht_dirty[CFR_max_alloc]; htsp_t *conf_fields = NULL; -static const int conf_default_prio[] = { +const int conf_default_prio[] = { /* CFR_INTERNAL */ 100, /* CFR_SYSTEM */ 200, /* CFR_DEFAULTPCB */ 300, @@ -53,7 +53,8 @@ /* CFR_ENV */ 500, /* CFR_PROJECT */ 600, /* CFR_DESIGN */ 700, -/* CFR_CLI */ 800 +/* CFR_CLI */ 800, +0, 0, 0, 0, 0, 0, 0, 0, 0 /* make sure the array is addressable until CFR_max_alloc */ }; extern const char *conf_internal; @@ -172,7 +173,7 @@ } -void extract_poliprio(lht_node_t *root, conf_policy_t *gpolicy, long *gprio) +void conf_extract_poliprio(lht_node_t *root, conf_policy_t *gpolicy, long *gprio) { long len = strlen(root->name), p = -1; char tmp[128]; @@ -212,6 +213,18 @@ } +int conf_get_policy_prio(lht_node_t *node, conf_policy_t *gpolicy, long *gprio) +{ + for(;;node = node->parent) { + if (node->parent == node->doc->root) { + conf_extract_poliprio(node, gpolicy, gprio); + return 0; + } + if (node->parent == NULL) + return -1; + } +} + static int conf_parse_increments(Increments *inc, lht_node_t *node) { lht_node_t *val; @@ -597,7 +610,7 @@ return -1; } - extract_poliprio(root, &gpolicy, &gprio); + conf_extract_poliprio(root, &gpolicy, &gprio); /* iterate over all hashes and insert them recursively */ for(n = lht_dom_first(&it, root); n != NULL; n = lht_dom_next(&it)) @@ -634,7 +647,7 @@ m = vmst_alloc_append(&merge_subtree, 1); m->prio = conf_default_prio[role]; - extract_poliprio(subtree_parent_root, &m->policy, &m->prio); + conf_extract_poliprio(subtree_parent_root, &m->policy, &m->prio); m->subtree = subtree_root; } Index: src/conf.h =================================================================== --- src/conf.h (revision 3582) +++ src/conf.h (revision 3583) @@ -141,6 +141,8 @@ CFR_invalid } conf_role_t; +extern const int conf_default_prio[]; + void conf_init(void); void conf_uninit(void); @@ -333,4 +335,9 @@ /* Write an existing conf subtree to a file */ int conf_export_to_file(const char *fn, conf_role_t role, const char *conf_path); +/* Determine the policy and priority of a config lihata node; + returns 0 on success but may not fill in both values, caller is + responsible for initializing them before the call. */ +int conf_get_policy_prio(lht_node_t *node, conf_policy_t *gpolicy, long *gprio); + #endif