diff options
-rw-r--r-- | epan/proto.c | 37 | ||||
-rw-r--r-- | epan/proto.h | 29 |
2 files changed, 66 insertions, 0 deletions
diff --git a/epan/proto.c b/epan/proto.c index 56c19908eb..08bbf01168 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1122,6 +1122,43 @@ proto_tree_add_text_valist(proto_tree *tree, tvbuff_t *tvb, gint start, return pi; } +/* Add a text-only node that creates a subtree underneath. + * proto_tree_add_text + proto_item_add_subtree + */ +proto_tree * +proto_tree_add_subtree(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, gint idx, proto_item **tree_item, const char *text) +{ + return proto_tree_add_subtree_format(tree, tvb, start, length, idx, tree_item, "%s", text); +} + +/* Add a text-only node that creates a subtree underneath. + * proto_tree_add_text + proto_item_add_subtree + */ +proto_tree * +proto_tree_add_subtree_format(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, gint idx, proto_item **tree_item, const char *format, ...) +{ + proto_tree *pt; + proto_item *pi; + va_list ap; + header_field_info *hfinfo; + + TRY_TO_FAKE_THIS_ITEM(tree, hf_text_only, hfinfo); + + pi = proto_tree_add_text_node(tree, tvb, start, length); + + TRY_TO_FAKE_THIS_REPR(pi); + + va_start(ap, format); + proto_tree_set_representation(pi, format, ap); + va_end(ap); + + pt = proto_item_add_subtree(pi, idx); + if (tree_item != NULL) + *tree_item = pi; + + return pt; +} + /* Add a text-only node for debugging purposes. The caller doesn't need * to worry about tvbuff, start, or length. Debug message gets sent to * STDOUT, too */ diff --git a/epan/proto.h b/epan/proto.h index 70fbb1ac10..0f85750848 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -879,6 +879,35 @@ proto_item * proto_tree_add_text_valist(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, const char *format, va_list ap); +/** Add a text-only node that creates a subtree underneath. + proto_tree_add_text + proto_item_add_subtree + @param tree the tree to append this item to + @param tvb the tv buffer of the current data + @param start start of data in tvb + @param length length of data in tvb + @param idx one of the ett_ array elements registered with proto_register_subtree_array() + @param tree_item item returned with tree creation. + @param Can be NULL if going to be unused + @param text label for the tree + @return the newly created tree */ +proto_tree * +proto_tree_add_subtree(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, gint idx, proto_item **tree_item, const char *text); + +/** Add a text-only node that creates a subtree underneath. + proto_tree_add_text + proto_item_add_subtree + @param tree the tree to append this item to + @param tvb the tv buffer of the current data + @param start start of data in tvb + @param length length of data in tvb + @param idx one of the ett_ array elements registered with proto_register_subtree_array() + @param tree_item item returned with tree creation. + @param Can be NULL if going to be unused + @param format printf like format string + @param ... printf like parameters + @return the newly created tree */ +proto_tree * +proto_tree_add_subtree_format(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, gint idx, proto_item **tree_item, const char *format, + ...) G_GNUC_PRINTF(5,6); /** Add a text-only node to a proto_tree with tvb_format_text() string. */ proto_item * |