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
44 #include "moduleinfo.h"
45 /* plugins are DLLs */
47 #include "ws_symbol_export.h"
50 WS_DLL_PUBLIC_DEF const gchar version[] = VERSION;
52 /* Start the functions we need for the plugin stuff */
54 WS_DLL_PUBLIC_DEF void
55 plugin_register (void)
59 # Build code to call all the protocol registration routines.
69 grep '^proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
70 done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
79 grep '^void proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
80 done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
82 cat <<"EOF" >>${outfile}-tmp
85 register_all_protocols
(register_cb cb
, gpointer client_data
)
89 # Build code to call all the protocol registration routines.
99 grep '^proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev
/null |
grep -v ';'
100 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
109 grep '^void proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev
/null |
grep -v ';'
110 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
113 echo '}' >>${outfile}-tmp
117 # Build code to call all the protocol handoff registration routines.
119 if [ "$registertype" = plugin
]
121 cat <<"EOF" >>${outfile}-tmp
122 WS_DLL_PUBLIC_DEF void
123 plugin_reg_handoff(void)
134 grep '^proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
135 done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
144 grep '^void proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';'
145 done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp
147 cat <<"EOF" >>${outfile}-tmp
149 register_all_protocol_handoffs
(register_cb cb
, gpointer client_data
)
160 grep '^proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev
/null |
grep -v ';'
161 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
170 grep '^void proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev
/null |
grep -v ';'
171 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
173 echo '}' >>${outfile}-tmp
174 if [ "$registertype" = plugin
]
176 echo '#endif' >>${outfile}-tmp
178 cat <<"EOF" >>${outfile}-tmp
179 gulong register_count(void)
182 proto_regs=`grep RA_REGISTER ${outfile}-tmp | wc -l`
183 handoff_regs=`grep RA_HANDOFF ${outfile}-tmp | wc -l`
184 echo " return $proto_regs + $handoff_regs;" >>${outfile}-tmp
185 echo '}' >>${outfile}-tmp
188 # Only overwrite outfile if it differs from newly generated file
189 diff ${outfile}-tmp ${outfile} >/dev/null || mv ${outfile}-tmp ${outfile}