wsutil: rename bytestring_to_str() -> bytes_to_str_punct()

This commit is contained in:
João Valverde 2021-07-29 02:21:35 +01:00 committed by Wireshark GitLab Utility
parent 177e5cda1f
commit 7b845e7194
17 changed files with 33 additions and 33 deletions

View File

@ -11,7 +11,7 @@ libwsutil.so.0 libwsutil0 #MINVER#
bytes_to_hexstr@Base 3.5.0
bytes_to_hexstr_punct@Base 3.5.0
bytes_to_str_max@Base 3.5.0
bytestring_to_str_max@Base 3.5.0
bytes_to_str_punct_max@Base 3.5.0
codec_decode@Base 3.1.0
codec_get_channels@Base 3.1.0
codec_get_frequency@Base 3.1.0

View File

@ -362,10 +362,10 @@ SigParameterV1/value ABBREV=sig_param_value
curr_info.term->buffer = (guint8 *)tvb_memdup(actx->pinfo->pool,new_tvb,0,curr_info.term->len);
if(term_info.str){
curr_info.term->str = wmem_strdup_printf(actx->pinfo->pool, "%s %s",
bytestring_to_str(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0),
bytes_to_str_punct(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0),
term_info.str);
}else{
curr_info.term->str = bytestring_to_str(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0);
curr_info.term->str = bytes_to_str_punct(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0);
}
}

View File

@ -221,7 +221,7 @@ BulkPDU/request-id bulkPDU_request-id
if (usm_p.authOK) {
expert = &ei_snmp_authentication_ok;
} else {
const gchar* calc_auth_str = bytestring_to_str(actx->pinfo->pool, calc_auth,calc_auth_len,' ');
const gchar* calc_auth_str = bytes_to_str_punct(actx->pinfo->pool, calc_auth,calc_auth_len,' ');
proto_item_append_text(authen_item, " calculated = %s", calc_auth_str);
expert = &ei_snmp_authentication_error;
}

View File

@ -113,7 +113,7 @@ dissect_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
cp = tvb_get_ptr(tvb, 0, bytes);
gcry_md_hash_buffer(GCRY_MD_MD5, digest, cp, bytes);
digest_string = bytestring_to_str(pinfo->pool, digest, HASH_MD5_LENGTH, '\0');
digest_string = bytes_to_str_punct(pinfo->pool, digest, HASH_MD5_LENGTH, '\0');
ti = proto_tree_add_string(data_tree, &hfi_data_md5_hash, tvb, 0, 0, digest_string);
proto_item_set_generated(ti);
}

View File

@ -739,7 +739,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
cp = tvb_get_ptr(tvb, 0, cap_len);
gcry_md_hash_buffer(GCRY_MD_MD5, digest, cp, cap_len);
digest_string = bytestring_to_str(pinfo->pool, digest, HASH_MD5_LENGTH, '\0');
digest_string = bytes_to_str_punct(pinfo->pool, digest, HASH_MD5_LENGTH, '\0');
ti = proto_tree_add_string(fh_tree, hf_frame_md5_hash, tvb, 0, 0, digest_string);
proto_item_set_generated(ti);
}

View File

@ -2981,10 +2981,10 @@ dissect_h248_T_terminationId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int o
curr_info.term->buffer = (guint8 *)tvb_memdup(actx->pinfo->pool,new_tvb,0,curr_info.term->len);
if(term_info.str){
curr_info.term->str = wmem_strdup_printf(actx->pinfo->pool, "%s %s",
bytestring_to_str(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0),
bytes_to_str_punct(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0),
term_info.str);
}else{
curr_info.term->str = bytestring_to_str(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0);
curr_info.term->str = bytes_to_str_punct(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0);
}
}

View File

@ -220,7 +220,7 @@ ipx_addr_to_str(const guint32 net, const guint8 *ad)
else {
buf = wmem_strdup_printf(wmem_packet_scope(), "%s.%s",
get_ipxnet_name(wmem_packet_scope(), net),
bytestring_to_str(wmem_packet_scope(), ad, 6, '\0'));
bytes_to_str_punct(wmem_packet_scope(), ad, 6, '\0'));
}
return buf;
}

View File

@ -3044,7 +3044,7 @@ static int parse_guid(tvbuff_t *tvb, int offset, proto_tree *tree, e_guid_t *gui
offset += 1;
proto_tree_add_item(tr, hf_mswsp_guid_time_clock_low, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
bytes = bytestring_to_str(wmem_packet_scope(), &guid->data4[2], 6, ':');
bytes = bytes_to_str_punct(wmem_packet_scope(), &guid->data4[2], 6, ':');
proto_tree_add_string(tr, hf_mswsp_guid_node, tvb, offset, 6, bytes);
offset += 6;

View File

@ -494,7 +494,7 @@ static gint dissect_parameter_transport_rtps_type(
tvb,
OFFSET_TO_VAL,
param_length);
const gchar *guid_string = bytestring_to_str(
const gchar *guid_string = bytes_to_str_punct(
pinfo->pool,
guid_bytes,
MIN(param_length, 12),

View File

@ -2869,7 +2869,7 @@ dissect_snmp_SNMPv3Message(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int off
if (usm_p.authOK) {
expert = &ei_snmp_authentication_ok;
} else {
const gchar* calc_auth_str = bytestring_to_str(actx->pinfo->pool, calc_auth,calc_auth_len,' ');
const gchar* calc_auth_str = bytes_to_str_punct(actx->pinfo->pool, calc_auth,calc_auth_len,' ');
proto_item_append_text(authen_item, " calculated = %s", calc_auth_str);
expert = &ei_snmp_authentication_error;
}

View File

@ -194,7 +194,7 @@ extern void oid_add_from_encoded(const char* name, const guint8 *oid, gint oid_l
add_oid(name,OID_KIND_UNKNOWN,NULL,NULL,subids_len,subids);
wmem_free(NULL, sub);
} else {
gchar* bytestr = bytestring_to_str(NULL, oid, oid_len, ':');
gchar* bytestr = bytes_to_str_punct(NULL, oid, oid_len, ':');
D(1,("Failed to add Oid: %s [%d]%s ",name?name:"NULL", oid_len, bytestr));
wmem_free(NULL, bytestr);
}
@ -1342,10 +1342,10 @@ char* oid_test_a2b(guint32 num_subids, guint32* subids) {
"oid_string2encoded=[%d]%s \n"
"oid_string2subid=%s \n "
,sub2str
,sub2enc_len,bytestring_to_str(wmem_packet_scope(), sub2enc, sub2enc_len, ':')
,sub2enc_len,bytes_to_str_punct(wmem_packet_scope(), sub2enc, sub2enc_len, ':')
,enc2sub ? oid_subid2string(wmem_packet_scope(), enc2sub,enc2sub_len) : "-"
,enc2str
,str2enc_len,bytestring_to_str(wmem_packet_scope(), str2enc, str2enc_len, ':')
,str2enc_len,bytes_to_str_punct(wmem_packet_scope(), str2enc, str2enc_len, ':')
,str2sub ? oid_subid2string(wmem_packet_scope(), str2sub,str2sub_len) : "-"
);

View File

@ -1080,21 +1080,21 @@ hfinfo_format_bytes(wmem_allocator_t *scope, const header_field_info *hfinfo,
*/
switch (FIELD_DISPLAY(hfinfo->display)) {
case SEP_DOT:
str = bytestring_to_str(scope, bytes, length, '.');
str = bytes_to_str_punct(scope, bytes, length, '.');
break;
case SEP_DASH:
str = bytestring_to_str(scope, bytes, length, '-');
str = bytes_to_str_punct(scope, bytes, length, '-');
break;
case SEP_COLON:
str = bytestring_to_str(scope, bytes, length, ':');
str = bytes_to_str_punct(scope, bytes, length, ':');
break;
case SEP_SPACE:
str = bytestring_to_str(scope, bytes, length, ' ');
str = bytes_to_str_punct(scope, bytes, length, ' ');
break;
case BASE_NONE:
default:
if (prefs.display_byte_fields_with_spaces) {
str = bytestring_to_str(scope, bytes, length, ' ');
str = bytes_to_str_punct(scope, bytes, length, ' ');
} else {
str = bytes_to_str(scope, bytes, length);
}

View File

@ -4214,7 +4214,7 @@ int tvb_get_token_len(tvbuff_t *tvb, const gint offset, int len, gint *next_offs
gchar *
tvb_bytes_to_str_punct(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, const gint len, const gchar punct)
{
return bytestring_to_str(scope, ensure_contiguous(tvb, offset, len), len, punct);
return bytes_to_str_punct(scope, ensure_contiguous(tvb, offset, len), len, punct);
}
/*

View File

@ -1043,7 +1043,7 @@ static void wimaxasncp_dissect_tlv_value(
const gchar *format1;
const gchar *format2;
const guint8 *p = tvb_get_ptr(tvb, offset, length);
const gchar *s = bytestring_to_str(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0);
const gchar *s = bytes_to_str_punct(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0);
if (length <= max_show_bytes)
{
@ -1223,7 +1223,7 @@ static void wimaxasncp_dissect_tlv_value(
{
const gchar *format;
const guint8 *p = tvb_get_ptr(tvb, offset, length);
const gchar *s = bytestring_to_str(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0);
const gchar *s = bytes_to_str_punct(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0);
if (length <= max_show_bytes)
{
@ -1712,7 +1712,7 @@ static void wimaxasncp_dissect_tlv_value(
const gchar *format2;
const guint8 *p = tvb_get_ptr(tvb, offset, length);
const gchar *s =
bytestring_to_str(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0);
bytes_to_str_punct(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0);
if (length <= max_show_bytes)
{
@ -1752,7 +1752,7 @@ static void wimaxasncp_dissect_tlv_value(
{
const gchar *format;
const guint8 *p = tvb_get_ptr(tvb, offset, length);
const gchar *s = bytestring_to_str(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0);
const gchar *s = bytes_to_str_punct(wmem_packet_scope(), p, MIN(length, max_show_bytes), 0);
if (length <= max_show_bytes)
{

View File

@ -45,13 +45,13 @@ void test_bytes_to_str(void)
g_free(str);
}
void test_bytestring_to_str(void)
void test_bytes_to_str_punct(void)
{
char *str;
const guint8 buf[] = { 1, 2, 3};
str = bytestring_to_str(NULL, buf, sizeof(buf), ':');
str = bytes_to_str_punct(NULL, buf, sizeof(buf), ':');
g_assert_cmpstr(str, ==, "01:02:03");
g_free(str);
}
@ -89,7 +89,7 @@ int main(int argc, char **argv)
g_test_add_func("/str_util/format_size", test_format_size);
g_test_add_func("/to_str/bytes_to_str", test_bytes_to_str);
g_test_add_func("/to_str/bytestring_to_str", test_bytestring_to_str);
g_test_add_func("/to_str/bytes_to_str_punct", test_bytes_to_str_punct);
g_test_add_func("/to_str/bytes_to_str_trunc1", test_bytes_to_string_trunc1);
ret = g_test_run();

View File

@ -102,7 +102,7 @@ bytes_to_hexstr_punct(char *out, const guint8 *ad, size_t len, char punct)
* the resulting string is (len-1) bytes shorter)
*/
gchar *
bytestring_to_str_max(wmem_allocator_t *scope, const guint8 *ad, size_t len, const char punct, size_t max)
bytes_to_str_punct_max(wmem_allocator_t *scope, const guint8 *ad, size_t len, const char punct, size_t max)
{
gchar *buf;
size_t buflen = len;
@ -110,12 +110,12 @@ bytestring_to_str_max(wmem_allocator_t *scope, const guint8 *ad, size_t len, con
int truncated = 0;
if (len == 0) {
ws_warning("Zero length passed to bytestring_to_str()");
ws_warning("Zero length passed to bytes_to_str_punct()");
return wmem_strdup(scope, "(zero length)");
}
if (!ad) {
ws_warning("Null pointer passed to bytestring_to_str()");
ws_warning("Null pointer passed to bytes_to_str_punct()");
return wmem_strdup(scope, "(null pointer)");
}

View File

@ -58,9 +58,9 @@ WS_DLL_PUBLIC char *bytes_to_hexstr_punct(char *out, const guint8 *ad, size_t le
*
* @see bytes_to_str()
*/
WS_DLL_PUBLIC gchar *bytestring_to_str_max(wmem_allocator_t *scope, const guint8 *ad, size_t len, const char punct, size_t max);
WS_DLL_PUBLIC gchar *bytes_to_str_punct_max(wmem_allocator_t *scope, const guint8 *ad, size_t len, const char punct, size_t max);
#define bytestring_to_str(scope, ad, len, punct) bytestring_to_str_max(scope, ad, len, punct, MAX_BYTE_STR_LEN)
#define bytes_to_str_punct(scope, ad, len, punct) bytes_to_str_punct_max(scope, ad, len, punct, MAX_BYTE_STR_LEN)
/** Turn an array of bytes into a string showing the bytes in hex.
*