From 1987bff88e01c74d647dd2db4f541ac311537e1a Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 10 May 2013 18:19:12 +0200 Subject: Add utility functions for formatting fully-qualified names Instead of using printf-like functions directly, provide two wrappers that would encapsulate formatting the fully-qualified names. No functional change is present in this patch. --- src/util/usertools.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/util/usertools.c') diff --git a/src/util/usertools.c b/src/util/usertools.c index 91110f263..20ca407f3 100644 --- a/src/util/usertools.c +++ b/src/util/usertools.c @@ -507,3 +507,28 @@ sss_get_cased_name_list(TALLOC_CTX *mem_ctx, const char * const *orig, *_cased = out; return EOK; } + +static inline const char * +safe_fq_str(struct sss_names_ctx *nctx, uint8_t part, const char *str) +{ + + return nctx->fq_flags & part ? str : ""; +} + +char * +sss_tc_fqname(TALLOC_CTX *mem_ctx, struct sss_names_ctx *nctx, + struct sss_domain_info *domain, const char *name) +{ + if (domain == NULL || nctx == NULL) return NULL; + + return talloc_asprintf(mem_ctx, nctx->fq_fmt, name, domain->name); +} + +int +sss_fqname(char *str, size_t size, struct sss_names_ctx *nctx, + struct sss_domain_info *domain, const char *name) +{ + if (domain == NULL || nctx == NULL) return -EINVAL; + + return snprintf(str, size, nctx->fq_fmt, name, domain->name); +} -- cgit