2001-04-01 03:18:41 +00:00
|
|
|
/* value_string.h
|
|
|
|
* Definitions for value_string structures and routines
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2001-04-01 03:18:41 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2001-04-01 03:18:41 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2001-04-01 03:18:41 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2001-04-01 03:18:41 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2001-04-01 03:18:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VALUE_STRING_H__
|
|
|
|
#define __VALUE_STRING_H__
|
|
|
|
|
|
|
|
#include <glib.h>
|
2013-03-01 23:53:11 +00:00
|
|
|
#include "ws_symbol_export.h"
|
2001-04-01 03:18:41 +00:00
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
/* VALUE TO STRING MATCHING */
|
2001-04-01 03:18:41 +00:00
|
|
|
|
|
|
|
typedef struct _value_string {
|
2013-11-21 18:46:40 +00:00
|
|
|
guint32 value;
|
|
|
|
const gchar *strptr;
|
2001-04-01 03:18:41 +00:00
|
|
|
} value_string;
|
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 00:26:23 +00:00
|
|
|
val_to_str(const guint32 val, const value_string *vs, const char *fmt);
|
2009-05-26 00:49:38 +00:00
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 00:26:23 +00:00
|
|
|
val_to_str_const(const guint32 val, const value_string *vs, const char *unknown_str);
|
2010-10-14 17:50:35 +00:00
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 00:26:23 +00:00
|
|
|
try_val_to_str(const guint32 val, const value_string *vs);
|
2004-05-07 11:34:10 +00:00
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 00:26:23 +00:00
|
|
|
try_val_to_str_idx(const guint32 val, const value_string *vs, gint *idx);
|
2009-09-06 04:26:50 +00:00
|
|
|
|
2013-07-26 21:51:39 +00:00
|
|
|
/* 64-BIT VALUE TO STRING MATCHING */
|
|
|
|
|
|
|
|
typedef struct _val64_string {
|
2013-11-21 18:46:40 +00:00
|
|
|
guint64 value;
|
|
|
|
const gchar *strptr;
|
2013-07-26 21:51:39 +00:00
|
|
|
} val64_string;
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-07-26 21:51:39 +00:00
|
|
|
val64_to_str(const guint64 val, const val64_string *vs, const char *fmt);
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-07-26 21:51:39 +00:00
|
|
|
val64_to_str_const(const guint64 val, const val64_string *vs, const char *unknown_str);
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-07-26 21:51:39 +00:00
|
|
|
try_val64_to_str(const guint64 val, const val64_string *vs);
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-07-26 21:51:39 +00:00
|
|
|
try_val64_to_str_idx(const guint64 val, const val64_string *vs, gint *idx);
|
|
|
|
|
2013-03-29 23:23:28 +00:00
|
|
|
/* STRING TO VALUE MATCHING */
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC
|
|
|
|
guint32
|
|
|
|
str_to_val(const gchar *val, const value_string *vs, const guint32 err_val);
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC
|
|
|
|
gint
|
|
|
|
str_to_val_idx(const gchar *val, const value_string *vs);
|
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
/* EXTENDED VALUE TO STRING MATCHING */
|
2009-05-26 00:49:38 +00:00
|
|
|
|
2010-10-14 17:50:35 +00:00
|
|
|
struct _value_string_ext;
|
2011-04-28 11:15:46 +00:00
|
|
|
typedef const value_string *(*_value_string_match2_t)(const guint32, const struct _value_string_ext *);
|
2010-10-14 17:50:35 +00:00
|
|
|
|
|
|
|
typedef struct _value_string_ext {
|
2013-11-21 18:46:40 +00:00
|
|
|
_value_string_match2_t _vs_match2;
|
|
|
|
guint32 _vs_first_value; /* first value of the value_string array */
|
|
|
|
guint _vs_num_entries; /* number of entries in the value_string array */
|
|
|
|
/* (excluding final {0, NULL}) */
|
|
|
|
const value_string *_vs_p; /* the value string array address */
|
|
|
|
const gchar *_vs_name; /* vse "Name" (for error messages) */
|
2010-10-14 17:50:35 +00:00
|
|
|
} value_string_ext;
|
|
|
|
|
|
|
|
#define VALUE_STRING_EXT_VS_P(x) (x)->_vs_p
|
2010-11-12 19:48:30 +00:00
|
|
|
#define VALUE_STRING_EXT_VS_NUM_ENTRIES(x) (x)->_vs_num_entries
|
|
|
|
#define VALUE_STRING_EXT_VS_NAME(x) (x)->_vs_name
|
2010-11-14 16:30:56 +00:00
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
WS_DLL_PUBLIC
|
|
|
|
const value_string*
|
|
|
|
_try_val_to_str_ext_init(const guint32 val, const value_string_ext *vse);
|
|
|
|
#define VALUE_STRING_EXT_INIT(x) { _try_val_to_str_ext_init, 0, array_length(x)-1, x, #x }
|
2010-10-14 17:50:35 +00:00
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const value_string_ext *
|
|
|
|
value_string_ext_new(const value_string *vs, guint vs_tot_num_entries, const gchar *vs_name);
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC
|
|
|
|
void
|
|
|
|
value_string_ext_free(const value_string_ext *vse);
|
2010-10-14 17:50:35 +00:00
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 00:26:23 +00:00
|
|
|
val_to_str_ext(const guint32 val, const value_string_ext *vs, const char *fmt);
|
2010-10-14 17:50:35 +00:00
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 00:26:23 +00:00
|
|
|
val_to_str_ext_const(const guint32 val, const value_string_ext *vs, const char *unknown_str);
|
2010-10-14 17:50:35 +00:00
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 00:26:23 +00:00
|
|
|
try_val_to_str_ext(const guint32 val, const value_string_ext *vse);
|
2011-01-10 14:31:33 +00:00
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
|
|
|
try_val_to_str_idx_ext(const guint32 val, const value_string_ext *vse, gint *idx);
|
2010-10-14 17:50:35 +00:00
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
/* STRING TO STRING MATCHING */
|
|
|
|
|
|
|
|
typedef struct _string_string {
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *value;
|
|
|
|
const gchar *strptr;
|
2013-03-29 00:26:23 +00:00
|
|
|
} string_string;
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 00:26:23 +00:00
|
|
|
str_to_str(const gchar *val, const string_string *vs, const char *fmt);
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 00:26:23 +00:00
|
|
|
try_str_to_str(const gchar *val, const string_string *vs);
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 00:26:23 +00:00
|
|
|
try_str_to_str_idx(const gchar *val, const string_string *vs, gint *idx);
|
|
|
|
|
|
|
|
/* RANGE TO STRING MATCHING */
|
|
|
|
|
|
|
|
typedef struct _range_string {
|
2013-11-21 18:46:40 +00:00
|
|
|
guint32 value_min;
|
|
|
|
guint32 value_max;
|
|
|
|
const gchar *strptr;
|
2013-03-29 00:26:23 +00:00
|
|
|
} range_string;
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 00:26:23 +00:00
|
|
|
rval_to_str(const guint32 val, const range_string *rs, const char *fmt);
|
|
|
|
|
2013-09-29 12:44:50 +00:00
|
|
|
WS_DLL_PUBLIC
|
|
|
|
const gchar *
|
|
|
|
rval_to_str_const(const guint32 val, const range_string *rs, const char *unknown_str);
|
|
|
|
|
2013-03-29 00:26:23 +00:00
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 00:26:23 +00:00
|
|
|
try_rval_to_str(const guint32 val, const range_string *rs);
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 00:26:23 +00:00
|
|
|
try_rval_to_str_idx(const guint32 val, const range_string *rs, gint *idx);
|
|
|
|
|
|
|
|
/* MISC (generally do not use) */
|
2010-10-14 17:50:35 +00:00
|
|
|
|
2013-03-29 02:34:23 +00:00
|
|
|
WS_DLL_LOCAL
|
|
|
|
gboolean
|
|
|
|
value_string_ext_validate(const value_string_ext *vse);
|
|
|
|
|
|
|
|
WS_DLL_LOCAL
|
2013-11-21 18:46:40 +00:00
|
|
|
const gchar *
|
2013-03-29 02:34:23 +00:00
|
|
|
value_string_ext_match_type_str(const value_string_ext *vse);
|
2001-04-01 03:18:41 +00:00
|
|
|
|
|
|
|
#endif /* __VALUE_STRING_H__ */
|
2013-11-21 18:46:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|