aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-11-26 15:10:06 -0500
committerAnders Broman <a.broman58@gmail.com>2015-11-27 05:11:25 +0000
commit3606f80d9e297c2c1fd8e69b2d2a9e13a99d4344 (patch)
tree3aa83dd74b85ea84f6aea028a20e494dc674896f
parent10261d120283cb739118fa7178b4e911ed72de14 (diff)
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>
-rw-r--r--docbook/release-notes.asciidoc3
-rw-r--r--epan/req_resp_hdrs.c6
-rw-r--r--epan/tpg.h8
-rw-r--r--epan/tvbparse.c2
-rw-r--r--epan/tvbuff.h20
-rw-r--r--plugins/irda/packet-irda.c10
-rw-r--r--plugins/unistim/packet-unistim.c4
-rw-r--r--plugins/wimaxasncp/packet-wimaxasncp.c2
-rwxr-xr-xtools/checkAPIs.pl2
9 files changed, 17 insertions, 40 deletions
diff --git a/docbook/release-notes.asciidoc b/docbook/release-notes.asciidoc
index 9e9801eb8e..c24c961ee9 100644
--- a/docbook/release-notes.asciidoc
+++ b/docbook/release-notes.asciidoc
@@ -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
diff --git a/epan/req_resp_hdrs.c b/epan/req_resp_hdrs.c
index fff245e590..4e9d01d0d0 100644
--- a/epan/req_resp_hdrs.c
+++ b/epan/req_resp_hdrs.c
@@ -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;
diff --git a/epan/tpg.h b/epan/tpg.h
index d4065c0a81..d4c8dff620 100644
--- a/epan/tpg.h
+++ b/epan/tpg.h
@@ -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*);
diff --git a/epan/tvbparse.c b/epan/tvbparse.c
index 4f400597ff..eb6f04c518 100644
--- a/epan/tvbparse.c
+++ b/epan/tvbparse.c
@@ -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
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index f359422703..0505245a3a 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -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
diff --git a/plugins/irda/packet-irda.c b/plugins/irda/packet-irda.c
index e1e1d9dae9..6430393b15 100644
--- a/plugins/irda/packet-irda.c
+++ b/plugins/irda/packet-irda.c
@@ -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, ", ...");
}
diff --git a/plugins/unistim/packet-unistim.c b/plugins/unistim/packet-unistim.c
index 7858f78ee4..a93fff9657 100644
--- a/plugins/unistim/packet-unistim.c
+++ b/plugins/unistim/packet-unistim.c
@@ -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;
diff --git a/plugins/wimaxasncp/packet-wimaxasncp.c b/plugins/wimaxasncp/packet-wimaxasncp.c
index 64c5cb36ee..d769d4643d 100644
--- a/plugins/wimaxasncp/packet-wimaxasncp.c
+++ b/plugins/wimaxasncp/packet-wimaxasncp.c
@@ -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,
diff --git a/tools/checkAPIs.pl b/tools/checkAPIs.pl
index 8e6acca6b3..06db2b496b 100755
--- a/tools/checkAPIs.pl
+++ b/tools/checkAPIs.pl
@@ -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.,