Officially remove tvb_get_string and tvb_get_stringz.

Almost all replacements were done awhile ago, just put the final nail in the coffin.

Change-Id: I0a708d886da5a500c2a1e2c9ee2736794bdb9411
Reviewed-on: https://code.wireshark.org/review/12206
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Michael Mann 2015-11-26 15:10:06 -05:00 committed by Anders Broman
parent 10261d1202
commit 3606f80d9e
9 changed files with 17 additions and 40 deletions

View File

@ -80,6 +80,9 @@ The libwireshark API has undergone some major changes:
used) have been replaced in name with the "new style" dissector
functions.
* tvb_get_string and tvb_get_stringz have been replaced with
tvb_get_string_enc and tvb_get_stringz_enc respectively.
== Getting Wireshark

View File

@ -271,8 +271,8 @@ req_resp_hdrs_do_reassembly(tvbuff_t *tvb, const int offset, packet_info *pinfo,
}
/* We have a line with the chunk size in it.*/
chunk_string = tvb_get_string(wmem_packet_scope(), tvb, next_offset,
linelen);
chunk_string = tvb_get_string_enc(wmem_packet_scope(), tvb, next_offset,
linelen, ENC_ASCII);
c = chunk_string;
/*
@ -346,7 +346,7 @@ req_resp_hdrs_do_reassembly(tvbuff_t *tvb, const int offset, packet_info *pinfo,
return TRUE;
}
/* Following sizeof will return the length of the string + \0 we need to not count it*/
tmp = tvb_get_string(wmem_packet_scope(), tvb, 0, sizeof("RPC_OUT_DATA") - 1);
tmp = tvb_get_string_enc(wmem_packet_scope(), tvb, 0, sizeof("RPC_OUT_DATA") - 1, ENC_ASCII);
if ((strncmp(tmp, "RPC_IN_DATA", sizeof("RPC_IN_DATA") - 1) == 0) ||
(strncmp(tmp, "RPC_OUT_DATA", sizeof("RPC_OUT_DATA") - 1) == 0)) {
return TRUE;

View File

@ -54,10 +54,10 @@ extern tpg_parser_data_t* tpg_start(proto_tree* root_tree,
#define TPG_TREE(vp) (((tpg_parser_data_t*)(vp))->tree)
#define TPG_DATA(vp,type) (((type*)(((tpg_parser_data_t*)(vp))->private_data)))
#define TPG_STRING(i) tvb_get_string(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len)
#define TPG_INT(i) strtol(tvb_get_string(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len),NULL,10)
#define TPG_UINT(i) strtoul(tvb_get_string(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len),NULL,10)
#define TPG_UINT_HEX(i) strtoul(tvb_get_string(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len),NULL,16)
#define TPG_STRING(i) tvb_get_string_enc(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len, ENC_ASCII)
#define TPG_INT(i) strtol(tvb_get_string_enc(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len, ENC_ASCII),NULL,10)
#define TPG_UINT(i) strtoul(tvb_get_string_enc(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len, ENC_ASCII),NULL,10)
#define TPG_UINT_HEX(i) strtoul(tvb_get_string_enc(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len, ENC_ASCII),NULL,16)
#define TPG_TVB(i) tvb_new_subset((i)->tvb,(i)->offset,(i)->len,(i)->len)
WS_DLL_PUBLIC guint32 tpg_ipv4(tvbparse_elem_t*);

View File

@ -481,7 +481,7 @@ static int cond_hash(tvbparse_t* tt, const int offset, const tvbparse_wanted_t*
if (key_len < 0)
return -1;
key = tvb_get_string(wmem_packet_scope(),key_elem->tvb,key_elem->offset,key_elem->len);
key = tvb_get_string_enc(wmem_packet_scope(),key_elem->tvb,key_elem->offset,key_elem->len, ENC_ASCII);
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_HASH) g_warning("cond_hash: got key='%s'",key);
#endif

View File

@ -582,16 +582,6 @@ extern gchar *tvb_format_stringzpad_wsp(tvbuff_t *tvb, const gint offset,
WS_DLL_PUBLIC guint8 *tvb_get_string_enc(wmem_allocator_t *scope,
tvbuff_t *tvb, const gint offset, const gint length, const guint encoding);
/*
* DEPRECATED, do not use in new code, call tvb_get_string_enc directly with
* the appropriate extension! Do not assume that ENC_ASCII will work
* with arbitrary string encodings; it will map all bytes with the 8th
* bit set to the Unicode REPLACEMENT CHARACTER, so it won't show non-ASCII
* characters as anything other than an ugly blob.
*/
#define tvb_get_string(SCOPE, TVB, OFFSET, LENGTH) \
tvb_get_string_enc(SCOPE, TVB, OFFSET, LENGTH, ENC_ASCII)
/**
* Given an allocator scope, a tvbuff, a bit offset, and a length in
* 7-bit characters (not octets!), with the specified offset and
@ -690,16 +680,6 @@ WS_DLL_PUBLIC guint8 *tvb_get_stringzpad(wmem_allocator_t *scope,
WS_DLL_PUBLIC guint8 *tvb_get_stringz_enc(wmem_allocator_t *scope,
tvbuff_t *tvb, const gint offset, gint *lengthp, const guint encoding);
/*
* DEPRECATED, do not use in new code, call tvb_get_string_enc directly with
* the appropriate extension! Do not assume that ENC_ASCII will work
* with arbitrary string encodings; it will map all bytes with the 8th
* bit set to the Unicode REPLACEMENT CHARACTER, so it won't show non-ASCII
* characters as anything other than an ugly blob.
*/
#define tvb_get_stringz(SCOPE, TVB, OFFSET, LENGTHP) \
tvb_get_stringz_enc(SCOPE, TVB, OFFSET, LENGTHP, ENC_ASCII)
/**
* Given a tvbuff and an offset, with the offset assumed to refer to
* a null-terminated string, find the length of that string (and throw

View File

@ -724,15 +724,14 @@ static void dissect_iap_result(tvbuff_t* tvb, packet_info* pinfo, proto_tree* ro
case GET_VALUE_BY_CLASS:
if (retcode == 0)
{
guint8 *string;
switch (tvb_get_guint8(tvb, offset + 6))
{
case IAS_MISSING:
g_snprintf(buf, 300, ", Missing");
col_append_str(pinfo->cinfo, COL_INFO, ", Missing");
break;
case IAS_INTEGER:
g_snprintf(buf, 300, ", Integer: %d", tvb_get_ntohl(tvb, offset + 7));
col_append_fstr(pinfo->cinfo, COL_INFO, ", Integer: %d", tvb_get_ntohl(tvb, offset + 7));
break;
case IAS_OCT_SEQ:
@ -741,14 +740,11 @@ static void dissect_iap_result(tvbuff_t* tvb, packet_info* pinfo, proto_tree* ro
case IAS_STRING:
n = tvb_get_guint8(tvb, offset + 8);
string = tvb_get_string(wmem_packet_scope(), tvb, offset + 9, n);
g_snprintf(buf, 300, ", \"%s\"", string);
col_append_fstr(pinfo->cinfo, COL_INFO, ", \"%s\"", tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 9, n, ENC_ASCII));
break;
default:
buf[0] = '\0';
break;
}
col_append_str(pinfo->cinfo, COL_INFO, buf);
if (tvb_get_ntohs(tvb, offset + 2) > 1)
col_append_str(pinfo->cinfo, COL_INFO, ", ...");
}

View File

@ -1048,8 +1048,8 @@ dissect_display_switch(proto_tree *msg_tree,
}
if(msg_len>0){
/* I'm guessing this will work flakily at best */
uinfo->string_data = tvb_get_string(wmem_packet_scope(), tvb,offset,msg_len);
proto_tree_add_item(msg_tree,hf_generic_string,tvb,offset,msg_len,ENC_ASCII|ENC_NA);
uinfo->string_data = tvb_get_string_enc(wmem_packet_scope(), tvb,offset,msg_len,ENC_ASCII);
proto_tree_add_string(msg_tree,hf_generic_string,tvb,offset,msg_len,uinfo->string_data);
}
offset+=msg_len;

View File

@ -822,7 +822,7 @@ static void wimaxasncp_dissect_tlv_value(
{
if (tree)
{
const gchar *s = tvb_get_string(wmem_packet_scope(), tvb, offset, length);
const gchar *s = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII);
proto_tree_add_string_format(
tree, tlv_info->hf_value,

View File

@ -145,8 +145,6 @@ my %APIs = (
# once they've been removed from all existing code.
'soft-deprecated' => { 'count_errors' => 0, 'functions' => [
'tvb_length_remaining', # replaced with tvb_captured_length_remaining
'tvb_get_string', # replaced with tvb_get_string_enc
'tvb_get_stringz', # replaced with tvb_get_stringz_enc
# Locale-unsafe APIs
# These may have unexpected behaviors in some locales (e.g.,