From Tomas Kukosa: add APIs to get the parent of a protocol tree item

and the item N levels up from a protocol tree item.

svn path=/trunk/; revision=10486
This commit is contained in:
Guy Harris 2004-03-25 23:55:21 +00:00
parent 95c026b270
commit 044f075c66
3 changed files with 32 additions and 3 deletions

View File

@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
* $Id: proto.c,v 1.130 2004/03/25 09:17:11 guy Exp $
* $Id: proto.c,v 1.131 2004/03/25 23:55:21 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -2186,6 +2186,26 @@ proto_item_get_subtree(proto_item *pi) {
return (proto_tree*) pi;
}
proto_item*
proto_item_get_parent(proto_item *ti) {
if (!ti)
return (NULL);
return ti->parent;
}
proto_item*
proto_item_get_parent_nth(proto_item *ti, int gen) {
if (!ti)
return (NULL);
while (gen--) {
ti = ti->parent;
if (!ti)
return (NULL);
}
return ti;
}
proto_item*
proto_tree_get_parent(proto_tree *tree) {
if (!tree)

View File

@ -1,7 +1,7 @@
/* proto.h
* Definitions for protocol display
*
* $Id: proto.h,v 1.56 2004/03/25 09:17:11 guy Exp $
* $Id: proto.h,v 1.57 2004/03/25 23:55:21 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -208,6 +208,12 @@ extern proto_tree* proto_item_add_subtree(proto_item *ti, gint idx);
/* Get a subtree under an item; returns tree pointer */
extern proto_tree* proto_item_get_subtree(proto_item *ti);
/* Get a parent item; returns item pointer */
extern proto_item* proto_item_get_parent(proto_item *ti);
/* Get Nth generation parent item; returns item pointer */
extern proto_item* proto_item_get_parent_nth(proto_item *ti, int gen);
/* Get a parent item of subtree; returns item pointer */
extern proto_item* proto_tree_get_parent(proto_tree *tree);

View File

@ -1,7 +1,7 @@
/* plugin_api_list.c
* Used to generate various included files for plugin API
*
* $Id: plugin_api_list.c,v 1.32 2004/03/25 09:17:11 guy Exp $
* $Id: plugin_api_list.c,v 1.33 2004/03/25 23:55:21 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -431,3 +431,6 @@ int get_ber_identifier(tvbuff_t *tvb, int offset, guint8 *class, gboolean *pc, g
int get_ber_length(tvbuff_t *tvb, int offset, guint32 *length, gboolean *ind);
proto_tree* proto_item_get_subtree(proto_item *ti);
proto_item* proto_tree_get_parent(proto_tree *tree);
proto_item* proto_item_get_parent(proto_item *ti);
proto_item* proto_item_get_parent_nth(proto_item *ti, int gen);
proto_item *get_ber_last_created_item(void);