4 # The first argument is the directory in which the source files live.
10 # The second argument is either "plugin" or "dissectors"; if it's
11 # "plugin", we build a plugin.c for a plugin, and if it's
12 # "dissectors", we build a register.c for libwireshark.
16 if [ "$registertype" = plugin ]
19 elif [ "$registertype" = dissectors ]
23 echo "Unknown output type '$registertype'" 1>&2
28 # All subsequent arguments are the files to scan.
31 echo '/* Do not modify this file. */' >${outfile}-tmp
32 echo '/* It is created automatically by the Makefile. */'>>${outfile}-tmp
33 if [ "$registertype" = plugin ]
35 cat <<"EOF" >>${outfile}-tmp
40 #include "moduleinfo.h"
41 /* plugins are DLLs */
43 #include "ws_symbol_export.h"
46 WS_DLL_PUBLIC_DEF const gchar version[] = VERSION;
48 /* Start the functions we need for the plugin stuff */
50 WS_DLL_PUBLIC_DEF void
51 plugin_register (void)
55 # Build code to call all the protocol registration routines.
65 grep '^proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
66 done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
75 grep '^void proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
76 done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
78 cat <<"EOF" >>${outfile}-tmp
81 register_all_protocols(register_cb cb, gpointer client_data)
85 # Build code to call all the protocol registration routines.
95 grep '^proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
96 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
105 grep '^void proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
106 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
109 echo '}' >>${outfile}-tmp
113 # Build code to call all the protocol handoff registration routines.
115 if [ "$registertype" = plugin ]
117 cat <<"EOF" >>${outfile}-tmp
118 WS_DLL_PUBLIC_DEF void
119 plugin_reg_handoff(void)
130 grep '^proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
131 done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
140 grep '^void proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
141 done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
143 cat <<"EOF" >>${outfile}-tmp
145 register_all_protocol_handoffs(register_cb cb, gpointer client_data)
156 grep '^proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
157 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
166 grep '^void proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
167 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
169 echo '}' >>${outfile}-tmp
170 if [ "$registertype" = plugin ]
172 echo '#endif' >>${outfile}-tmp
174 cat <<"EOF" >>${outfile}-tmp
175 gulong register_count(void)
178 proto_regs=`grep RA_REGISTER ${outfile}-tmp | wc -l`
179 handoff_regs=`grep RA_HANDOFF ${outfile}-tmp | wc -l`
180 echo " return $proto_regs + $handoff_regs;" >>${outfile}-tmp
181 echo '}' >>${outfile}-tmp
184 # Only overwrite outfile if it differs from newly generated file
185 diff ${outfile}-tmp ${outfile} >/dev/null || mv ${outfile}-tmp ${outfile}