]> rtime.felk.cvut.cz Git - ulut.git/commitdiff
Added ul_logreg_for_each_domain()
authorwentasah <wentasah>
Mon, 10 Aug 2009 12:06:01 +0000 (12:06 +0000)
committerwentasah <wentasah>
Mon, 10 Aug 2009 12:06:01 +0000 (12:06 +0000)
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
ulut/ul_logreg.h

index fc721c9714f908f890e98045ab58f1387b0653a8..6f63d95eb8586ed0f69beba222690b4d4ae9064d 100644 (file)
@@ -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;
+    }
+  }
+}
index 52d3149530ab1fe24421a984f58ca0590d3ea498..0aaa260bcf73271640629369b4c4105f7ba6193d 100644 (file)
@@ -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