Add a counter : "enabled_plugins_number", to record how many plugins are
authoroabad <oabad@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 31 Mar 2000 21:42:24 +0000 (21:42 +0000)
committeroabad <oabad@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 31 Mar 2000 21:42:24 +0000 (21:42 +0000)
enabled. The counter is incremented in enable_plugin() and decremented
in disable_plugin().
In add_packet_to_packet_list(), we check this counter (instead of
plugin_list) to see if there is at least one enabled plugin. If this is
the case, we must build the protocol tree.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1770 f5534014-38df-0310-8fa8-9805f1628bb7

file.c
plugins.c
plugins.h

diff --git a/file.c b/file.c
index 32dbcb62cca540fe7ac307815f48595998aac1cf..1d5c7029bf06e7b6ebb3c73f3b2f83c5ac320a13 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
 /* file.c
  * File I/O routines
  *
- * $Id: file.c,v 1.173 2000/03/28 08:11:43 guy Exp $
+ * $Id: file.c,v 1.174 2000/03/31 21:42:23 oabad Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -550,7 +550,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, const u_char *buf
   }
   else {
 #ifdef HAVE_PLUGINS
-       if (plugin_list)
+       if (enabled_plugins_number > 0)
            protocol_tree = proto_tree_create_root();
 #endif
        dissect_packet(buf, fdata, protocol_tree);
index 131892e51d91346a6bcb8c4595a2f8b696ede5f1..ff764480c1f20e1ea2a196e89cd8b41cf6fe197d 100644 (file)
--- a/plugins.c
+++ b/plugins.c
@@ -1,7 +1,7 @@
 /* plugins.c
  * plugin routines
  *
- * $Id: plugins.c,v 1.11 2000/03/15 19:09:23 guy Exp $
+ * $Id: plugins.c,v 1.12 2000/03/31 21:42:24 oabad Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -64,6 +64,7 @@ plugin_address_table_t        patable;
 
 /* linked list of all plugins */
 plugin *plugin_list;
+guint32 enabled_plugins_number;
 
 #ifdef WIN32
 static gchar std_plug_dir[] = "c:/program files/ethereal/plugins/0.8";
@@ -148,6 +149,7 @@ enable_plugin(const gchar *name, const gchar *version)
        if (!strcmp(pt_plug->name, name) && !strcmp(pt_plug->version, version))
        {
            pt_plug->enabled = TRUE;
+           enabled_plugins_number++;
            return pt_plug;
        }
        pt_plug = pt_plug->next;
@@ -171,6 +173,7 @@ disable_plugin(const gchar *name, const gchar *version)
        if (!strcmp(pt_plug->name, name) && !strcmp(pt_plug->version, version))
        {
            pt_plug->enabled = FALSE;
+           enabled_plugins_number--;
            return pt_plug;
        }
        pt_plug = pt_plug->next;
@@ -447,6 +450,7 @@ init_plugins()
 
     if (plugin_list == NULL)      /* ensure init_plugins is only run once */
     {
+       enabled_plugins_number = 0;
 
 #ifdef PLUGINS_NEED_ADDRESS_TABLE
        /* Intialize address table */
index ea4d84f33c4d84460a615d5609ca406a751f30e5..abf1152cd59c832c7be16af40bdd5f0758c17cf3 100644 (file)
--- a/plugins.h
+++ b/plugins.h
@@ -1,7 +1,7 @@
 /* plugins.h
  * definitions for plugins structures
  *
- * $Id: plugins.h,v 1.5 2000/01/15 00:22:34 gram Exp $
+ * $Id: plugins.h,v 1.6 2000/03/31 21:42:24 oabad Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -64,6 +64,7 @@ typedef struct _plugin {
 } plugin;
 
 extern plugin *plugin_list;
+extern guint32 enabled_plugins_number;
 
 int add_plugin(void *, gchar *, gchar *, gchar *, gchar *, dfilter *,
                  void (*) (const u_char *, int, frame_data *, proto_tree *));