7 # Wireshark - Network traffic analyzer
8 # By Gerald Combs <gerald@wireshark.org>
9 # Copyright 1998 Gerald Combs
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License
13 # as published by the Free Software Foundation; either version 2
14 # of the License, or (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 takes the file listed as the first argument and creates the file listed
28 as the second argument. It takes a PostScript file and creates a C source
33 Ported to Python from rdps.c.
39 def ps_clean_string(raw_str):
52 def start_code(fd, func):
53 script_name = os.path.split(__file__)[-1]
54 fd.write("void print_ps_%s(FILE *fd) {\n" % func)
56 def write_code(fd, raw_str):
57 ps_str = ps_clean_string(raw_str)
58 fd.write("\tfprintf(fd, \"%s\");\n" % ps_str)
63 def exit_err(msg=None, *param):
65 sys.stderr.write(msg % param)
70 STATE_PREAMBLE = 'preamble'
71 STATE_FINALE = 'finale'
76 if len(sys.argv) != 3:
77 exit_err("%s: input_file output_file\n", __file__)
79 input = open(sys.argv[1], 'r')
80 output = open(sys.argv[2], 'w')
82 script_name = os.path.split(__file__)[-1]
90 * Definitions for generating PostScript(R) packet output.
92 * Wireshark - Network traffic analyzer
93 * By Gerald Combs <gerald@wireshark.org>
94 * Copyright 1998 Gerald Combs
96 * This program is free software; you can redistribute it and/or
97 * modify it under the terms of the GNU General Public License
98 * as published by the Free Software Foundation; either version 2
99 * of the License, or (at your option) any later version.
101 * This program is distributed in the hope that it will be useful,
102 * but WITHOUT ANY WARRANTY; without even the implied warranty of
103 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
104 * GNU General Public License for more details.
106 * You should have received a copy of the GNU General Public License
107 * along with this program; if not, write to the Free Software
108 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
118 #line = line.rstrip()
119 if state is STATE_NULL:
120 if line.startswith("% ---- wireshark preamble start ---- %"):
121 state = STATE_PREAMBLE
122 start_code(output, "preamble")
124 elif line.startswith("% ---- wireshark finale start ---- %"):
126 start_code(output, "finale")
128 elif state is STATE_PREAMBLE:
129 if line.startswith("% ---- wireshark preamble end ---- %"):
134 write_code(output, line)
135 elif state is STATE_FINALE:
136 if line.startswith("% ---- wireshark finale end ---- %"):
141 write_code(output, line)
143 exit_err("NO MATCH:%s", line)
147 if __name__ == "__main__":
151 # Editor modelines - http://www.wireshark.org/tools/modelines.html
155 # indent-tabs-mode: nil
158 # vi: set shiftwidth=4 expandtab:
159 # :indentSize=4:noTabs=true: