Un-#if out "dissect_beep_status()", to serve as a reminder to either get
[obnox/wireshark/wip.git] / make-reg-dotc
1 #! /bin/sh
2
3 #
4 # The first argument is the output filename.
5 #
6
7 outfile="$1"
8 shift
9
10 #
11 # The second argument is the directory in which the source files live.
12 #
13 srcdir="$1"
14 shift
15
16 #
17 # All subsequent arguments are the files to scan.
18 #
19 rm -f ${outfile}-tmp
20 echo '/* Do not modify this file.  */' >${outfile}-tmp
21 echo '/* It is created automatically by the Makefile.  */'>>${outfile}-tmp
22 echo '#include "register.h"' >>${outfile}-tmp
23
24 #
25 # Build code to call all the protocol registration routines.
26 #
27 echo 'void register_all_protocols(void) {' >>${outfile}-tmp
28 for f in "$@"
29 do
30         if [ -f $f ]
31         then
32                 srcfile=$f
33         else
34                 srcfile=$srcdir/$f
35         fi
36         grep '^proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
37 done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/  {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
38 for f in "$@"
39 do
40         if [ -f $f ]
41         then
42                 srcfile=$f
43         else
44                 srcfile=$srcdir/$f
45         fi
46         grep '^void proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
47 done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/  {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
48 echo '}' >>${outfile}-tmp
49
50 #
51 # Build code to call all the protocol handoff registration routines.
52 #
53 echo 'void register_all_protocol_handoffs(void) {' >>${outfile}-tmp
54 for f in "$@"
55 do
56         if [ -f $f ]
57         then
58                 srcfile=$f
59         else
60                 srcfile=$srcdir/$f
61         fi
62         grep '^proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
63 done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/  {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
64 for f in "$@"
65 do
66         if [ -f $f ]
67         then
68                 srcfile=$f
69         else
70                 srcfile=$srcdir/$f
71         fi
72         grep '^void proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
73 done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/  {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
74 echo '}' >>${outfile}-tmp
75 mv ${outfile}-tmp ${outfile}