In the final scene of the horror movie, just when you think the monster
[obnox/wireshark/wip.git] / make-reg-dotc
1 #! /bin/sh
2
3 #
4 # The first argument is the directory in which the source files live.
5 #
6 srcdir="$1"
7 shift
8
9 #
10 # All subsequent arguments are the files to scan.
11 #
12 rm -f register.c-tmp
13 echo '/* Do not modify this file.  */' >register.c-tmp
14 echo '/* It is created automatically by the Makefile.  */'>>register.c-tmp
15 echo '#include "register.h"' >>register.c-tmp
16
17 #
18 # Build code to call all the protocol registration routines.
19 #
20 echo 'void register_all_protocols(void) {' >>register.c-tmp
21 for f in "$@"
22 do
23         grep '^proto_register_[a-z_0-9A-Z]* *(' $srcdir/$f 2>/dev/null
24 done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/  {extern void \1 (void); \1 ();}/' >>register.c-tmp
25 for f in "$@"
26 do
27         grep '^void proto_register_[a-z_0-9A-Z]* *(' $srcdir/$f 2>/dev/null
28 done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/  {extern void \1 (void); \1 ();}/' >>register.c-tmp
29 echo '}' >>register.c-tmp
30
31 #
32 # Build code to call all the protocol handoff registration routines.
33 #
34 echo 'void register_all_protocol_handoffs(void) {' >>register.c-tmp
35 for f in "$@"
36 do
37         grep '^proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcdir/$f 2>/dev/null
38 done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/  {extern void \1 (void); \1 ();}/' >>register.c-tmp
39 for f in "$@"
40 do
41         grep '^void proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcdir/$f 2>/dev/null
42 done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/  {extern void \1 (void); \1 ();}/' >>register.c-tmp
43 echo '}' >>register.c-tmp
44 mv register.c-tmp register.c