7 # Author : Frank Singleton (frank.singleton@ericsson.com)
9 # Copyright (C) 2001 Frank Singleton, Ericsson Inc.
11 # This file is a simple shell script wrapper for the IDL to
12 # Wireshark dissector code.
14 # ie: wireshark_be.py and wireshark_gen.py
16 # This file is used to generate "Wireshark" dissectors from IDL descriptions.
17 # The output language generated is "C". It will generate code to use the
18 # GIOP/IIOP get_CDR_XXX API.
20 # Please see packet-giop.h in Wireshark distro for API description.
21 # Wireshark is available at http://www.wireshark.org/
23 # Omniidl is part of the OmniOrb distribution, and is available at
24 # http://omniorb.sourceforge.net/
26 # This program is free software; you can redistribute it and/or modify it
27 # under the terms of the GNU General Public License as published by
28 # the Free Software Foundation; either version 2 of the License, or
29 # (at your option) any later version.
31 # This program is distributed in the hope that it will be useful,
32 # but WITHOUT ANY WARRANTY; without even the implied warranty of
33 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34 # General Public License for more details.
36 # You should have received a copy of the GNU General Public License
37 # along with this program; if not, write to the Free Software
38 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
43 # Must at least supply an IDL file
46 echo "idl2wrs Error: no IDL file specified."
47 echo "Usage: idl2wrs idl_file_name"
51 # Check the file name for valid characters.
52 # Implementation based on Dave Taylor's validalnum shell script from his book,
53 # "Wicked Cool Shell Scripts", as well as Mark Rushakoff's answer he provided
54 # to the question posted at stackoverflow.com entitled, "How can I use the
55 # UNIX shell to count the number of times a letter appears in a text file?"
57 compressed
="$(echo $file | sed 's/[^[:alnum:]._]//g')"
58 if [ "$compressed" != "$file" ]; then
59 echo "idl2wrs Error: Invalid file name: $file"
63 # Only allow one '.' at most.
64 count
=$
(echo $compressed |
awk -F.
'{c += NF - 1} END {print c}')
65 if [ $count -gt 1 ] ; then
66 echo "idl2wrs Error: Invalid file name: $file"
71 # Run wireshark backend, looking for wireshark_be.py and wireshark_gen.py
72 # in pythons's "site-packages" directory. If cannot find that, then
73 # try looking in current directory. If still cannot, then exit with
76 if [ -f $PYTHONPATH/site-packages
/wireshark_be.py
] && [ -f $PYTHONPATH/site-packages
/wireshark_gen.py
]; then
77 exec omniidl
-p $PYTHONPATH/site-packages
-b wireshark_be $@
81 # Try current directory.
83 if [ -f .
/wireshark_be.py
] && [ -f .
/wireshark_gen.py
]; then
84 exec omniidl
-p .
/ -b wireshark_be $@
88 # Could not find both wireshark_be.py AND wireshark_gen.py
89 # So let's just try to run it without -p, hoping that the installation
90 # set up a valid path.
92 exec omniidl
-b wireshark_be $@
96 echo "idl2wrs Error: Could not find both wireshark_be.py AND wireshark_gen.py."
97 echo "Please ensure you have the PYTHONPATH variable set, or that wireshark_be.py "
98 echo "and wireshark_gen.py exist in the current directory. "
100 echo "On this system, PYTHONPATH is : $PYTHONPATH"