aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>2001-03-02 23:10:12 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>2001-03-02 23:10:12 +0000
commit540f56499354402291fc3ae4e2c276fb874def6a (patch)
tree1776d21c5cbf19ab2f67611bcb5a6f47374c23ec /epan
parent22e8d3d18feb09e46f9be3729214be2f90304be2 (diff)
Calculate the height and width of m_r_font globally, since various
routines need it. When a user clicks on a hex digit or on the corresponding character (the "text dump" portion) in the hex dump, find the field in the proto_tree that the byte corresponds to, expand the GtkCTree so that the field is viewable, select the field, and center it vertically. LanAlyzer has this feature, and I've missed it in Ethereal. svn path=/trunk/; revision=3096
Diffstat (limited to 'epan')
-rw-r--r--epan/proto.c52
-rw-r--r--epan/proto.h5
2 files changed, 55 insertions, 2 deletions
diff --git a/epan/proto.c b/epan/proto.c
index a64b3950cf..82afb5098c 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.11 2001/03/01 20:24:05 gram Exp $
+ * $Id: proto.c,v 1.12 2001/03/02 23:10:11 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -2586,6 +2586,56 @@ proto_get_finfo_ptr_array(proto_tree *tree, int id)
return sinfo.result.ptr_array;
}
+
+
+
+typedef struct {
+ guint offset;
+ field_info *finfo;
+} offset_search_t;
+
+static gboolean
+check_for_offset(GNode *node, gpointer data)
+{
+ field_info *fi = node->data;
+ offset_search_t *offsearch = data;
+
+ /* !fi == the top most container node which holds nothing */
+ if (fi && fi->visible) {
+ if (offsearch->offset >= fi->start &&
+ offsearch->offset <= (fi->start + fi->length)) {
+
+ offsearch->finfo = fi;
+ return FALSE; /* keep traversing */
+ }
+ }
+ return FALSE; /* keep traversing */
+}
+
+/* Search a proto_tree backwards (from leaves to root) looking for the field
+ * whose start/length occupies 'offset' */
+/* XXX - I couldn't find an easy way to search backwards, so I search
+ * forwards, w/o stopping. Therefore, the last finfo I find will the be
+ * the one I want to return to the user. This algorithm is inefficient
+ * and could be re-done, but I'd have to handle all the children and
+ * siblings of each node myself. When I have more time I'll do that.
+ * (yeah right) */
+field_info*
+proto_find_field_from_offset(proto_tree *tree, guint offset)
+{
+ offset_search_t offsearch;
+
+ offsearch.offset = offset;
+ offsearch.finfo = NULL;
+
+ g_node_traverse((GNode*)tree, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+ check_for_offset, &offsearch);
+
+ return offsearch.finfo;
+}
+
+
+
/* Dumps the contents of the registration database to stdout. An indepedent program can take
diff --git a/epan/proto.h b/epan/proto.h
index fa07c89040..6aa31830f9 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -1,7 +1,7 @@
/* proto.h
* Definitions for protocol display
*
- * $Id: proto.h,v 1.7 2001/02/13 18:34:49 guy Exp $
+ * $Id: proto.h,v 1.8 2001/03/02 23:10:11 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -557,4 +557,7 @@ hfinfo_bitwidth(header_field_info *hfinfo);
char*
proto_alloc_dfilter_string(field_info *finfo, guint8 *pd);
+field_info*
+proto_find_field_from_offset(proto_tree *tree, guint offset);
+
#endif /* proto.h */