aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorAlexis La Goutte <alexis.lagoutte@gmail.com>2013-12-08 11:09:54 +0000
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2013-12-08 11:09:54 +0000
commit006f84a565f2581e4e1e9aefecceac64658466e8 (patch)
tree6225f30bfcc97374e967bf5cfad6cca66dbc6566 /epan
parent4ed05f22b80ebb69bcebce5bb97d04ae42e96ffd (diff)
From Deon van der Westhuysen via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9452
Patch: Stats_tree enhancements for sorting, averages and burst rate Add sort, save-as and new columns to Qt ui, remove old functions stats_tree.c / stats_tree_priv.h: Make all columns sortable. Remove unneeded functions stats_tree_get_strs_from_node, stats_tree_branch_to_str and stats_tree_is_sortable_column. stats_tree_stat.c: Set all columns sortable. stats_tree_dialog.cpp / stats_tree_dialog.h: Add new stats_tree columns. Make columns sortable. Remove copy to csv and copy to yaml buttons. Add copy to clipboard as plain text and save as buttons. stats_tree_dialog.ui: Remove copy to csv and copy to yaml buttons. Add copy to clipboard as plain text and save as buttons. Only define one column in ui, rest are added dynmically. From me : fix trailing whitespace svn path=/trunk/; revision=53848
Diffstat (limited to 'epan')
-rw-r--r--epan/stats_tree.c98
-rw-r--r--epan/stats_tree_priv.h21
2 files changed, 8 insertions, 111 deletions
diff --git a/epan/stats_tree.c b/epan/stats_tree.c
index 0d4f21382d..48bdfc9812 100644
--- a/epan/stats_tree.c
+++ b/epan/stats_tree.c
@@ -62,34 +62,6 @@ enum _stat_tree_columns {
/* used to contain the registered stat trees */
static GHashTable *registry = NULL;
-/* writes into the buffers pointed by value, rate and percent
- the string representations of a node*/
-/*** DEPRECIATED ***/
-extern void
-stats_tree_get_strs_from_node(const stat_node *node, gchar *value, gchar *rate, gchar *percent)
-{
- float f;
-
- if (value) g_snprintf(value,NUM_BUF_SIZE,"%u",node->counter);
-
- if (rate) {
- *rate = '\0';
- if (node->st->elapsed > 0.0) {
- f = ((float)node->counter) / (float)node->st->elapsed;
- g_snprintf(rate,NUM_BUF_SIZE,"%f",f);
- }
- }
-
- if (percent) {
- *percent = '\0';
- if (node->parent->counter > 0) {
- f = (float)(((float)node->counter * 100.0) / node->parent->counter);
- g_snprintf(percent,NUM_BUF_SIZE,"%.2f%%",f);
- }
- }
-}
-
-
/* a text representation of a node
if buffer is NULL returns a newly allocated string */
extern gchar*
@@ -132,53 +104,6 @@ stats_tree_branch_max_namelen(const stat_node *node, guint indent)
return maxlen;
}
-static gchar *format;
-
-/* populates the given GString with a tree representation of a branch given by node,
-using indent spaces as initial indentation */
-/*** DEPRECIATED ***/
-extern void
-stats_tree_branch_to_str(const stat_node *node, GString *s, guint indent)
-{
- stat_node *child;
- static gchar indentation[INDENT_MAX+1];
- static gchar value[NUM_BUF_SIZE];
- static gchar rate[NUM_BUF_SIZE];
- static gchar percent[NUM_BUF_SIZE];
-
- guint i = 0;
-
- if (indent == 0) {
- format = g_strdup_printf(" %%s%%-%us%%12s %%12s %%12s\n",stats_tree_branch_max_namelen(node,0));
- }
-
- stats_tree_get_strs_from_node(node, value, rate, percent);
-
- indent = indent > INDENT_MAX ? INDENT_MAX : indent;
-
- /* fill indentation with indent spaces */
- if (indent > 0) {
- while(i<indent)
- indentation[i++] = ' ';
- }
-
- indentation[i] = '\0';
-
- g_string_append_printf(s,format,
- indentation,node->name,value,rate,percent);
-
- if (node->children) {
- for (child = node->children; child; child = child->next ) {
- stats_tree_branch_to_str(child,s,indent+1);
- }
- }
-
- if (indent == 0) {
- g_free(format);
- }
-}
-
-
/* frees the resources allocated by a stat_tree node */
static void
free_stat_node(stat_node *node)
@@ -567,7 +492,7 @@ new_stat_node(stats_tree *st, const gchar *name, int parent_id,
node->bt = node->bh;
node->bcount = 0;
node->max_burst = 0;
- node->burst_time = -1;
+ node->burst_time = -1.0;
node->name = g_strdup(name);
node->children = NULL;
@@ -1106,20 +1031,6 @@ stats_tree_get_column_size (gint col_index)
return 0; /* invalid column */
}
-extern gboolean
-stats_tree_is_sortable_column (gint col_index)
-{
- switch (col_index) {
- case COL_NAME:
- case COL_COUNT:
- case COL_AVERAGE:
- case COL_MIN:
- case COL_MAX:
- case COL_BURSTRATE: return TRUE;
- default: return FALSE;
- }
-}
-
extern gchar**
stats_tree_get_values_from_node (const stat_node* node)
{
@@ -1181,6 +1092,8 @@ stats_tree_sort_compare (const stat_node *a, const stat_node *b, gint sort_colum
}
break;
+ case COL_RATE:
+ case COL_PERCENT:
case COL_COUNT: result = a->counter - b->counter;
break;
@@ -1206,8 +1119,11 @@ stats_tree_sort_compare (const stat_node *a, const stat_node *b, gint sort_colum
case COL_BURSTRATE: result = a->max_burst - b->max_burst;
break;
+ case COL_BURSTTIME: result = (a->burst_time>b->burst_time)?1:((a->burst_time<b->burst_time)?-1:0);
+ break;
+
default:
- /* see stats_tree_is_sortable_column */
+ /* no sort comparison found for column - must update this switch statement */
g_assert_not_reached();
}
diff --git a/epan/stats_tree_priv.h b/epan/stats_tree_priv.h
index 9a89ac9c6d..bc79d4df59 100644
--- a/epan/stats_tree_priv.h
+++ b/epan/stats_tree_priv.h
@@ -219,29 +219,13 @@ WS_DLL_PUBLIC stats_tree_cfg *stats_tree_get_cfg_by_abbr(const char *abbr);
caller should free returned list with g_list_free() */
WS_DLL_PUBLIC GList *stats_tree_get_cfg_list(void);
-/** extracts node data as strings from a stat_node into
- the buffers given by value, rate and precent
- if NULL they are ignored
-
- DO NOT USE FOR NEW CODE. Use stats_tree_get_values_from_node() instead */
-WS_DLL_PUBLIC void stats_tree_get_strs_from_node(const stat_node *node,
- gchar *value,
- gchar *rate,
- gchar *percent);
-
-/** populates the given GString with a tree representation of a branch given by node,
- using indent spaces as indentation */
-WS_DLL_PUBLIC void stats_tree_branch_to_str(const stat_node *node,
- GString *s,
- guint indent);
-
/** used to calcuate the size of the indentation and the longest string */
WS_DLL_PUBLIC guint stats_tree_branch_max_namelen(const stat_node *node, guint indent);
/** a text representation of a node,
if buffer is NULL returns a newly allocated string */
WS_DLL_PUBLIC gchar *stats_tree_node_to_str(const stat_node *node,
- gchar *buffer, guint len);
+ gchar *buffer, guint len);
/** get the display name for the stats_tree (or node name) based on the
st_sort_showfullname preference. If not set remove everything before
@@ -260,9 +244,6 @@ WS_DLL_PUBLIC const gchar* stats_tree_get_column_name (gint index);
/** returns the maximum number of characters in the value of a column */
WS_DLL_PUBLIC gint stats_tree_get_column_size (gint index);
-/** returns TRUE is the the column name for a given column index can be sorted*/
-WS_DLL_PUBLIC gboolean stats_tree_is_sortable_column (gint index);
-
/** returns the formatted column values for the current node
as array of gchar*. Caller must free entries and free array */
WS_DLL_PUBLIC gchar** stats_tree_get_values_from_node (const stat_node* node);