From e7d75a821ded66cf485e2aa8822b5b487dc9cc6c Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Mon, 17 Apr 2006 00:41:54 +0000 Subject: Move "make-reg-dotc" and "make-reg-dotc.py" to the "tools" directory, so that it can more easily be used when building plugins. svn path=/trunk/; revision=17881 --- epan/dissectors/Makefile.am | 9 ++- epan/dissectors/make-reg-dotc | 79 -------------------------- epan/dissectors/make-reg-dotc.py | 118 --------------------------------------- 3 files changed, 4 insertions(+), 202 deletions(-) delete mode 100644 epan/dissectors/make-reg-dotc delete mode 100644 epan/dissectors/make-reg-dotc.py (limited to 'epan/dissectors') diff --git a/epan/dissectors/Makefile.am b/epan/dissectors/Makefile.am index e54c624ee4..12f245178d 100644 --- a/epan/dissectors/Makefile.am +++ b/epan/dissectors/Makefile.am @@ -33,8 +33,6 @@ libdissectors_la_SOURCES = \ EXTRA_DIST = \ Makefile.common \ Makefile.nmake \ - make-reg-dotc \ - make-reg-dotc.py \ ncp2222.py \ packet-ncp2222.inc \ process-x11-fields.pl \ @@ -77,13 +75,14 @@ x11-declarations.h x11-register-info.h: $(PROC_X11_FIELDS) $(X11_FIELDS) # The second argument is the directory in which the source files live. # All subsequent arguments are the files to scan. # -register.c: $(plugin_src) $(DISSECTOR_SRC) $(srcdir)/make-reg-dotc $(srcdir)/make-reg-dotc.py +register.c: $(plugin_src) $(DISSECTOR_SRC) $(top_srcdir)/tools/make-reg-dotc \ + $(top_srcdir)/tools/make-reg-dotc.py @if test -n $(PYTHON); then \ echo Making register.c with python ; \ - $(PYTHON) $(srcdir)/make-reg-dotc.py $(srcdir) $(DISSECTOR_SRC) ; \ + $(PYTHON) $(top_srcdir)/tools/make-reg-dotc.py $(srcdir) $(DISSECTOR_SRC) ; \ else \ echo Making register.c with shell script ; \ - $(srcdir)/make-reg-dotc register.c $(srcdir) \ + $(top_srcdir)/tools/make-reg-dotc register.c $(srcdir) \ $(plugin_src) $(DISSECTOR_SRC) ; \ fi diff --git a/epan/dissectors/make-reg-dotc b/epan/dissectors/make-reg-dotc deleted file mode 100644 index a90019af05..0000000000 --- a/epan/dissectors/make-reg-dotc +++ /dev/null @@ -1,79 +0,0 @@ -#! /bin/sh - -# -# $Id$ -# - -# -# The first argument is the output filename. -# - -outfile="$1" -shift - -# -# The second argument is the directory in which the source files live. -# -srcdir="$1" -shift - -# -# All subsequent arguments are the files to scan. -# -rm -f ${outfile}-tmp -echo '/* Do not modify this file. */' >${outfile}-tmp -echo '/* It is created automatically by the Makefile. */'>>${outfile}-tmp -echo '#include "register.h"' >>${outfile}-tmp - -# -# Build code to call all the protocol registration routines. -# -echo 'void register_all_protocols(void) {' >>${outfile}-tmp -for f in "$@" -do - if [ -f $f ] - then - srcfile=$f - else - srcfile=$srcdir/$f - fi - grep '^proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';' -done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp -for f in "$@" -do - if [ -f $f ] - then - srcfile=$f - else - srcfile=$srcdir/$f - fi - grep '^void proto_register_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';' -done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp -echo '}' >>${outfile}-tmp - -# -# Build code to call all the protocol handoff registration routines. -# -echo 'void register_all_protocol_handoffs(void) {' >>${outfile}-tmp -for f in "$@" -do - if [ -f $f ] - then - srcfile=$f - else - srcfile=$srcdir/$f - fi - grep '^proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';' -done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp -for f in "$@" -do - if [ -f $f ] - then - srcfile=$f - else - srcfile=$srcdir/$f - fi - grep '^void proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';' -done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>${outfile}-tmp -echo '}' >>${outfile}-tmp -mv ${outfile}-tmp ${outfile} diff --git a/epan/dissectors/make-reg-dotc.py b/epan/dissectors/make-reg-dotc.py deleted file mode 100644 index 0ce7ed6029..0000000000 --- a/epan/dissectors/make-reg-dotc.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env python -# -# Looks for registration routines in the protocol dissectors, -# and assembles C code to call all the routines. -# -# This is a Python version of the make-reg-dotc shell script. -# Running the shell script on Win32 is very very slow because of -# all the process-launching that goes on --- multiple greps and -# seds for each input file. I wrote this python version so that -# less processes would have to be started. -# -# $Id$ - -import os -import sys -import re - -tmp_filename = "register.c-tmp" -final_filename = "register.c" - -# -# The first argument is the directory in which the source files live. -# -srcdir = sys.argv[1] - -# -# All subsequent arguments are the files to scan. -# -files = sys.argv[2:] - -reg_code = open(tmp_filename, "w") - -reg_code.write("/* Do not modify this file. */\n") -reg_code.write("/* It is created automatically by the Makefile. */\n") -reg_code.write('#include "register.h"\n') - -# Create the proper list of filenames -filenames = [] -for file in files: - if os.path.isfile(file): - filenames.append(file) - else: - filenames.append("%s/%s" % (srcdir, file)) - - -# Look through all files, applying the regex to each line. -# If the pattern matches, save the "symbol" section to the -# appropriate array. -proto_reg = [] -handoff_reg = [] - -# For those that don't know Python, r"" indicates a raw string, -# devoid of Python escapes. -proto_regex0 = r"^(?Pproto_register_[_A-Za-z0-9]+)\s*\([^;]+$" -proto_regex1 = r"void\s+(?Pproto_register_[_A-Za-z0-9]+)\s*\([^;]+$" - -handoff_regex0 = r"^(?Pproto_reg_handoff_[_A-Za-z0-9]+)\s*\([^;]+$" -handoff_regex1 = r"void\s+(?Pproto_reg_handoff_[_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) ), - ] - -# Grep -for filename in filenames: - file = open(filename) -# print "Searching %s" % (filename) - for line in file.readlines(): - for action in patterns: - regex = action[1] - match = regex.search(line) - if match: - symbol = match.group("symbol") - list = action[0] - list.append(symbol) - file.close() - -# Sort the lists to make them pretty -proto_reg.sort() -handoff_reg.sort() - -# Make register_all_protocols() -reg_code.write("void register_all_protocols(void) {\n") - -for symbol in proto_reg: - line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) - reg_code.write(line) - -reg_code.write("}\n") - - -# Make register_all_protocol_handoffs() -reg_code.write("void register_all_protocol_handoffs(void) {\n") - -for symbol in handoff_reg: - line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) - reg_code.write(line) - -reg_code.write("}\n") - -# Close the file -reg_code.close() - -# Remove the old final_file if it exists. -try: - os.stat(final_filename) - os.remove(final_filename) -except OSError: - pass - -# Move from tmp file to final file -os.rename(tmp_filename, final_filename) - - -- cgit v1.2.3