virtio-9p: Security model for symlink and readlink
[qemu/mdroth.git] / hxtool
blob7ca83ed1ff7feee5c734a16d34b94fa4cf122049
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 line=1
63 while read -r str; do
64 case "$str" in
65 HXCOMM*)
67 SQMP*)
68 if test $flag -eq 1 ; then
69 echo "line $line: syntax error: expected EQMP, found $str" >&2
70 exit 1
72 flag=1
74 EQMP*)
75 if test $flag -ne 1 ; then
76 echo "line $line: syntax error: expected SQMP, found $str" >&2
77 exit 1
79 flag=0
81 STEXI*|ETEXI*)
82 if test $flag -eq 1 ; then
83 echo "line $line: syntax error: expected EQMP, found $str" >&2
84 exit 1
88 test $flag -eq 1 && echo "$str"
90 esac
91 line=$((line+1))
92 done
95 case "$1" in
96 "-h") hxtoh ;;
97 "-t") hxtotexi ;;
98 "-q") hxtoqmp ;;
99 *) exit 1 ;;
100 esac
102 exit 0