diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
commit | e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc (patch) | |
tree | 68cb5ef9081156392f1dd62a00c6ccc1451b93df /epan/iana_charsets.c | |
parent | Initial commit. (diff) | |
download | wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.tar.xz wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.zip |
Adding upstream version 4.2.2.upstream/4.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/iana_charsets.c')
-rw-r--r-- | epan/iana_charsets.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/epan/iana_charsets.c b/epan/iana_charsets.c new file mode 100644 index 00000000..600339cd --- /dev/null +++ b/epan/iana_charsets.c @@ -0,0 +1,75 @@ +/* iana_charsets.c + * + * Routines and tables for IANA-registered character sets + * + * http://www.iana.org/assignments/character-sets/character-sets.xhtml + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * WAP dissector based on original work by Ben Fowler + * Updated by Neil Hunter <neil.hunter@energis-squared.com> + * WTLS support by Alexandre P. Ferreira (Splice IP) + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "config.h" + +#include <glib.h> + +#include <epan/proto.h> +#include <epan/value_string.h> +#include <epan/params.h> + +#include <epan/iana_charsets.h> + +#define _ICWE_CASE_AND_RETURN(ic_enum_val, ws_enc) case (ic_enum_val): return (ws_enc); + +/* + * Map a MIBenum code for a charset to a Wireshark string encoding. + */ +guint +mibenum_charset_to_encoding (guint charset) +{ + switch (charset) { + /* Expand macro result in: + * + * case IANA_CS_US_ASCII: + * return ENC_NA|ENC_ASCII; + * + * case IANA_CS_ISO_8859_1: + * return ENC_NA|ENC_ISO_8859_1; + * ... + */ + IANA_CHARSETS_WS_ENCODING_MAP_LIST(_ICWE_CASE_AND_RETURN, ICWE_MAP_TO_ENUM_MAP_ONLY, ICWE_SELECT_N1) + + default: + return ENC_NA|_DEFAULT_WS_ENC; + } +} + +/* define a value_string array named mibenum_vals_character_sets */ +VALUE_STRING_ARRAY(mibenum_vals_character_sets); + +value_string_ext mibenum_vals_character_sets_ext = VALUE_STRING_EXT_INIT(mibenum_vals_character_sets); + +/* define an iana charset enum_val_t array named mibenum_vals_character_sets_ev_array */ +VS_LIST_TO_ENUM_VAL_T_ARRAY_GLOBAL_DEF(mibenum_vals_character_sets, mibenum_vals_character_sets_ev_array); + +/* define an Wireshark supported iana charset enum_val_t array */ +VS_LIST_TO_ENUM_VAL_T_ARRAY_GLOBAL_DEF(ws_supported_mibenum_vals_character_sets, ws_supported_mibenum_vals_character_sets_ev_array); + +/* + * Editor modelines - https://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: + */ |