Add a "tvb_bytes_to_str_punct()" routine, which wraps

"bytes_to_str_punct()", and use it instead of extracting the bytes and
formatting them by hand.

svn path=/trunk/; revision=12876
This commit is contained in:
Guy Harris 2004-12-30 23:47:52 +00:00
parent 467e33d1b1
commit a0de9d34c7
3 changed files with 22 additions and 6 deletions

View File

@ -680,7 +680,6 @@ static void dissect_fc_sbccs_dib_link_hdr (tvbuff_t *tvb, packet_info *pinfo,
guint16 ctl_info;
gchar buffer[128];
guint link_payload_len, i;
gchar *lpath_ptr;
if (check_col (pinfo->cinfo, COL_INFO)) {
col_append_fstr (pinfo->cinfo, COL_INFO,
@ -741,14 +740,12 @@ static void dissect_fc_sbccs_dib_link_hdr (tvbuff_t *tvb, packet_info *pinfo,
link_payload_len = tvb_get_ntohs (tvb, offset+10);
i = 0;
offset += 16;
lpath_ptr = (gchar *)tvb_get_ptr (tvb, offset, link_payload_len/4);
while (i < link_payload_len) {
proto_tree_add_text (tree, tvb, offset, 4,
"Logical Paths %d-%d: %x:%x:%x:%x",
i*8, ((i+4)*8) - 1, lpath_ptr[i],
lpath_ptr[i+1], lpath_ptr[i+2],
lpath_ptr[i+3]);
"Logical Paths %d-%d: %s",
i*8, ((i+4)*8) - 1,
tvb_bytes_to_str_punct (tvb, offset, 4, ':'));
i += 4;
offset += 4;
}

View File

@ -2128,6 +2128,17 @@ tvb_find_line_end_unquoted(tvbuff_t *tvb, gint offset, int len,
return linelen;
}
/*
* Format a bunch of data from a tvbuff as bytes, returning a pointer
* to the string with the formatted data, with "punct" as a byte
* separator.
*/
gchar *
tvb_bytes_to_str_punct(tvbuff_t *tvb, gint offset, gint len, gchar punct)
{
return bytes_to_str_punct(tvb_get_ptr(tvb, offset, len), len, punct);
}
/*
* Format a bunch of data from a tvbuff as bytes, returning a pointer
* to the string with the formatted data.

View File

@ -499,6 +499,14 @@ extern gint tvb_strncaseeql(tvbuff_t *tvb, gint offset, const gchar *str,
extern gint tvb_memeql(tvbuff_t *tvb, gint offset, const guint8 *str,
gint size);
/*
* Format a bunch of data from a tvbuff as bytes, returning a pointer
* to the string with the formatted data, with "punct" as a byte
* separator.
*/
extern gchar *tvb_bytes_to_str_punct(tvbuff_t *tvb, gint offset, gint len,
gchar punct);
/*
* Format a bunch of data from a tvbuff as bytes, returning a pointer
* to the string with the formatted data.