block: Fix serial number assignment
[qemu.git] / hxtool
blobd499dc08ab3dd00034f522bb719113f99cfc033f
1 #!/bin/sh
3 hxtoh()
5 flag=1
6 while read -r str; do
7 case $str in
8 HXCOMM*)
9 ;;
10 STEXI*|ETEXI*|SQMP*|EQMP*) flag=$(($flag^1))
13 test $flag -eq 1 && printf "%s\n" "$str"
15 esac
16 done
19 hxtotexi()
21 flag=0
22 line=1
23 while read -r str; do
24 case "$str" in
25 HXCOMM*)
27 STEXI*)
28 if test $flag -eq 1 ; then
29 echo "line $line: syntax error: expected ETEXI, found $str" >&2
30 exit 1
32 flag=1
34 ETEXI*)
35 if test $flag -ne 1 ; then
36 echo "line $line: syntax error: expected STEXI, found $str" >&2
37 exit 1
39 flag=0
41 SQMP*|EQMP*)
42 if test $flag -eq 1 ; then
43 echo "line $line: syntax error: expected ETEXI, found $str" >&2
44 exit 1
47 DEFHEADING*)
48 echo "$(expr "$str" : "DEFHEADING(\(.*\))")"
51 test $flag -eq 1 && echo "$str"
53 esac
54 line=$((line+1))
55 done
58 hxtoqmp()
60 IFS=
61 flag=0
62 while read -r str; do
63 case "$str" in
64 HXCOMM*)
66 SQMP*)
67 if test $flag -eq 1 ; then
68 echo "line $line: syntax error: expected EQMP, found $str" >&2
69 exit 1
71 flag=1
73 EQMP*)
74 if test $flag -ne 1 ; then
75 echo "line $line: syntax error: expected SQMP, found $str" >&2
76 exit 1
78 flag=0
80 STEXI*|ETEXI*)
81 if test $flag -eq 1 ; then
82 echo "line $line: syntax error: expected EQMP, found $str" >&2
83 exit 1
87 test $flag -eq 1 && echo "$str"
89 esac
90 done
93 case "$1" in
94 "-h") hxtoh ;;
95 "-t") hxtotexi ;;
96 "-q") hxtoqmp ;;
97 *) exit 1 ;;
98 esac
100 exit 0