8 # The first argument is the directory in which the source files live.
14 # The second argument is either "plugin" or "dissectors"; if it's
15 # "plugin", we build a plugin.c for a plugin, and if it's
16 # "dissectors", we build a register.c for libwireshark.
20 if [ "$registertype" = plugin ]
23 elif [ "$registertype" = dissectors ]
27 echo "Unknown output type '$registertype'" 1>&2
32 # All subsequent arguments are the files to scan.
35 echo '/* Do not modify this file. */' >${outfile}-tmp
36 echo '/* It is created automatically by the Makefile. */'>>${outfile}-tmp
37 if [ "$registertype" = plugin ]
39 cat <<"EOF" >>${outfile}-tmp
46 #include "moduleinfo.h"
49 G_MODULE_EXPORT const gchar version[] = VERSION;
51 /* Start the functions we need for the plugin stuff */
54 plugin_register (void)
58 # Build code to call all the protocol registration routines.
68 grep '^proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
69 done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
78 grep '^void proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
79 done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
81 cat <<"EOF" >>${outfile}-tmp
84 register_all_protocols(register_cb cb, gpointer client_data)
88 # Build code to call all the protocol registration routines.
98 grep '^proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
99 done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); if(cb) (*cb)(RA_REGISTER, \"\1\", client_data); \1 ();}/' >>${outfile}-tmp
108 grep '^void proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
109 done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); if(cb) (*cb)(RA_REGISTER, \"\1\", client_data); \1 ();}/' >>${outfile}-tmp
112 echo '}' >>${outfile}-tmp
116 # Build code to call all the protocol handoff registration routines.
118 if [ "$registertype" = plugin ]
120 cat <<"EOF" >>${outfile}-tmp
122 plugin_reg_handoff(void)
133 grep '^proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
134 done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
143 grep '^void proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
144 done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
146 cat <<"EOF" >>${outfile}-tmp
148 register_all_protocol_handoffs(register_cb cb, gpointer client_data)
159 grep '^proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
160 done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); if(cb) (*cb)(RA_HANDOFF, \"\1\", client_data); \1 ();}/' >>${outfile}-tmp
169 grep '^void proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
170 done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); if(cb) (*cb)(RA_HANDOFF, \"\1\", client_data); \1 ();}/' >>${outfile}-tmp
172 echo '}' >>${outfile}-tmp
173 if [ "$registertype" = plugin ]
175 echo '#endif' >>${outfile}-tmp
177 cat <<"EOF" >>${outfile}-tmp
178 gulong register_count(void)
181 proto_regs=`grep RA_REGISTER ${outfile}-tmp | wc -l`
182 handoff_regs=`grep RA_HANDOFF ${outfile}-tmp | wc -l`
183 echo " return $proto_regs + $handoff_regs;" >>${outfile}-tmp
184 echo '}' >>${outfile}-tmp
186 mv ${outfile}-tmp ${outfile}