Update to V9.0.0 (2009-12)
[obnox/wireshark/wip.git] / tap-camelcounter.c
index fa489c1ace8b0693ff88866f2d15298d447188f9..18df797130c913a1649c112af7b0c63f40f5edae 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
@@ -92,41 +95,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 */