wireshark/make-reg-dotc
Guy Harris 9fd68ec37f "test -e" is documented in the Solaris 2.6 man page, but doesn't seem to
work, and it's not even documented in the Solaris 2.5.1 man page; don't
use "-e" to test for the existence of a file, use "-f", which is
documented in the 2.5.1 man page and works.

svn path=/trunk/; revision=2247
2000-08-10 19:43:07 +00:00

69 lines
1.7 KiB
Bash
Executable file

#! /bin/sh
#
# The first argument is the directory in which the source files live.
#
srcdir="$1"
shift
#
# All subsequent arguments are the files to scan.
#
rm -f register.c-tmp
echo '/* Do not modify this file. */' >register.c-tmp
echo '/* It is created automatically by the Makefile. */'>>register.c-tmp
echo '#include "register.h"' >>register.c-tmp
#
# Build code to call all the protocol registration routines.
#
echo 'void register_all_protocols(void) {' >>register.c-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
done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>register.c-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
done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>register.c-tmp
echo '}' >>register.c-tmp
#
# Build code to call all the protocol handoff registration routines.
#
echo 'void register_all_protocol_handoffs(void) {' >>register.c-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
done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>register.c-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
done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>register.c-tmp
echo '}' >>register.c-tmp
mv register.c-tmp register.c