USB/PN532: Fix dissector to use new dissector *data instead of private_data. Bug...
[metze/wireshark/wip.git] / tools / textify.sh
1 #!/bin/bash
2 #
3 # Text file conversion script for packaging on Windows
4 #
5 # This script copies a text file from a source to a destination,
6 # converting line endings and adding a ".txt" filename extension
7 # if needed. If the destination is a directory the source file
8 # name is used. Newer files will not be overwritten.
9 #
10 # The destination file should be double-clickable and usable
11 # when Notepad is the default editor.
12 #
13 # Copyright 2013 Gerald Combs <gerald@wireshark.org>
14 #
15 # $Id$
16 #
17 # Wireshark - Network traffic analyzer
18 # By Gerald Combs <gerald@wireshark.org>
19 # Copyright 1998 Gerald Combs
20 #
21 # This program is free software; you can redistribute it and/or
22 # modify it under the terms of the GNU General Public License
23 # as published by the Free Software Foundation; either version 2
24 # of the License, or (at your option) any later version.
25 #
26 # This program is distributed in the hope that it will be useful,
27 # but WITHOUT ANY WARRANTY; without even the implied warranty of
28 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29 # GNU General Public License for more details.
30 #
31 # You should have received a copy of the GNU General Public License
32 # along with this program; if not, write to the Free Software
33 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
34
35 SRC="$1"
36 DST="$2"
37
38 err_exit () {
39     for str in "$@" ; do
40         echo "ERROR: $str"
41     done
42     echo "Usage:"
43     echo "  $0 <source file> <destination file>"
44     echo ""
45     exit 1
46 }
47
48 if [ -z "$SRC" -o -z "$DST" ] ; then
49     err_exit
50 fi
51
52 if [ ! -r "$SRC" ] ; then
53     err_exit "Can't read $SRC"
54 fi    
55
56 if [ -f "$DST" -a "$DST" -nt "SRC" ]; then
57     exit 0
58 fi
59
60 if [ -d "$DST" ] ; then
61     DSTBASE=`basename "$SRC" txt`
62     DST="$DST/$DSTBASE.txt"
63 else
64     DSTDIR=`dirname "$DST"`
65     DSTBASE=`basename "$DST" txt`
66     DST="$DSTDIR/$DSTBASE.txt"
67 fi
68
69 cp "$SRC" "$DST"
70 u2d "$DST"