]> git.proxmox.com Git - mirror_qemu.git/blob - hxtool
hpet: Make number of timers configurable
[mirror_qemu.git] / hxtool
1 #!/bin/sh
2
3 hxtoh()
4 {
5 flag=1
6 while read -r str; do
7 case $str in
8 HXCOMM*)
9 ;;
10 STEXI*|ETEXI*|SQMP*|EQMP*) flag=$(($flag^1))
11 ;;
12 *)
13 test $flag -eq 1 && printf "%s\n" "$str"
14 ;;
15 esac
16 done
17 }
18
19 hxtotexi()
20 {
21 flag=0
22 line=1
23 while read -r str; do
24 case "$str" in
25 HXCOMM*)
26 ;;
27 STEXI*)
28 if test $flag -eq 1 ; then
29 echo "line $line: syntax error: expected ETEXI, found $str" >&2
30 exit 1
31 fi
32 flag=1
33 ;;
34 ETEXI*)
35 if test $flag -ne 1 ; then
36 echo "line $line: syntax error: expected STEXI, found $str" >&2
37 exit 1
38 fi
39 flag=0
40 ;;
41 SQMP*|EQMP*)
42 if test $flag -eq 1 ; then
43 echo "line $line: syntax error: expected ETEXI, found $str" >&2
44 exit 1
45 fi
46 ;;
47 DEFHEADING*)
48 echo "$(expr "$str" : "DEFHEADING(\(.*\))")"
49 ;;
50 *)
51 test $flag -eq 1 && echo "$str"
52 ;;
53 esac
54 line=$((line+1))
55 done
56 }
57
58 hxtoqmp()
59 {
60 IFS=
61 flag=0
62 while read -r str; do
63 case "$str" in
64 HXCOMM*)
65 ;;
66 SQMP*)
67 if test $flag -eq 1 ; then
68 echo "line $line: syntax error: expected EQMP, found $str" >&2
69 exit 1
70 fi
71 flag=1
72 ;;
73 EQMP*)
74 if test $flag -ne 1 ; then
75 echo "line $line: syntax error: expected SQMP, found $str" >&2
76 exit 1
77 fi
78 flag=0
79 ;;
80 STEXI*|ETEXI*)
81 if test $flag -eq 1 ; then
82 echo "line $line: syntax error: expected EQMP, found $str" >&2
83 exit 1
84 fi
85 ;;
86 *)
87 test $flag -eq 1 && echo "$str"
88 ;;
89 esac
90 done
91 }
92
93 case "$1" in
94 "-h") hxtoh ;;
95 "-t") hxtotexi ;;
96 "-q") hxtoqmp ;;
97 *) exit 1 ;;
98 esac
99
100 exit 0