Ethereal-dev: Re: [Ethereal-dev] Next Release

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Olivier Abad <oabad@xxxxxxx>
Date: Tue, 10 Jul 2001 01:31:45 +0200
On Mon, Jul 09, 2001 at 06:53:38PM -0400, Ed Warnicke wrote:
> Please look at what I've done recently to the MGCP and Gryphon
> plugins.
> 
> The way they are handled currently will allow a static ethereal binary
> to be compiled INCLUDING the dissectors in the protocols.

You're right. Here is a better patch.

Olivier
-- 
Inside, I'm already SOBBING!
--- ethereal/ethereal_gen.py	Sun Jul  1 19:34:52 2001
+++ ethereal.build/ethereal_gen.py	Tue Jul 10 01:23:00 2001
@@ -182,6 +182,7 @@
 
         self.gen_proto_register()
         self.gen_proto_reg_handoff(oplist)
+        self.gen_plugin_init()
 
         #self.dumpvars()                 # debug
         
@@ -837,6 +838,13 @@
 
 
     #
+    # generate code for plugin initialisation
+    #
+
+    def gen_plugin_init(self):
+        self.st.out(self.template_plugin_init, description=self.description, protocol_name=self.protoname, dissector_name=self.dissname)
+
+    #
     # generate  register_giop_user_module code, and register only
     # unique interfaces that contain operations. Also output
     # a heuristic register in case we want to use that.
@@ -1071,6 +1079,31 @@
     
 
 
+    #
+    # plugin_init and plugin_reg_handoff templates
+    #
+
+    template_plugin_init = """
+
+#ifndef __ETHEREAL_STATIC__
+
+G_MODULE_EXPORT void
+plugin_reg_handoff(void){
+   proto_register_handoff_giop_@dissector_name@();
+}
+
+G_MODULE_EXPORT void
+plugin_init(plugin_address_table_t *pat){
+   /* initialise the table of pointers needed in Win32 DLLs */
+   plugin_address_table_init(pat);
+   if (proto_@dissector_name@ == -1) {
+     proto_register_giop_@dissector_name@();
+   }
+}
+
+#endif
+
+"""
 
     #
     # proto_register_<dissector name>(void) templates
@@ -1496,8 +1529,11 @@
 # include "config.h"
 #endif
 
+#include "plugins/plugin_api.h"
+
 #include <stdio.h>
 #include <stdlib.h>
+#include <gmodule.h>
 
 #ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
@@ -1521,6 +1557,10 @@
 #include "packet.h"
 #include "proto.h"
 #include "packet-giop.h"
+
+#ifndef __ETHEREAL_STATIC__
+G_MODULE_EXPORT const gchar version[] = "0.0.1";
+#endif
 
 """