aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc/src/debug.c')
-rw-r--r--openbsc/src/debug.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/openbsc/src/debug.c b/openbsc/src/debug.c
index bc9230a93..dc270d86e 100644
--- a/openbsc/src/debug.c
+++ b/openbsc/src/debug.c
@@ -56,6 +56,32 @@ static struct debug_category default_categories[Debug_LastEntry] = {
[DREF] = { .enabled = 0, .loglevel = LOGL_NOTICE },
};
+const char *get_value_string(const struct value_string *vs, u_int32_t val)
+{
+ int i;
+
+ for (i = 0;; i++) {
+ if (vs[i].value == 0 && vs[i].str == NULL)
+ break;
+ if (vs[i].value == val)
+ return vs[i].str;
+ }
+ return "unknown";
+}
+
+int get_string_value(const struct value_string *vs, const char *str)
+{
+ int i;
+
+ for (i = 0;; i++) {
+ if (vs[i].value == 0 && vs[i].str == NULL)
+ break;
+ if (!strcasecmp(vs[i].str, str))
+ return vs[i].value;
+ }
+ return -EINVAL;
+}
+
struct debug_info {
const char *name;
const char *color;