Update minimum version requirement for GTK to 2.12.
[obnox/wireshark/wip.git] / tap-camelcounter.c
index 9b8fd039e04026a1ccbaa32b21337bc2566e8325..c922f198606c53084c62b2c2a98dba974a9d9484 100644 (file)
@@ -1,6 +1,9 @@
 /* tap_camelcounter.c
  * camel message counter for tshark
  * Copyright 2006 Florent DROUIN
+ *
+ * $Id$
+ *
  * This part of code is extracted from tap-h225counter.c from Lars Roland
  *
  * Wireshark - Network traffic analyzer
 #endif
 
 #include <string.h>
-#include "epan/proto.h"
+#include "epan/packet.h"
 #include "epan/packet_info.h"
 #include "epan/tap.h"
 #include "epan/value_string.h"
-#include "register.h"
 #include "epan/stat_cmd_args.h"
 #include "epan/asn1.h"
 #include "epan/camel-persistentdata.h"
@@ -46,7 +48,7 @@ void register_tap_listener_camelcounter(void);
 
 /* used to keep track of the statistics for an entire program interface */
 struct camelcounter_t {
-  char *filter; 
+  char *filter;
   guint32 camel_msg[camel_MAX_NUM_OPR_CODES];
 };
 
@@ -59,14 +61,14 @@ static void camelcounter_reset(void *phs)
 
 static int camelcounter_packet(void *phs,
                               packet_info *pinfo _U_,
-                              epan_dissect_t *edt _U_, 
+                              epan_dissect_t *edt _U_,
                               const void *phi)
 {
   struct camelcounter_t * p_counter =(struct camelcounter_t *)phs;
   const struct camelsrt_info_t * pi=phi;
   if (pi->opcode != 255)
     p_counter->camel_msg[pi->opcode]++;
-  
+
   return 1;
 }
 
@@ -84,7 +86,7 @@ static void camelcounter_draw(void *phs)
     if(p_counter->camel_msg[i]!=0) {
       printf("%30s ", val_to_str(i,camel_opr_code_strings,"Unknown message "));
       printf("%6d\n", p_counter->camel_msg[i]);
-    } 
+    }
   } /* Message Type */
   printf("------------------------------------------\n");
 }
@@ -92,41 +94,24 @@ static void camelcounter_draw(void *phs)
 static void camelcounter_init(const char *optarg, void* userdata _U_)
 {
   struct camelcounter_t *p_camelcounter;
-  const char *filter=NULL;
-  const char *emptyfilter=""; 
   GString *error_string;
 
-  if(!strncmp(optarg,"camel,counter,",13)){
-    filter=optarg+13;
-  } else {
-    filter=NULL;
-  }
-
   p_camelcounter = g_malloc(sizeof(struct camelcounter_t));
-  if(filter){
-    p_camelcounter->filter=g_malloc(strlen(filter)+1);
-    strcpy(p_camelcounter->filter,filter);
+  if(!strncmp(optarg,"camel,counter,",13)){
+    p_camelcounter->filter=g_strdup(optarg+13);
   } else {
     p_camelcounter->filter=NULL;
   }
-  
+
   camelcounter_reset(p_camelcounter);
 
-  if (filter) {
-    error_string=register_tap_listener("CAMEL",
-                                      p_camelcounter,
-                                      filter,
-                                      NULL,
-                                      camelcounter_packet,
-                                      camelcounter_draw);
-  } else {
-    error_string=register_tap_listener("CAMEL",
-                                      p_camelcounter,
-                                      emptyfilter,
-                                      NULL,
-                                      camelcounter_packet,
-                                      camelcounter_draw);
-  }
+  error_string=register_tap_listener("CAMEL",
+                                    p_camelcounter,
+                                    p_camelcounter->filter,
+                                    0,
+                                    NULL,
+                                    camelcounter_packet,
+                                    camelcounter_draw);
 
   if(error_string){
     /* error, we failed to attach to the tap. clean up */