mirror of
https://github.com/SELinuxProject/selinux
synced 2025-01-20 12:30:45 +00:00
libsepol/cil: Add function to determine if a subtree has a declaration
Create the function cil_tree_subtree_has_decl() that returns CIL_TRUE if the subtree has a declaration in it and CIL_FALSE otherwise. Signed-off-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
37863b0b14
commit
20271849d5
@ -136,6 +136,22 @@ __attribute__((format (printf, 3, 4))) void cil_tree_log(struct cil_tree_node *n
|
||||
cil_log(lvl,"\n");
|
||||
}
|
||||
|
||||
int cil_tree_subtree_has_decl(struct cil_tree_node *node)
|
||||
{
|
||||
while (node) {
|
||||
if (node->flavor >= CIL_MIN_DECLARATIVE) {
|
||||
return CIL_TRUE;
|
||||
}
|
||||
if (node->cl_head != NULL) {
|
||||
if (cil_tree_subtree_has_decl(node->cl_head))
|
||||
return CIL_TRUE;
|
||||
}
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
return CIL_FALSE;
|
||||
}
|
||||
|
||||
int cil_tree_init(struct cil_tree **tree)
|
||||
{
|
||||
struct cil_tree *new_tree = cil_malloc(sizeof(*new_tree));
|
||||
|
@ -54,6 +54,8 @@ struct cil_tree_node *cil_tree_get_next_path(struct cil_tree_node *node, char **
|
||||
char *cil_tree_get_cil_path(struct cil_tree_node *node);
|
||||
__attribute__((format (printf, 3, 4))) void cil_tree_log(struct cil_tree_node *node, enum cil_log_level lvl, const char* msg, ...);
|
||||
|
||||
int cil_tree_subtree_has_decl(struct cil_tree_node *node);
|
||||
|
||||
int cil_tree_init(struct cil_tree **tree);
|
||||
void cil_tree_destroy(struct cil_tree **tree);
|
||||
void cil_tree_subtree_destroy(struct cil_tree_node *node);
|
||||
|
Loading…
Reference in New Issue
Block a user