BadVPN – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 #!/usr/bin/env bash
2  
3 OUTPUT=$1
4 shift
5 INPUTS=("$@")
6  
7 types=""
8 keys=""
9 rels=""
10 syns=""
11 abss=""
12 sws=""
13 mscs=""
14 leds=""
15 reps=""
16 snds=""
17 ffstatuss=""
18  
19 while read LINE; do
20 tab=$'\t'
21 space="[ ${tab}]"
22 regex="^#define ((EV|SYN|KEY|BTN|REL|ABS|SW|MSC|LED|REP|SND|FF_STATUS)_([A-Z0-9_]+))${space}"
23 if [[ $LINE =~ $regex ]]; then
24 name=${BASH_REMATCH[1]}
25 type=${BASH_REMATCH[2]}
26 nameonly=${BASH_REMATCH[3]}
27 [[ $nameonly = "MAX" || $nameonly = "CNT" ]] && continue
28 if [[ $type = "EV" ]]; then
29 if [[ $name != "EV_VERSION" ]]; then
30 types="${types} [${name}] = \"${name}\",
31 "
32 fi
33 elif [[ $type = "SYN" ]]; then
34 syns="${syns} [${name}] = \"${name}\",
35 "
36 elif [[ $type = "KEY" ]] || [[ $type = "BTN" ]]; then
37 if [[ $name != "KEY_MIN_INTERESTING" ]]; then
38 keys="${keys} [${name}] = \"${name}\",
39 "
40 fi
41 elif [[ $type = "REL" ]]; then
42 rels="${rels} [${name}] = \"${name}\",
43 "
44 elif [[ $type = "ABS" ]]; then
45 abss="${abss} [${name}] = \"${name}\",
46 "
47 elif [[ $type = "SW" ]]; then
48 sws="${sws} [${name}] = \"${name}\",
49 "
50 elif [[ $type = "MSC" ]]; then
51 mscs="${mscs} [${name}] = \"${name}\",
52 "
53 elif [[ $type = "LED" ]]; then
54 leds="${leds} [${name}] = \"${name}\",
55 "
56 elif [[ $type = "REP" ]]; then
57 reps="${reps} [${name}] = \"${name}\",
58 "
59 elif [[ $type = "SND" ]]; then
60 snds="${snds} [${name}] = \"${name}\",
61 "
62 elif [[ $type = "FF_STATUS" ]]; then
63 ffstatuss="${ffstatuss} [${name}] = \"${name}\",
64 "
65 fi
66 fi
67 done < <(cat "${INPUTS[@]}")
68  
69 (
70 echo "
71 static const char *type_names[] = {
72 ${types}};
73  
74 static const char *syn_names[] = {
75 ${syns}};
76  
77 static const char *key_names[] = {
78 ${keys}};
79  
80 static const char *rel_names[] = {
81 ${rels}};
82  
83 static const char *abs_names[] = {
84 ${abss}};
85  
86 static const char *sw_names[] = {
87 ${sws}};
88  
89 static const char *msc_names[] = {
90 ${mscs}};
91  
92 static const char *led_names[] = {
93 ${leds}};
94  
95 static const char *rep_names[] = {
96 ${reps}};
97  
98 static const char *snd_names[] = {
99 ${snds}};
100  
101 static const char *ffstatus_names[] = {
102 ${ffstatuss}};
103 "
104 ) >"${OUTPUT}"