]>
git.proxmox.com Git - mirror_qemu.git/blob - scripts/feature_to_c.sh
3 # Convert text files to compilable C arrays.
5 # Copyright (C) 2007 Free Software Foundation, Inc.
7 # This file is part of GDB.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, see <http://www.gnu.org/licenses/>.
25 if test -z "$output" ||
test -z "$1"; then
26 echo "Usage: $0 OUTPUTFILE INPUTFILE..."
30 if test -e "$output"; then
31 echo "Output file \"$output\" already exists; refusing to overwrite."
36 arrayname
=xml_feature_$
(echo $input |
sed 's,.*/,,; s/[-.]/_/g')
38 ${AWK:-awk} 'BEGIN { n = 0
39 printf "#include \"qemu/osdep.h\"\n"
40 print "static const char '$arrayname'[] = {"
41 for (i = 0; i < 255; i++)
42 _ord_[sprintf("%c", i)] = i
46 for (i = 1; i <= length($0); i++) {
49 printf "'\''\\'\'''\'', "
50 } else if (c == "\\") {
51 printf "'\''\\\\'\'', "
52 } else if (_ord_[c] >= 32 && _ord_[c] < 127) {
53 printf "'\''%s'\'', ", c
55 printf "'\''\\%03o'\'', ", _ord_[c]
60 printf "'\''\\n'\'', \n"
63 }' < $input >> $output
67 echo "const char *const xml_builtin[][2] = {" >> $output
70 basename=$
(echo $input |
sed 's,.*/,,')
71 arrayname
=xml_feature_$
(echo $input |
sed 's,.*/,,; s/[-.]/_/g')
72 echo " { \"$basename\", $arrayname }," >> $output
75 echo " { (char *)0, (char *)0 }" >> $output