1 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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
#!/bin/sh
version="1.0"
name=`basename $0`
dir="/usr/share/codecgraph"
fmt="svg"
usage="Usage: $name [-f format] [-h] [-o name] [-v] [codecfile]"
help="Options:
-f format Set output format (svg, ps, png), default is $fmt
-h Display list of parameters and exit
-o name Set output file name
-v Display version information and exit
"
while getopts hvf:o: opt
do
case "$opt" in
f) # specify output file format
fmt="$OPTARG"
;;
h)
echo "$usage" 1>&2
echo "$help" 1>&2
exit 0
;;
o) # specify output file name
outfile="$OPTARG"
;;
v) # display version information
echo "$name $version"
exit 0
;;
\?)
echo "$usage" 1>&2
exit 1
;;
esac
done
shift `expr $OPTIND - 1`
codecfile=$1
if [ -z "$codecfile" ]; then
codecfile=`ls /proc/asound/card*/codec*|head -1 2>/dev/null`
if [ -n "$codecfile" ]; then
echo "Reading codec data from $codecfile"
fi
fi
if [ -z "$codecfile" ]; then
echo "error: codec file not specified" >&2
exit 1
fi
if [ ! -x $dir/codecgraph.py ]; then
echo "error: can't execute codecgraph.py (package corrupt?)" >&2
exit 1
fi
if [ -z "`which dot`" ]; then
echo "error: dot executable not found (did you install graphviz?)" >&2
exit 1
fi
if [ ! -r "$codecfile" ]; then
echo "error: can't read input file $codecfile" >&2
exit 1
fi
if [ -z "$outfile" ]; then
outfile="`basename $codecfile`"
fi
cat $codecfile | grep -v "^[\t ]*$" | head -1 | grep ^Codec:
if [ $? -ne 0 ]; then
echo "error: $codecfile not a codec description" 2>&1
exit 1
fi
dotfile=`mktemp -t codecgraph.XXXXXX`
$dir/codecgraph.py $codecfile > $dotfile
echo Generating $outfile.$fmt
dot -T$fmt -o$outfile.$fmt $dotfile
rm $dotfile
|