Commit 5f4a5e91 authored by conrad's avatar conrad

yo diff in!


git-svn-id: http://svn.annodex.net/liboggz/trunk@348 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 506d5d26
#!/bin/sh
## Copyright (C) 2003 Commonwealth Scientific and Industrial Research
## Organisation (CSIRO) Australia
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
##
## - Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
##
## - Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
##
## - Neither the name of CSIRO Australia nor the names of its
## contributors may be used to endorse or promote products derived from
## this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
## ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
## PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
## LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
## NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
## SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
version () {
echo >&2 "oggzdiff version "@VERSION@
exit 1
}
usage () {
echo >&2 "oggzdiff, diff oggzdumps of two Ogg files."
echo >&2
echo >&2 "Usage: oggzdiff [options] [OGGZDUMP_OPTIONS] [DIFF_OPTIONS] file1.ogg file2.ogg"
echo >&2
echo >&2 "options: [--verbose] [-v | --version] [-h | --help]"
echo >&2
echo >&2 "Supported oggzdump and diff options:"
echo >&2
echo >&2 "OGGZDUMP_OPTIONS: [-b | --binary] [-x | --hexadecimal]"
echo >&2 " [-O | --hide-offset] [-S | --hide-serialno] [-G | --hide-granulepos]"
echo >&2 " [-P | --hide-packetno] [-s serialno | --serialno serialno]"
echo >&2
echo >&2 "DIFF_OPTIONS: [-q | --brief] [-c | -C NUM | --context[=NUM]]"
echo >&2 " [-u | -U NUM | --unified[=NUM]] [-e | -ed] [--normal] [--rcs]"
echo >&2 " [-y | --side-by-side] [-l | --paginate]"
echo >&2
exit 1
}
GETOPTEST=`getopt --version`
case $GETOPTEST in
getopt*) # GNU getopt
TEMP=`getopt -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 hide-offset -l hide-serialno -l hide-granulepos -l hide-packetno -l help -- +qcC:uU:eylbxs:OSGPhv "$@"`
;;
*) # POSIX getopt ?
TEMP=`getopt qcC:uU:eylbxs:OSGPhv "$@"`
;;
esac
if test "$?" != "0"; then
usage
fi
eval set -- "$TEMP"
DIFFOPTS="-w" # -w, --ignore-all-space
DUMPOPTS=""
VERBOSE=""
while test "X$1" != "X--"; do
case "$1" in
-q|--brief)
DIFFOPTS=$DIFFOPTS" -q"
;;
-c)
DIFFOPTS=$DIFFOPTS" -c"
;;
-C)
shift
DIFFOPTS=$DIFFOPTS" -C $1"
;;
--context)
shift
if test "x$1" = "x"; then
DIFFOPTS=$DIFFOPTS" --context"
else
DIFFOPTS=$DIFFOPTS" --context=$1"
fi
;;
-u)
DIFFOPTS=$DIFFOPTS" -u"
;;
-U)
shift
DIFFOPTS=$DIFFOPTS" -U $1"
;;
--unified)
shift
if test "x$1" = "x"; then
DIFFOPTS=$DIFFOPTS" --unified"
else
DIFFOPTS=$DIFFOPTS" --unified=$1"
fi
;;
-e|--ed)
DIFFOPTS=$DIFFOPTS" -e"
;;
--normal)
DIFFOPTS=$DIFFOPTS" --normal"
;;
--rcs)
DIFFOPTS=$DIFFOPTS" --rcs"
;;
-y|--side-by-side)
DIFFOPTS=$DIFFOPTS" -y"
;;
-l|--paginate)
DIFFOPTS=$DIFFOPTS" -l"
;;
-b|--binary)
DUMPOPTS=$DUMPOPTS" -b"
;;
-x|--hexadecimal)
DUMPOPTS=$DUMPOPTS" -x"
;;
-s|--serialno)
shift
DUMPOPTS=$DUMPOTS" -s $1"
;;
-O|--hide-offset)
DUMPOPTS=$DUMPOTS" -O"
;;
-S|--hide-serialno)
DUMPOPTS=$DUMPOTS" -S"
;;
-G|--hide-granulepos)
DUMPOPTS=$DUMPOTS" -G"
;;
-P|--hide-packetno)
DUMPOPTS=$DUMPOTS" -P"
;;
--verbose)
VERBOSE="y"
;;
-v|--version)
version
;;
-h|--help)
usage
;;
esac
shift
done
# Check that all options parsed ok
if test "x$1" != "x--"; then
usage
fi
shift #get rid of the '--'
if test "x$1" = "x"; then
usage
fi
if test "x$2" = "x"; then
usage
fi
if test "x$VERBOSE" != "x"; then
echo >&2 "OGGZDUMP_OPTIONS: " $DUMPOPTS
echo >&2 "DIFF_OPTIONS: " $DIFFOPTS
fi
FIFO1="${TMPDIR-/tmp}/`basename $1`.dump-$$"
FIFO2="${TMPDIR-/tmp}/`basename $2`.dump-$$"
exec 5>$FIFO1
exec 6>$FIFO2
oggzdump $DUMPOPTS $1 >&5
if test "$?" != "0"; then
exit 1
fi
oggzdump $DUMPOPTS $2 >&6
if test "$?" != "0"; then
exit 1
fi
diff $DIFFOPTS $FIFO1 $FIFO2
rm $FIFO1 $FIFO2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment