From 0232747f04b650796db56fd7b487aee8a96fab03 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 14 Jan 2013 17:04:00 -0500 Subject: Add function get_next_domain() Use this function instead of explicitly calling domain->next This function allows to get the next primary domain or to descend into the subdomains and replaces also get_next_dom_or_subdom() --- src/util/domain_info_utils.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/util/domain_info_utils.c') diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c index 1ff7c0c6..8cba7dca 100644 --- a/src/util/domain_info_utils.c +++ b/src/util/domain_info_utils.c @@ -22,6 +22,24 @@ #include "db/sysdb.h" #include "util/util.h" +struct sss_domain_info *get_next_domain(struct sss_domain_info *domain, + bool descend) +{ + struct sss_domain_info *dom; + + dom = domain; + if (descend && dom->subdomain_count > 0) { + dom = dom->subdomains[0]; + } else if (dom->next) { + dom = dom->next; + } else if (descend && dom->parent) { + dom = dom->parent->next; + } else { + dom = NULL; + } + return dom; +} + struct sss_domain_info *new_subdomain(TALLOC_CTX *mem_ctx, struct sss_domain_info *parent, const char *name, -- cgit