root/liboggz/trunk/src/tools/oggz-diff.in

Revision 3802, 5.5 kB (checked in by conrad, 2 months ago)

remove debugging echos from oggz-diff

Line 
1 #!/bin/sh
2
3 ## Copyright (C) 2003 Commonwealth Scientific and Industrial Research
4 ## Organisation (CSIRO) Australia
5 ##
6 ## Redistribution and use in source and binary forms, with or without
7 ## modification, are permitted provided that the following conditions
8 ## are met:
9 ##
10 ## - Redistributions of source code must retain the above copyright
11 ## notice, this list of conditions and the following disclaimer.
12 ##
13 ## - Redistributions in binary form must reproduce the above copyright
14 ## notice, this list of conditions and the following disclaimer in the
15 ## documentation and/or other materials provided with the distribution.
16 ##
17 ## - Neither the name of CSIRO Australia nor the names of its
18 ## contributors may be used to endorse or promote products derived from
19 ## this software without specific prior written permission.
20 ##
21 ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 ## ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 ## PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
25 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 ## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 ## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 ## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 ## LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 ## NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 ## SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 version () {
34   echo >&2 "oggz-diff version "@VERSION@
35   exit 1
36 }
37
38 usage () {
39   echo >&2 "oggz-diff, diff oggz-dumps of two Ogg files."
40   echo >&2
41   echo >&2 "Usage: oggz-diff [options] [OGGZDUMP_OPTIONS] [DIFF_OPTIONS] file1.ogg file2.ogg"
42   echo >&2
43   echo >&2 "options: [--verbose] [-v | --version] [-h | --help]"
44   echo >&2
45   echo >&2 "Supported oggz-dump and diff options:"
46   echo >&2
47   echo >&2 "OGGZDUMP_OPTIONS: [-b | --binary] [-x | --hexadecimal]"
48   echo >&2 "    [-O | --hide-offset] [-S | --hide-serialno] [-G | --hide-granulepos]"
49   echo >&2 "    [-P | --hide-packetno] [-s serialno | --serialno serialno]"
50   echo >&2 "    [-c content-type | --content-type content-type]"
51   echo >&2
52   echo >&2 "DIFF_OPTIONS: [-q | --brief] [-C NUM | --context[=NUM]]"
53   echo >&2 "     [-u | -U NUM | --unified[=NUM]] [-e | -ed] [--normal] [--rcs]"
54   echo >&2 "     [-y | --side-by-side] [-l | --paginate]"
55   echo >&2
56   exit 1
57 }
58
59 GETOPTEST=`getopt --version`
60 case $GETOPTEST in
61 getopt*) # GNU getopt
62   GETOPTARGS="-l verbose -l version -l brief -l context:: -l unified:: -l ed -l normal -l rcs -l side-by-side -l paginate -l binary -l hexadecimal -l serialno: -l content-type: -l hide-offset -l hide-serialno -l hide-granulepos -l hide-packetno -l help -- +qC:uU:eylbxs:c:OSGPhv"
63   QARGS="--verbose --version --brief --context --unified --ed --normal --rcs --side-by-side --paginate --binary --hexadecimal --serialno --content-type --hide-offset --hide-serialno --hide-granulepos --hide-packetno --help -q -C -u -U -e -y -l -b -x -s -c -O -S -G -P -h -v"
64   ;;
65 *) # POSIX getopt ?
66   GETOPTARGS="qC:uU:eylbxs:c:OSGPhv"
67   QARGS="-q -C -u -U -e -y -l -b -x -s -c -O -S -G -P -h -v"
68   ;;
69 esac
70
71 # First check for -? option
72 if test "X$1" = "X-?"; then
73   exit 0
74 fi
75
76 TEMP=`getopt $GETOPTARGS "$@"`
77
78 if test "$?" != "0"; then
79   usage
80 fi
81
82 eval set -- "$TEMP"
83
84 DIFFOPTS="-w" # -w, --ignore-all-space
85 DUMPOPTS=""
86 VERBOSE=""
87
88 while test "X$1" != "X--"; do
89   case "$1" in
90     -q|--brief)
91       DIFFOPTS=$DIFFOPTS" -q"
92       ;;
93     -C)
94       shift
95       DIFFOPTS=$DIFFOPTS" -C $1"
96       ;;
97     --context)
98       shift
99       if test "x$1" = "x"; then
100         DIFFOPTS=$DIFFOPTS" --context"
101       else
102         DIFFOPTS=$DIFFOPTS" --context=$1"
103       fi
104       ;;
105     -u)
106       DIFFOPTS=$DIFFOPTS" -u"
107       ;;
108     -U)
109       shift
110       DIFFOPTS=$DIFFOPTS" -U $1"
111       ;;
112     --unified)
113       shift
114       if test "x$1" = "x"; then
115         DIFFOPTS=$DIFFOPTS" --unified"
116       else
117         DIFFOPTS=$DIFFOPTS" --unified=$1"
118       fi
119       ;;
120     -e|--ed)
121       DIFFOPTS=$DIFFOPTS" -e"
122       ;;
123     --normal)
124       DIFFOPTS=$DIFFOPTS" --normal"
125       ;;
126     --rcs)
127       DIFFOPTS=$DIFFOPTS" --rcs"
128       ;;
129     -y|--side-by-side)
130       DIFFOPTS=$DIFFOPTS" -y"
131       ;;
132     -l|--paginate)
133       DIFFOPTS=$DIFFOPTS" -l"
134       ;;
135     -b|--binary)
136       DUMPOPTS=$DUMPOPTS" -b"
137       ;;
138     -x|--hexadecimal)
139       DUMPOPTS=$DUMPOPTS" -x"
140       ;;
141     -s|--serialno)
142       shift
143       DUMPOPTS=$DUMPOPTS" -s $1"
144       ;;
145     -c)
146       shift
147       DUMPOPTS=$DUMPOPTS" -c $1"
148       ;;
149     -O|--hide-offset)
150       DUMPOPTS=$DUMPOPTS" -O"
151       ;;
152     -S|--hide-serialno)
153       DUMPOPTS=$DUMPOPTS" -S"
154       ;;
155     -G|--hide-granulepos)
156       DUMPOPTS=$DUMPOPTS" -G"
157       ;;
158     -P|--hide-packetno)
159       DUMPOPTS=$DUMPOPTS" -P"
160       ;;
161     --verbose)
162       VERBOSE="y"
163       ;;
164     -v|--version)
165       version
166       ;;
167     -h|--help)
168       usage
169       ;;
170   esac
171   shift
172 done
173
174 # Check that all options parsed ok
175 if test "x$1" != "x--"; then
176   usage
177 fi
178 shift #get rid of the '--'
179
180 if test "x$1" = "x"; then
181   usage
182 fi
183 if test "x$2" = "x"; then
184   usage
185 fi
186
187 if test "x$VERBOSE" != "x"; then
188   echo >&2 "OGGZDUMP_OPTIONS: " $DUMPOPTS
189   echo >&2 "DIFF_OPTIONS: " $DIFFOPTS
190 fi
191
192 FIFO1="${TMPDIR:-/tmp}/`basename $1`.dump-1-$$"
193 FIFO2="${TMPDIR:-/tmp}/`basename $2`.dump-2-$$"
194
195 exec 5>$FIFO1
196 exec 6>$FIFO2
197
198 oggz-dump $DUMPOPTS $1 >&5
199 if test "$?" != "0"; then
200   exit 1
201 fi
202
203 oggz-dump $DUMPOPTS $2 >&6
204 if test "$?" != "0"; then
205   exit 1
206 fi
207
208 diff $DIFFOPTS $FIFO1 $FIFO2
209 ret=$?
210
211 rm $FIFO1 $FIFO2
212
213 exit $ret
214
Note: See TracBrowser for help on using the browser.