aboutsummaryrefslogtreecommitdiffstats
path: root/epan/value_string.c
diff options
context:
space:
mode:
authorEvan Huus <eapache@gmail.com>2013-07-26 21:51:39 +0000
committerEvan Huus <eapache@gmail.com>2013-07-26 21:51:39 +0000
commit6e3a30794ef9e3270f52bbb5ea2227ff35112f21 (patch)
tree1d7592f45b40281d89259ea429600352e9560461 /epan/value_string.c
parent6580abbbc31c22060e819cfb8b1b8484028b62ec (diff)
Add 64-bit value strings and the appropriate tooling (including yet another
overloaded use of the DISPLAY field). Thanks to Jakub for pointing out I'd done this wrong the first time (months ago in r49357). Fixes severity display for collectd protocol, originally filed at: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8472 svn path=/trunk/; revision=50935
Diffstat (limited to 'epan/value_string.c')
-rw-r--r--epan/value_string.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/epan/value_string.c b/epan/value_string.c
index a760971d89..f363956726 100644
--- a/epan/value_string.c
+++ b/epan/value_string.c
@@ -103,6 +103,65 @@ try_val_to_str(const guint32 val, const value_string *vs)
return try_val_to_str_idx(val, vs, &ignore_me);
}
+/* 64-BIT VALUE STRING */
+
+const gchar*
+val64_to_str(const guint64 val, const val64_string *vs, const char *fmt)
+{
+ const gchar *ret;
+
+ DISSECTOR_ASSERT(fmt != NULL);
+
+ ret = try_val64_to_str(val, vs);
+ if (ret != NULL)
+ return ret;
+
+ return ep_strdup_printf(fmt, val);
+}
+
+const gchar*
+val64_to_str_const(const guint64 val, const val64_string *vs,
+ const char *unknown_str)
+{
+ const gchar *ret;
+
+ DISSECTOR_ASSERT(unknown_str != NULL);
+
+ ret = try_val64_to_str(val, vs);
+ if (ret != NULL)
+ return ret;
+
+ return unknown_str;
+}
+
+const gchar*
+try_val64_to_str_idx(const guint64 val, const val64_string *vs, gint *idx)
+{
+ gint i = 0;
+
+ DISSECTOR_ASSERT(idx != NULL);
+
+ if(vs) {
+ while (vs[i].strptr) {
+ if (vs[i].value == val) {
+ *idx = i;
+ return(vs[i].strptr);
+ }
+ i++;
+ }
+ }
+
+ *idx = -1;
+ return NULL;
+}
+
+const gchar*
+try_val64_to_str(const guint64 val, const val64_string *vs)
+{
+ gint ignore_me;
+ return try_val64_to_str_idx(val, vs, &ignore_me);
+}
+
/* REVERSE VALUE STRING */
/* We use the same struct as for regular value strings, but we look up strings