From Xiao Xiangquan:
[obnox/wireshark/wip.git] / tap-stats_tree.c
index da4244b0a177872b62004da2d3de1a970fc7c27b..e9568b306c42c3e039ce10ed1f510cc46ca8e117 100644 (file)
 
 /* actually unused */
 struct _st_node_pres {
-       voiddummy;
+       void *dummy;
 };
 
 struct _tree_pres {
-       void* dummy;
+       void** dummy;
 };
 
 struct _tree_cfg_pres {
-       guint8* init_string;    
+       gchar *init_string;     
 };
 
-static void draw_stats_tree(void *psp) {
-       stats_tree *st = psp;
-       GString* s;
-       gchar* fmt;
-       stat_node* child;
+static void
+draw_stats_tree(void *psp)
+{
+       stats_tree *st = (stats_tree *)psp;
+       GString *s;
+       gchar *fmt;
+       stat_node *child;
        
        s = g_string_new("\n===================================================================\n");
        fmt = g_strdup_printf(" %%s%%-%us%%12s\t%%12s\t%%12s\n",stats_tree_branch_max_namelen(&st->root,0));
-       g_string_sprintfa(s,fmt,"",st->cfg->name,"value","rate","percent");
+       g_string_append_printf(s,fmt,"",st->cfg->name,"value","rate","percent");
        g_free(fmt);
-       g_string_sprintfa(s,"-------------------------------------------------------------------\n");
+       g_string_append_printf(s,"-------------------------------------------------------------------\n");
        
        for (child = st->root.children; child; child = child->next ) {
                stats_tree_branch_to_str(child,s,0);
@@ -69,18 +71,20 @@ static void draw_stats_tree(void *psp) {
        
 }
 
-static void  init_stats_tree(const char *optarg,void* userdata _U_) {
-       guint8* abbr = stats_tree_get_abbr(optarg);
+static void
+init_stats_tree(const char *optarg, void *userdata _U_)
+{
+       char *abbr = stats_tree_get_abbr(optarg);
        GString *error_string;
        stats_tree_cfg *cfg = NULL;
-       stats_treest = NULL;
+       stats_tree *st = NULL;
        
        if (abbr) {
                cfg = stats_tree_get_cfg_by_abbr(abbr);
 
                if (cfg != NULL) {
                        if (strncmp (optarg, cfg->pr->init_string, strlen(cfg->pr->init_string)) == 0){
-                               st = stats_tree_new(cfg,NULL,(char*)(optarg)+strlen(cfg->pr->init_string));
+                               st = stats_tree_new(cfg,NULL,optarg+strlen(cfg->pr->init_string));
                        } else {
                                report_failure("Wrong stats_tree (%s) found when looking at ->init_string",abbr);
                                return;
@@ -93,13 +97,14 @@ static void  init_stats_tree(const char *optarg,void* userdata _U_) {
                g_free(abbr);
                
        } else {
-               report_failure("could not obtain stats_tree abbr (%s) from grg '%s'",abbr,optarg);              
+               report_failure("could not obtain stats_tree abbr (%s) from arg '%s'",abbr,optarg);              
                return;
        }
        
        error_string = register_tap_listener(st->cfg->tapname,
                                             st,
                                             st->filter,
+                                            st->cfg->flags,
                                             stats_tree_reset,
                                             stats_tree_packet,
                                             draw_stats_tree);
@@ -113,17 +118,21 @@ static void  init_stats_tree(const char *optarg,void* userdata _U_) {
 
 }
 
-void register_stats_tree_tap (gpointer k _U_, gpointer v, gpointer p _U_) {
-       stats_tree_cfg* cfg = v;
+void
+register_stats_tree_tap (gpointer k _U_, gpointer v, gpointer p _U_)
+{
+       stats_tree_cfg *cfg = (stats_tree_cfg *)v;
        
-       cfg->pr = g_malloc(sizeof(tree_cfg_pres));
-       cfg->pr->init_string = g_strdup_printf("%s,tree",cfg->abbr);
+       cfg->pr = (tree_cfg_pres *)g_malloc(sizeof(tree_cfg_pres));
+       cfg->pr->init_string = g_strdup_printf("%s,tree", cfg->abbr);
 
        register_stat_cmd_arg(cfg->pr->init_string, init_stats_tree, NULL);
        
 }
 
-static void free_tree_presentation(stats_tree* st) {
+static void
+free_tree_presentation(stats_tree *st)
+{
        g_free(st->pr);
 }
 
@@ -131,7 +140,6 @@ static void free_tree_presentation(stats_tree* st) {
 void
 register_tap_listener_stats_tree_stat(void)
 {
-       stats_tree_presentation(register_stats_tree_tap,
-                                                       NULL, NULL, NULL, NULL, NULL,
-                                                       free_tree_presentation, NULL, NULL, NULL);
+       stats_tree_presentation(register_stats_tree_tap, NULL, NULL, NULL, NULL,
+                               NULL, free_tree_presentation, NULL, NULL, NULL);
 }