From 950f439dd9a3b06cd79df68c486b4b1a93758a67 Mon Sep 17 00:00:00 2001 From: wentasah Date: Mon, 10 Aug 2009 12:06:01 +0000 Subject: [PATCH] Added ul_logreg_for_each_domain() This functions walks through the list of all registered log domains and calls a callback on it. It can be used to print the list of domains for a user. --- ulut/ul_logreg.c | 15 +++++++++++++++ ulut/ul_logreg.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/ulut/ul_logreg.c b/ulut/ul_logreg.c index fc721c9..6f63d95 100644 --- a/ulut/ul_logreg.c +++ b/ulut/ul_logreg.c @@ -193,3 +193,18 @@ int ul_logreg_domains_static(ul_log_domain_t *const *domains, int count) } return 0; } + +void ul_logreg_for_each_domain(ul_logreg_domain_cb_t *callback, void *context) +{ + ul_log_domains_it_t it; + ul_log_domain_t *domain; + ul_for_each_it(ul_log_domains, &ul_log_domains, it) { + domain=ul_log_domains_it2item(&it); + if (callback) { + int ret; + ret = callback(domain, context); + if (ret) + break; + } + } +} diff --git a/ulut/ul_logreg.h b/ulut/ul_logreg.h index 52d3149..0aaa260 100644 --- a/ulut/ul_logreg.h +++ b/ulut/ul_logreg.h @@ -69,6 +69,9 @@ int function_name(void) \ static void function_name##_on_init(void) UL_ATTR_CONSTRUCTOR; \ static void function_name##_on_init(void) { function_name(); } +typedef int (ul_logreg_domain_cb_t)(ul_log_domain_t *domain, void *context); +void ul_logreg_for_each_domain(ul_logreg_domain_cb_t *callback, void *context); + #ifdef __cplusplus } /* extern "C"*/ #endif -- 2.39.2