Redesigned the menu structure of the former statistics stuff,
[obnox/wireshark/wip.git] / make-tapreg-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
23 #
24 # Build code to call all the tap listener registration routines.
25 #
26 echo 'void register_all_tap_listeners(void) {' >>${outfile}-tmp
27 for f in "$@"
28 do
29         if [ -f $f ]
30         then
31                 srcfile=$f
32         else
33                 srcfile=$srcdir/$f
34         fi
35         grep '^register_tap_listener_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';' | sed -e 's/(.*//'
36 done | while read func; do
37         echo "  { extern void $func (void);" >>${outfile}-tmp
38         echo "    $func ();}" >>${outfile}-tmp
39 done 
40 echo '}' >>${outfile}-tmp
41
42 mv ${outfile}-tmp ${outfile}