From cf1a8af5556b1d8eab68802918c881ae1a0b89eb Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Sep 26 2013 19:11:51 +0000 Subject: util: add get_domains_head() This function will return head of the domain list. Resolves: https://fedorahosted.org/sssd/ticket/2066 --- diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c index 7b1eb1a..7ac4d9d 100644 --- a/src/util/domain_info_utils.c +++ b/src/util/domain_info_utils.c @@ -27,6 +27,19 @@ /* the directory domain - realm mappings are written to */ #define KRB5_MAPPING_DIR PUBCONF_PATH"/krb5.include.d" +struct sss_domain_info *get_domains_head(struct sss_domain_info *domain) +{ + struct sss_domain_info *dom = NULL; + + /* get to the top level domain */ + for (dom = domain; dom->parent != NULL; dom = dom->parent); + + /* proceed to the list head */ + for (; dom->prev != NULL; dom = dom->prev); + + return dom; +} + struct sss_domain_info *get_next_domain(struct sss_domain_info *domain, bool descend) { diff --git a/src/util/util.h b/src/util/util.h index 20d230c..6cd59d9 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -543,6 +543,8 @@ struct sized_string { void to_sized_string(struct sized_string *out, const char *in); /* from domain_info.c */ +struct sss_domain_info *get_domains_head(struct sss_domain_info *domain); + struct sss_domain_info *get_next_domain(struct sss_domain_info *domain, bool descend); struct sss_domain_info *find_subdomain_by_name(struct sss_domain_info *domain,