2 * Definitions for value_string structures and routines
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@zing.org>
8 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #ifndef __VALUE_STRING_H__
27 #define __VALUE_STRING_H__
31 /* Struct for the match_strval function */
33 typedef struct _value_string {
38 /* #define VS_DEF(x) { x, #x } */
39 /* #define VS_END { 0, NULL } */
41 /* Tries to match val against each element in the value_string array vs.
42 Returns the associated string ptr on a match, or NULL on failure. */
43 extern gchar* match_strval(guint32 val, const value_string *vs);
45 /* Tries to match val against each element in the value_string array vs.
46 Returns the associated string ptr on a match.
47 Formats val with fmt, and returns the resulting string, on failure. */
48 extern gchar* val_to_str(guint32 val, const value_string *vs, const char *fmt);
50 /* Generate a string describing an enumerated bitfield (an N-bit field
51 with various specific values having particular names). */
52 extern const char *decode_enumerated_bitfield(guint32 val, guint32 mask,
53 int width, const value_string *tab, const char *fmt);
55 /* Generate a string describing an enumerated bitfield (an N-bit field
56 with various specific values having particular names). */
57 extern const char *decode_enumerated_bitfield_shifted(guint32 val, guint32 mask,
58 int width, const value_string *tab, const char *fmt);
60 #endif /* __VALUE_STRING_H__ */