ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: [Wireshark-dev] How to retrieve/modify a tree string

From: "Bill Florac" <bill.florac@xxxxxxxxxxxxxx>
Date: Wed, 15 Nov 2006 09:32:00 -0600
Is there an easy way to amend the display text for an item inserted in a
tree with proto_tree_add_item(). Like proto_item_append_text() but I
need to insert text into or in front of the existing text.  For example,
if I want to display an array of items that all use the same hfindex.
In the following example, the "user" comes from hf[] and the following
name is the value. 

User: Bob
User: Tom
User: Fred

I want to insert an index to the view so it would look like 

User[0]: Bob
User[1]: Tom
User[2]: Fred

I thought that if I put sprintf context into the hf[] data like
"User[%d]", I could then retreive the display string from pinfo, put it
thru sprintf with my index and then reset the text. But this not seem to
work.  I know I can just write the text with proto_tree_add_text() or
proto_tree_set_text() but I want to use the formating provided by
proto_tree_add_item().

Any ideas?

Bill Florac