Add a function to search for a counter by name
authorDaniel Willmann <daniel@totalueberwachung.de>
Fri, 8 Apr 2011 08:46:19 +0000 (10:46 +0200)
committerHolger Hans Peter Freyther <zecke@selfish.org>
Sat, 9 Apr 2011 18:52:18 +0000 (20:52 +0200)
include/osmocom/core/statistics.h
src/statistics.c

index 1d56054..2c15965 100644 (file)
@@ -28,4 +28,6 @@ void counter_free(struct counter *ctr);
 
 int counters_for_each(int (*handle_counter)(struct counter *, void *), void *data);
 
+struct counter *counter_get_by_name(const char *name);
+
 #endif /* _STATISTICS_H */
index 183005d..d1ffe52 100644 (file)
@@ -64,3 +64,13 @@ int counters_for_each(int (*handle_counter)(struct counter *, void *), void *dat
        return rc;
 }
 
+struct counter *counter_get_by_name(const char *name)
+{
+       struct counter *ctr;
+
+       llist_for_each_entry(ctr, &counters, list) {
+               if (!strcmp(ctr->name, name))
+                       return ctr;
+       }
+       return NULL;
+}