2 * Definitions for value_string structures and routines
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifndef __VALUE_STRING_H__
26 #define __VALUE_STRING_H__
29 #include "ws_symbol_export.h"
31 /* VALUE TO STRING MATCHING */
33 typedef struct _value_string {
40 val_to_str(const guint32 val, const value_string *vs, const char *fmt);
44 val_to_str_const(const guint32 val, const value_string *vs, const char *unknown_str);
48 try_val_to_str(const guint32 val, const value_string *vs);
52 try_val_to_str_idx(const guint32 val, const value_string *vs, gint *idx);
54 /* EXTENDED VALUE TO STRING MATCHING */
56 struct _value_string_ext;
57 typedef const value_string *(*_value_string_match2_t)(const guint32, const struct _value_string_ext *);
59 typedef struct _value_string_ext {
60 _value_string_match2_t _vs_match2;
61 guint32 _vs_first_value; /* first value of the value_string array */
62 guint _vs_num_entries; /* number of entries in the value_string array */
63 /* (excluding final {0, NULL}) */
64 const value_string *_vs_p; /* the value string array address */
65 const gchar *_vs_name; /* vse "Name" (for error messages) */
68 #define VALUE_STRING_EXT_VS_P(x) (x)->_vs_p
69 #define VALUE_STRING_EXT_VS_NUM_ENTRIES(x) (x)->_vs_num_entries
70 #define VALUE_STRING_EXT_VS_NAME(x) (x)->_vs_name
74 _try_val_to_str_ext_init(const guint32 val, const value_string_ext *vse);
75 #define VALUE_STRING_EXT_INIT(x) { _try_val_to_str_ext_init, 0, array_length(x)-1, x, #x }
79 value_string_ext_new(value_string *vs, guint vs_tot_num_entries, const gchar *vs_name);
83 val_to_str_ext(const guint32 val, const value_string_ext *vs, const char *fmt);
87 val_to_str_ext_const(const guint32 val, const value_string_ext *vs, const char *unknown_str);
91 try_val_to_str_ext(const guint32 val, const value_string_ext *vse);
95 try_val_to_str_idx_ext(const guint32 val, value_string_ext *vse, gint *idx);
97 /* STRING TO STRING MATCHING */
99 typedef struct _string_string {
106 str_to_str(const gchar *val, const string_string *vs, const char *fmt);
110 try_str_to_str(const gchar *val, const string_string *vs);
114 try_str_to_str_idx(const gchar *val, const string_string *vs, gint *idx);
116 /* RANGE TO STRING MATCHING */
118 typedef struct _range_string {
126 rval_to_str(const guint32 val, const range_string *rs, const char *fmt);
130 try_rval_to_str(const guint32 val, const range_string *rs);
134 try_rval_to_str_idx(const guint32 val, const range_string *rs, gint *idx);
136 /* MISC (generally do not use) */
140 value_string_ext_validate(const value_string_ext *vse);
144 value_string_ext_match_type_str(const value_string_ext *vse);
146 #endif /* __VALUE_STRING_H__ */