# routines must start in column zero, or must be preceded only by
# "void " starting in column zero, and must not be inside #if.
#
-# The shell script runs slowly, as multiple greps and seds are run
-# for each input file; this is especially slow on Windows. Therefore,
-# if Python is present (as indicated by PYTHON being defined), we run
-# a faster Python script to do that work instead.
-#
# The first argument is the name of the file to write.
# The second argument is the directory in which the source files live.
# All subsequent arguments are the files to scan.
#
-!IFDEF PYTHON
-tshark-tap-register.c: $(TSHARK_TAP_SRC) tools/make-dissector-reg.py
- @echo Making tshark-tap-register.c (using python)
- @$(PYTHON) "tools/make-dissector-reg.py" . taps $(TSHARK_TAP_SRC)
-!ELSE
tshark-tap-register.c: $(TSHARK_TAP_SRC) make-tapreg-dotc
@echo Making tshark-tap-register.c
@$(SH) make-tapreg-dotc tshark-tap-register.c . $(TSHARK_TAP_SRC)
-!ENDIF
text2pcap-scanner.c : text2pcap-scanner.l
$(LEX) -otext2pcap-scanner.c text2pcap-scanner.l
tmp_filename = "register.c-tmp"
final_filename = "register.c"
cache_filename = "register-cache.pkl"
-elif registertype == "taps":
- tmp_filename = "tshark-tap-register.c-tmp"
- final_filename = "tshark-tap-register.c"
- cache_filename = "tap-cache.pkl"
else:
print "Unknown output type '%s'" % registertype
sys.exit(1)
regs = {
'proto_reg': [],
'handoff_reg': [],
- 'tap_reg': [],
}
# For those that don't know Python, r"" indicates a raw string,
handoff_regex0 = r"^(?P<symbol>proto_reg_handoff_[_A-Za-z0-9]+)\s*\([^;]+$"
handoff_regex1 = r"void\s+(?P<symbol>proto_reg_handoff_[_A-Za-z0-9]+)\s*\([^;]+$"
-tap_regex0 = r"^(?P<symbol>register_tap_listener_[_A-Za-z0-9]+)\s*\([^;]+$"
-tap_regex1 = r"void\s+(?P<symbol>register_tap_listener_[_A-Za-z0-9]+)\s*\([^;]+$"
-
# This table drives the pattern-matching and symbol-harvesting
patterns = [
( 'proto_reg', re.compile(proto_regex0) ),
( 'proto_reg', re.compile(proto_regex1) ),
( 'handoff_reg', re.compile(handoff_regex0) ),
( 'handoff_reg', re.compile(handoff_regex1) ),
- ( 'tap_reg', re.compile(tap_regex0) ),
- ( 'tap_reg', re.compile(tap_regex1) ),
]
# Open our registration symbol cache
# print "Pulling %s from cache" % (filename)
regs['proto_reg'].extend(cdict['proto_reg'])
regs['handoff_reg'].extend(cdict['handoff_reg'])
- regs['tap_reg'].extend(cdict['tap_reg'])
file.close()
continue
# We don't have a cache entry
'mtime': cur_mtime,
'proto_reg': [],
'handoff_reg': [],
- 'tap_reg': [],
}
# print "Searching %s" % (filename)
for line in file.readlines():
cache_file.close()
# Make sure we actually processed something
-if registertype == "taps":
- if len(regs['tap_reg']) < 1:
- print "No tap registrations found"
- sys.exit(1)
-else:
- if len(regs['proto_reg']) < 1:
- print "No protocol registrations found"
- sys.exit(1)
+if len(regs['proto_reg']) < 1:
+ print "No protocol registrations found"
+ sys.exit(1)
# Sort the lists to make them pretty
regs['proto_reg'].sort()
regs['handoff_reg'].sort()
-regs['tap_reg'].sort()
reg_code = open(tmp_filename, "w")
plugin_register (void)
{
""");
- for symbol in regs['proto_reg']:
- line = " {extern void %s (void); %s ();}\n" % (symbol, symbol)
- reg_code.write(line)
-
- reg_code.write("}\n")
-if registertype == "dissectors":
+else:
reg_code.write("""
#include "register.h"
void
register_all_protocols(register_cb cb, gpointer client_data)
{
""");
- for symbol in regs['proto_reg']:
+
+for symbol in regs['proto_reg']:
+ if registertype == "plugin":
+ line = " {extern void %s (void); %s ();}\n" % (symbol, symbol)
+ else:
line = " {extern void %s (void); if(cb) (*cb)(RA_REGISTER, \"%s\", client_data); %s ();}\n" % (symbol, symbol, symbol)
- reg_code.write(line)
- reg_code.write("}\n")
+ reg_code.write(line)
+
+reg_code.write("}\n")
# Make the routine to register all protocol handoffs
plugin_reg_handoff(void)
{
""");
- for symbol in regs['handoff_reg']:
- line = " {extern void %s (void); %s ();}\n" % (symbol, symbol)
- reg_code.write(line)
- reg_code.write("}\n")
- reg_code.write("#endif\n");
-if registertype == "dissectors":
+else:
reg_code.write("""
void
register_all_protocol_handoffs(register_cb cb, gpointer client_data)
{
""");
- for symbol in regs['tap_reg']:
+for symbol in regs['handoff_reg']:
+ if registertype == "plugin":
+ line = " {extern void %s (void); %s ();}\n" % (symbol, symbol)
+ else:
line = " {extern void %s (void); if(cb) (*cb)(RA_HANDOFF, \"%s\", client_data); %s ();}\n" % (symbol, symbol, symbol)
- reg_code.write(line)
- reg_code.write("}\n")
+ reg_code.write(line)
+
+reg_code.write("}\n")
+
+if registertype == "plugin":
+ reg_code.write("#endif\n");
+else:
reg_code.write("""
gulong register_count(void)
{
}
""");
-if registertype == "taps":
- reg_code.write("""
-#include "register.h"
-void register_all_tap_listeners(void) {
-""");
- for symbol in regs['tap_reg']:
- line = " {extern void %s (void); %s ();}\n" % (symbol, symbol)
- reg_code.write(line)
- reg_code.write("}\n")
# Close the file
reg_code.close()