aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/make-reg-dotc
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/make-reg-dotc')
-rwxr-xr-xepan/dissectors/make-reg-dotc79
1 files changed, 79 insertions, 0 deletions
diff --git a/epan/dissectors/make-reg-dotc b/epan/dissectors/make-reg-dotc
new file mode 100755
index 0000000000..a90019af05
--- /dev/null
+++ b/epan/dissectors/make-reg-dotc
@@ -0,0 +1,79 @@
+#! /bin/sh
+
+#
+# $Id$
+#
+
+#
+# The first argument is the output filename.
+#
+
+outfile="$1"
+shift
+
+#
+# The second argument is the directory in which the source files live.
+#
+srcdir="$1"
+shift
+
+#
+# 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
+echo '#include "register.h"' >>${outfile}-tmp
+
+#
+# Build code to call all the protocol registration routines.
+#
+echo 'void register_all_protocols(void) {' >>${outfile}-tmp
+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.
+#
+echo 'void register_all_protocol_handoffs(void) {' >>${outfile}-tmp
+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
+mv ${outfile}-tmp ${outfile}