Follow up to rev 34073: Since "-b files:0" is no longer necessary to
[obnox/wireshark/wip.git] / tap-httpstat.c
index 6d4db1306376273d73cc79acb18daf29f19efc24..b2f5a1676c1a89dc2f9093bb560e68126c8fc982 100644 (file)
@@ -3,8 +3,8 @@
  *
  * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  * 
  * This program is free software; you can redistribute it and/or
@@ -32,6 +32,7 @@
 #include "epan/packet_info.h"
 #include "epan/value_string.h"
 #include <epan/tap.h>
+#include <epan/stat_cmd_args.h>
 #include "register.h"
 #include <epan/dissectors/packet-http.h>
 
@@ -145,7 +146,7 @@ static void
 http_draw_hash_responses( gint * key _U_ , http_response_code_t *data, char * format)
 {
        if (data==NULL) {
-               g_warning("C'est quoi ce borderl key=%d\n", *key);
+               g_warning("No data available, key=%d\n", *key);
                exit(EXIT_FAILURE);
        }
        if (data->packets==0)
@@ -180,10 +181,10 @@ static void
 httpstat_reset(void *psp  )
 {
        httpstat_t *sp=psp;
-       if (!sp) {
-               g_hash_table_foreach( sp->hash_responses, (GHFunc)http_reset_hash_responses, NULL);
-               g_hash_table_foreach( sp->hash_responses, (GHFunc)http_reset_hash_requests, NULL);
-       }
+
+       g_hash_table_foreach( sp->hash_responses, (GHFunc)http_reset_hash_responses, NULL);
+       g_hash_table_foreach( sp->hash_requests, (GHFunc)http_reset_hash_requests, NULL);
+
 }
 
 static int
@@ -280,7 +281,7 @@ httpstat_draw(void *psp  )
 /* When called, this function will create a new instance of gtk_httpstat.
  */
 static void
-gtk_httpstat_init(const char *optarg)
+gtk_httpstat_init(const char *optarg,void* userdata _U_)
 {
        httpstat_t *sp;
        const char *filter=NULL;
@@ -294,8 +295,7 @@ gtk_httpstat_init(const char *optarg)
        
        sp = g_malloc( sizeof(httpstat_t) );
        if(filter){
-               sp->filter=g_malloc(strlen(filter)+1);
-               strcpy(sp->filter,filter);
+               sp->filter=g_strdup(filter);
        } else {
                sp->filter=NULL;
        }
@@ -306,6 +306,7 @@ gtk_httpstat_init(const char *optarg)
                        "http",
                        sp,
                        filter,
+                       0,
                        httpstat_reset,
                        httpstat_packet,
                        httpstat_draw);
@@ -313,7 +314,7 @@ gtk_httpstat_init(const char *optarg)
                /* error, we failed to attach to the tap. clean up */
                g_free(sp->filter);
                g_free(sp);
-               fprintf (stderr, "tethereal: Couldn't register http,stat tap: %s\n",
+               fprintf (stderr, "tshark: Couldn't register http,stat tap: %s\n",
                                error_string->str);
                g_string_free(error_string, TRUE);
                exit(1);
@@ -325,5 +326,5 @@ gtk_httpstat_init(const char *optarg)
 void
 register_tap_listener_gtkhttpstat(void)
 {
-       register_tap_listener_cmd_arg("http,stat,", gtk_httpstat_init);
+       register_stat_cmd_arg("http,stat,", gtk_httpstat_init,NULL);
 }