aboutsummaryrefslogtreecommitdiffstats
path: root/epan/value_string.h
diff options
context:
space:
mode:
authorStephen Fisher <steve@stephen-fisher.com>2006-12-07 20:29:40 +0000
committerStephen Fisher <steve@stephen-fisher.com>2006-12-07 20:29:40 +0000
commitc980cede98fada00249cc6d7218ef519302926f4 (patch)
treecde84151baa939faa211ceff602a1dde6d0ff848 /epan/value_string.h
parentf4e3b4c03367f0ac40bde83db1f2960566bd3aa7 (diff)
From Francesco Fondelli:
I defined a range_string struct. It's like value_string but stores range <-> string pairs. Moreover I wrote rval_to_str(), match_strrval_idx() match_strrval() which are behaving exactly as val_to_str(), match_strval_idx() and match_strval(). svn path=/trunk/; revision=20061
Diffstat (limited to 'epan/value_string.h')
-rw-r--r--epan/value_string.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/epan/value_string.h b/epan/value_string.h
index ff9c107ec6..546e8a7800 100644
--- a/epan/value_string.h
+++ b/epan/value_string.h
@@ -34,6 +34,13 @@ typedef struct _value_string {
const gchar *strptr;
} value_string;
+/* Struct for the rval_to_str, match_strrval_idx, and match_strrval functions */
+typedef struct _range_string {
+ guint32 value_min;
+ guint32 value_max;
+ const gchar *strptr;
+} range_string;
+
/* #define VS_DEF(x) { x, #x } */
/* #define VS_END { 0, NULL } */
@@ -61,4 +68,21 @@ extern const char *decode_enumerated_bitfield(guint32 val, guint32 mask,
extern const char *decode_enumerated_bitfield_shifted(guint32 val, guint32 mask,
int width, const value_string *tab, const char *fmt);
+
+/* ranges aware versions */
+
+/* Tries to match val against each range in the range_string array rs.
+ Returns the associated string ptr on a match.
+ Formats val with fmt, and returns the resulting string, on failure. */
+extern const gchar* rval_to_str(guint32 val, const range_string *rs, const char *fmt);
+
+/* Tries to match val against each range in the range_string array rs.
+ Returns the associated string ptr, and sets "*idx" to the index in
+ that table, on a match, and returns NULL, and sets "*idx" to -1,
+ on failure. */
+extern const gchar *match_strrval_idx(guint32 val, const range_string *rs, gint *idx);
+
+/* Like match_strrval_idx(), but doesn't return the index. */
+extern const gchar *match_strrval(guint32 val, const range_string *rs);
+
#endif /* __VALUE_STRING_H__ */