summaryrefslogtreecommitdiff
path: root/tools/make-dissector-reg
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2006-04-20 02:21:28 +0000
committerGuy Harris <guy@alum.mit.edu>2006-04-20 02:21:28 +0000
commitfd1cec89175ac70bdac07e0de8087eca9bd49026 (patch)
treefceb11315955f31d51a8e2b2a8d67bb5bb1e04d7 /tools/make-dissector-reg
parent4a67045746756d775deedbbc949fbf786c2c4c8f (diff)
downloadwireshark-fd1cec89175ac70bdac07e0de8087eca9bd49026.tar.gz
Rename "make-reg-dotc" to "make-dissector-reg", and do the same for the
Python versions, as it no longer makes only "register.c", it can also make a "plugin.c" file for a plugin. When making "plugin.c", there's no need to include "register.h", as it's not defining any functions declared there. svn path=/trunk/; revision=17919
Diffstat (limited to 'tools/make-dissector-reg')
-rwxr-xr-xtools/make-dissector-reg133
1 files changed, 133 insertions, 0 deletions
diff --git a/tools/make-dissector-reg b/tools/make-dissector-reg
new file mode 100755
index 0000000000..fe403cc5f6
--- /dev/null
+++ b/tools/make-dissector-reg
@@ -0,0 +1,133 @@
+#! /bin/sh
+
+#
+# $Id$
+#
+
+#
+# The first argument is the directory in which the source files live.
+#
+srcdir="$1"
+shift
+
+#
+# The second argument is either "plugin" or "dissectors"; if it's
+# "plugin", we build a plugin.c for a plugin, and if it's
+# "dissectors", we build a register.c for libethereal.
+#
+registertype="$1"
+shift
+if [ "$registertype" = plugin ]
+then
+ outfile="plugin.c"
+elif [ "$registertype" = dissectors ]
+then
+ outfile="register.c"
+else
+ echo "Unknown output type '$registertype'" 1>&2
+ exit 1
+fi
+
+#
+# All subsequent arguments are the files to scan.
+#
+rm -f ${outfile}-tmp
+echo '/* Do not modify this file. */' >${outfile}-tmp
+echo '/* It is created automatically by the Makefile. */'>>${outfile}-tmp
+if [ "$registertype" = plugin ]
+then
+ cat <<"EOF" >>${outfile}-tmp
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <gmodule.h>
+
+#include "moduleinfo.h"
+
+#ifndef ENABLE_STATIC
+G_MODULE_EXPORT const gchar version[] = VERSION;
+
+/* Start the functions we need for the plugin stuff */
+
+G_MODULE_EXPORT void
+plugin_register (void)
+{
+EOF
+else
+ cat <<"EOF" >>${outfile}-tmp
+#include "register.h"
+void
+register_all_protocols(void)
+{
+EOF
+fi
+
+#
+# Build code to call all the protocol registration routines.
+#
+for f in "$@"
+do
+ if [ -f $f ]
+ then
+ srcfile=$f
+ else
+ srcfile=$srcdir/$f
+ fi
+ grep '^proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
+done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
+for f in "$@"
+do
+ if [ -f $f ]
+ then
+ srcfile=$f
+ else
+ srcfile=$srcdir/$f
+ fi
+ grep '^void proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
+done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
+echo '}' >>${outfile}-tmp
+
+#
+# Build code to call all the protocol handoff registration routines.
+#
+if [ "$registertype" = plugin ]
+then
+ cat <<"EOF" >>${outfile}-tmp
+G_MODULE_EXPORT void
+plugin_reg_handoff(void)
+{
+EOF
+else
+ cat <<"EOF" >>${outfile}-tmp
+void
+register_all_protocol_handoffs(void)
+{
+EOF
+fi
+for f in "$@"
+do
+ if [ -f $f ]
+ then
+ srcfile=$f
+ else
+ srcfile=$srcdir/$f
+ fi
+ grep '^proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
+done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
+for f in "$@"
+do
+ if [ -f $f ]
+ then
+ srcfile=$f
+ else
+ srcfile=$srcdir/$f
+ fi
+ grep '^void proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
+done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
+echo '}' >>${outfile}-tmp
+if [ "$registertype" = plugin ]
+then
+ echo '#endif' >>${outfile}-tmp
+fi
+mv ${outfile}-tmp ${outfile}