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