| 1 |
#!/bin/sh |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 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*) |
|---|
| 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 |
*) |
|---|
| 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 |
|
|---|
| 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" |
|---|
| 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 |
|
|---|
| 175 |
if test "x$1" != "x--"; then |
|---|
| 176 |
usage |
|---|
| 177 |
fi |
|---|
| 178 |
shift |
|---|
| 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 |
|
|---|