ia64/xen-unstable

view tools/ioemu/create_keysym_header.sh @ 6946:e703abaf6e3d

Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
parents 8e5fc5fe636c
children
line source
1 #!/bin/sh
3 # QEMU keysym adapter: create a header file to link the name to its keysym
4 #
5 # Copyright (c) 2004,2005 Johannes E. Schindelin
6 #
7 # Permission is hereby granted, free of charge, to any person obtaining a copy
8 # of this software and associated documentation files (the "Software"), to deal
9 # in the Software without restriction, including without limitation the rights
10 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 # copies of the Software, and to permit persons to whom the Software is
12 # furnished to do so, subject to the following conditions:
13 #
14 # The above copyright notice and this permission notice shall be included in
15 # all copies or substantial portions of the Software.
16 #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 # THE SOFTWARE.
25 type="$1"
26 cflags="$2"
27 if [ -z "$cflags" ]; then
28 echo "Usage: $0 vnc|sdl cflags"
29 exit 1
30 fi
33 case "$type" in
34 vnc)
35 ignore_case=''
36 header=rfb/keysym.h
37 keysym_t=rfbKeySym
38 pattern='^#define[ ]*XK_\([^ ]*\)[ ].*$'
39 replacement='#ifdef XK_\1\n{\"\1\", XK_\1},\n#endif'
40 extra_replace='cat'
41 extra_sort='cat'
42 ;;
43 sdl)
44 ignore_case='-f'
45 header=SDL_keysym.h
46 keysym_t=int
47 pattern='^[ ]*SDLK_\([^ ]*\)[ ]*=.*$'
48 replacement='{\"\1\", SDLK_\1},'
49 extra_replace='sed -e s/{"\([RL]\)\(SUPER\|META\|ALT\|CONTROL\|SHIFT\)/{"\2_\1/ -e s/{"\([RL]\)CTRL/{"CONTROL_\1/ -e s/{"\(PAGE\)\(UP\|DOWN\)/{"\1_\2/ -e s/{"\(KP\)\([0-9]\)/{"\1_\2/ -e s/{"KP_MINUS/{"KP_SUBTRACT/ -e s/{"KP_PLUS/{"KP_ADD/ -e s/{"KP_PERIOD/{"KP_DECIMAL/ -e s/{"\(LEFT\|RIGHT\)\(PAREN\|BRACKET\)/{"\2\1/ -e s/{"EXCLAIM/{"EXCLAM/ -e s/{"\(CAPS\|NUM\)\(LOCK\)/{"\1_\2/ -e s/{"SCROLLOCK/{"SCROLL_LOCK/ -e s/{"KP_EQUALS/{"KP_EQUAL/ -e s/{"SYSREQ/{"SYS_REQ/ -e s/{"QUOTE"/{"APOSTROPHE"/ -e s/{"BACKQUOTE/{"GRAVE/ -e s/{"EQUALS/{"EQUAL/ -e s/{"EURO/{"EUROSIGN/ -e s/{"COMPOSE/{"MULTI_KEY/ -e s/{"MODE/{"MODE_SWITCH/ -e s/{"HASH/{"NUMBERSIGN/ -e s/{"WORLD_68/{"ADIAERESIS/ -e s/{"WORLD_86/{"ODIAERESIS/ -e s/{"WORLD_92/{"UDIAERESIS/ -e s/{"WORLD_63/{"SSHARP/ -e s/{"WORLD_20/{"ACUTE/ -e s/{"CARET/{"ASCIICIRCUM/'
50 extra_sort='sort -f'
51 ;;
52 *) echo "Unknown type: $type is neither vnc nor sdl"; exit 1;;
53 esac
55 outfile=keysym_adapter_"$type".h
57 echo "typedef struct {" > $outfile
58 echo " const char* name;" >> $outfile
59 echo " $keysym_t keysym;" >> $outfile
60 echo "} name2keysym_t;" >> $outfile
61 echo "static name2keysym_t name2keysym[]={" >> $outfile
63 for path in $(echo "$cflags" | sed "s/-I/ /g"); do
64 if [ -f $path/$header ]; then
65 cat $path/$header
66 fi
67 done | tr "\011" " " | LC_ALL=C sort $ignore_case | uniq | \
68 sed -n -e "s/$pattern/$replacement/p" | $extra_replace | \
69 LC_ALL=C $extra_sort >> $outfile
71 echo "{0,0}};" >> $outfile
73 if [ -n "$ignore_case" ]; then
74 echo "#define KEYBOARD_IGNORE_CASE" >> $outfile
75 fi