1#!/bin/sh 2# 3# File : idl2wrs 4# 5# Author : Frank Singleton (frank.singleton@ericsson.com) 6# 7# Copyright (C) 2001 Frank Singleton, Ericsson Inc. 8# 9# This file is a simple shell script wrapper for the IDL to 10# Wireshark dissector code. 11# 12# ie: wireshark_be.py and wireshark_gen.py 13# 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. 17# 18# Please see packet-giop.h in Wireshark distro for API description. 19# Wireshark is available at https://www.wireshark.org/ 20# 21# Omniidl is part of the OmniOrb distribution, and is available at 22# http://omniorb.sourceforge.net/ 23# 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. 28# 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. 33# 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 37# 02111-1307, USA. 38# 39 40 41# Must at least supply an IDL file 42 43if [ $# -lt 1 ]; then 44 echo "idl2wrs Error: no IDL file specified." 45 echo "Usage: idl2wrs idl_file_name" 46 exit 1; 47fi 48 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?" 54file=$(basename $1) 55compressed="$(echo $file | sed 's/[^[:alnum:]._]//g')" 56if [ "$compressed" != "$file" ]; then 57 echo "idl2wrs Error: Invalid file name: $file" 58 exit 1; 59fi 60 61# Only allow one '.' at most. 62count=$(echo $compressed | awk -F. '{c += NF - 1} END {print c}') 63if [ $count -gt 1 ] ; then 64 echo "idl2wrs Error: Invalid file name: $file" 65 exit 1; 66fi 67 68# 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 72# error. 73 74if [ -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 $@ 76 /* not reached */ 77fi 78 79# Try current directory. 80 81if [ -f ./wireshark_be.py ] && [ -f ./wireshark_gen.py ]; then 82 exec omniidl -p ./ -b wireshark_be $@ 83 /* not reached */ 84fi 85 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. 89 90exec omniidl -b wireshark_be $@ 91 92old code: not reached 93 94echo "idl2wrs Error: Could not find both wireshark_be.py AND wireshark_gen.py." 95echo "Please ensure you have the PYTHONPATH variable set, or that wireshark_be.py " 96echo "and wireshark_gen.py exist in the current directory. " 97echo 98echo "On this system, PYTHONPATH is : $PYTHONPATH" 99echo 100 101exit 2 102 103 104# 105# Editor modelines - https://www.wireshark.org/tools/modelines.html 106# 107# Local variables: 108# c-basic-offset: 4 109# indent-tabs-mode: nil 110# End: 111# 112# vi: set shiftwidth=4 expandtab: 113# :indentSize=4:noTabs=true: 114# 115