From ac8f637590b792b94f4c2e55a5238586fc0f6157 Mon Sep 17 00:00:00 2001 From: Kovarththanan Rajaratnam Date: Sun, 4 Oct 2009 07:50:36 +0000 Subject: Move rdps.py to tools/rdps.py svn path=/trunk/; revision=30281 --- CMakeLists.txt | 4 +- Makefile.am | 6 +-- Makefile.nmake | 4 +- rdps.py | 151 --------------------------------------------------------- tools/rdps.py | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 158 insertions(+), 158 deletions(-) delete mode 100644 rdps.py create mode 100644 tools/rdps.py diff --git a/CMakeLists.txt b/CMakeLists.txt index bbbc78a288..12d4972456 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -424,11 +424,11 @@ ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND( OUTPUT ps.c COMMAND ${PYTHON_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/rdps.py + ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py ${CMAKE_CURRENT_SOURCE_DIR}/print.ps ps.c DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/rdps.py + ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py ${CMAKE_CURRENT_SOURCE_DIR}/print.ps ) diff --git a/Makefile.am b/Makefile.am index c51d495194..143275d5bc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -528,8 +528,8 @@ tshark-tap-register.c: $(TSHARK_TAP_SRC) $(srcdir)/make-tapreg-dotc @echo Making tshark-tap-register.c @$(srcdir)/make-tapreg-dotc tshark-tap-register.c $(srcdir) $(TSHARK_TAP_SRC) -ps.c: print.ps rdps.py - $(PYTHON) $(srcdir)/rdps.py $(srcdir)/print.ps ps.c +ps.c: print.ps $(srcdir)/tools/rdps.py + $(PYTHON) $(srcdir)/tools/rdps.py $(srcdir)/print.ps ps.c # # XXX - "svnversion.h" is distributed in the release tarball; should @@ -803,11 +803,11 @@ EXTRA_DIST = \ $(tpncp_DATA) \ $(wimaxasncp_DATA) \ randpkt.c \ - rdps.py \ smi_modules \ text2pcap-scanner.l \ text2pcap.c \ text2pcap.h \ + tools/rdps.py \ services \ wireshark.desktop \ wka.tmpl diff --git a/Makefile.nmake b/Makefile.nmake index b7c3e8c6e4..4ee6261002 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -375,8 +375,8 @@ config.h : config.h.win32 config.nmake < config.h.win32 > $@ -ps.c : rdps.py print.ps - $(PYTHON) rdps.py print.ps ps.c +ps.c: tools\rdps.py print.ps + $(PYTHON) tools\rdps.py print.ps ps.c # # Build the version string # diff --git a/rdps.py b/rdps.py deleted file mode 100644 index 9bb3b04141..0000000000 --- a/rdps.py +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env python -# -# rdps.py -# -# $Id$ -# -# Wireshark - Network traffic analyzer -# By Gerald Combs -# Copyright 1998 Gerald Combs -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -'''\ -takes the file listed as the first argument and creates the file listed -as the second argument. It takes a PostScript file and creates a C source -with 2 functions: - print_ps_preamble() - print_ps_finale() - -Ported to Python from rdps.c. -''' - -import sys -import os.path - -def ps_clean_string(raw_str): - ps_str = '' - for c in raw_str: - if c == '\\': - ps_str += '\\\\' - elif c == '%': - ps_str += '%%' - elif c == '\n': - ps_str += '\\n' - else: - ps_str += c - return ps_str - -def start_code(fd, func): - script_name = os.path.split(__file__)[-1] - fd.write("void print_ps_%s(FILE *fd) {\n" % func) - -def write_code(fd, raw_str): - ps_str = ps_clean_string(raw_str) - fd.write("\tfprintf(fd, \"%s\");\n" % ps_str) - -def end_code(fd): - fd.write("}\n\n\n") - -def exit_err(msg=None, *param): - if msg is not None: - sys.stderr.write(msg % param) - sys.exit(1) - -# Globals -STATE_NULL = 'null' -STATE_PREAMBLE = 'preamble' -STATE_FINALE = 'finale' - -def main(): - state = STATE_NULL; - - if len(sys.argv) != 3: - exit_err("%s: input_file output_file\n", __file__) - - input = open(sys.argv[1], 'r') - output = open(sys.argv[2], 'w') - - script_name = os.path.split(__file__)[-1] - - output.write('''\ -/* DO NOT EDIT - * - * Created by %s. - * - * ps.c - * Definitions for generating PostScript(R) packet output. - * - * $Id$ - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include - -#include "ps.h" - -''' % script_name) - - for line in input: - #line = line.rstrip() - if state is STATE_NULL: - if line.startswith("% ---- wireshark preamble start ---- %"): - state = STATE_PREAMBLE - start_code(output, "preamble") - continue - elif line.startswith("% ---- wireshark finale start ---- %"): - state = STATE_FINALE - start_code(output, "finale") - continue - elif state is STATE_PREAMBLE: - if line.startswith("% ---- wireshark preamble end ---- %"): - state = STATE_NULL - end_code(output) - continue - else: - write_code(output, line) - elif state is STATE_FINALE: - if line.startswith("% ---- wireshark finale end ---- %"): - state = STATE_NULL - end_code(output) - continue - else: - write_code(output, line) - else: - exit_err("NO MATCH:%s", line) - - sys.exit(0) - -if __name__ == "__main__": - main() - diff --git a/tools/rdps.py b/tools/rdps.py new file mode 100644 index 0000000000..9bb3b04141 --- /dev/null +++ b/tools/rdps.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python +# +# rdps.py +# +# $Id$ +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# Copyright 1998 Gerald Combs +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +'''\ +takes the file listed as the first argument and creates the file listed +as the second argument. It takes a PostScript file and creates a C source +with 2 functions: + print_ps_preamble() + print_ps_finale() + +Ported to Python from rdps.c. +''' + +import sys +import os.path + +def ps_clean_string(raw_str): + ps_str = '' + for c in raw_str: + if c == '\\': + ps_str += '\\\\' + elif c == '%': + ps_str += '%%' + elif c == '\n': + ps_str += '\\n' + else: + ps_str += c + return ps_str + +def start_code(fd, func): + script_name = os.path.split(__file__)[-1] + fd.write("void print_ps_%s(FILE *fd) {\n" % func) + +def write_code(fd, raw_str): + ps_str = ps_clean_string(raw_str) + fd.write("\tfprintf(fd, \"%s\");\n" % ps_str) + +def end_code(fd): + fd.write("}\n\n\n") + +def exit_err(msg=None, *param): + if msg is not None: + sys.stderr.write(msg % param) + sys.exit(1) + +# Globals +STATE_NULL = 'null' +STATE_PREAMBLE = 'preamble' +STATE_FINALE = 'finale' + +def main(): + state = STATE_NULL; + + if len(sys.argv) != 3: + exit_err("%s: input_file output_file\n", __file__) + + input = open(sys.argv[1], 'r') + output = open(sys.argv[2], 'w') + + script_name = os.path.split(__file__)[-1] + + output.write('''\ +/* DO NOT EDIT + * + * Created by %s. + * + * ps.c + * Definitions for generating PostScript(R) packet output. + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include + +#include "ps.h" + +''' % script_name) + + for line in input: + #line = line.rstrip() + if state is STATE_NULL: + if line.startswith("% ---- wireshark preamble start ---- %"): + state = STATE_PREAMBLE + start_code(output, "preamble") + continue + elif line.startswith("% ---- wireshark finale start ---- %"): + state = STATE_FINALE + start_code(output, "finale") + continue + elif state is STATE_PREAMBLE: + if line.startswith("% ---- wireshark preamble end ---- %"): + state = STATE_NULL + end_code(output) + continue + else: + write_code(output, line) + elif state is STATE_FINALE: + if line.startswith("% ---- wireshark finale end ---- %"): + state = STATE_NULL + end_code(output) + continue + else: + write_code(output, line) + else: + exit_err("NO MATCH:%s", line) + + sys.exit(0) + +if __name__ == "__main__": + main() + -- cgit v1.2.3