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

Wireshark-dev: Re: [Wireshark-dev] proto_tree -> proto_item

From: Luca Ceresoli <list@xxxxxxxxxxxxxxxx>
Date: Mon, 23 Mar 2009 22:48:28 +0100
Sébastien Tandel ha scritto:

Therefore you could then do what you want with something like the following :
it = proto_tree_add_text(ptvcursor_tree(cursor), ptvcursor_tvbuff(cursor),
      ptvcursor_current_offset(cursor), length, "foo");
my_tree = ptvcursor_add_subtree_item(cursor, it, ...);
Thanks Sébastien,

that looks fine, except ptvcursor_add_subtree_item() is not (currently) declared in any header file, so that does not compile.
Apart from dumbly declaring it, I found this alternative:

 my_tree = ptvcursor_add_text_with_subtree(cursor, ..., "foo");
 my_item = proto_tree_get_parent(my_tree);
 /* ... */
 proto_item_set_text(my_item, "<%s>", my_string);

To me it looks safe and cleaner, am I missing anything?

Luca