diff options
author | Mark Purcell <msp@debian.org> | 2008-06-22 11:00:40 +1000 |
---|---|---|
committer | etobi <git@e-tobi.net> | 2013-09-03 09:48:42 +0200 |
commit | 891c51ff368ed700dec6025eeb47ce4d96f76418 (patch) | |
tree | 3729664829e4faa691d403274f38eb10890b533c /util/av7110_loadkeys/av7110_loadkeys.c | |
parent | 1c6e1f28f54ec2606c23936c1d8689f2be55a86c (diff) | |
parent | ab959d7b4194715870128e616b8e29d4a101e488 (diff) | |
download | linux-dvb-apps-debian/1.1.1+rev1207-1.tar.gz |
Imported Debian patch 1.1.1+rev1207-1debian/1.1.1+rev1207-1
Diffstat (limited to 'util/av7110_loadkeys/av7110_loadkeys.c')
-rw-r--r-- | util/av7110_loadkeys/av7110_loadkeys.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/util/av7110_loadkeys/av7110_loadkeys.c b/util/av7110_loadkeys/av7110_loadkeys.c index e9eeea0..793862f 100644 --- a/util/av7110_loadkeys/av7110_loadkeys.c +++ b/util/av7110_loadkeys/av7110_loadkeys.c @@ -33,9 +33,10 @@ void print_error (const char *action, const char *file) static int parse_keyname (char *pos, char **nend, int limit) { - int cmp, index; + int cmp, _index; int l = 1; - int r = sizeof (key_name) / sizeof (key_name[0]); + const struct input_key_name *kn; + int r; if (limit < 5) return -1; @@ -46,7 +47,18 @@ int parse_keyname (char *pos, char **nend, int limit) limit--; } - if (pos [0] != 'K' || pos[1] != 'E' || pos[2] != 'Y' || pos[3] != '_') + if (pos[3] != '_') + return -2; + + if (pos[0] == 'K' && pos[1] == 'E' && pos[2] == 'Y') { + kn = key_name; + r = sizeof (key_name) / sizeof (key_name[0]); + } + else if (pos[0] == 'B' && pos[1] == 'T' && pos[2] == 'N') { + kn = btn_name; + r = sizeof (btn_name) / sizeof (btn_name[0]); + } + else return -2; (*nend) += 4; @@ -56,21 +68,21 @@ int parse_keyname (char *pos, char **nend, int limit) while (r >= l) { int len0, len1 = 0; - index = (l + r) / 2; - - len0 = strlen(key_name[index-1].name); + _index = (l + r) / 2; + + len0 = strlen(kn[_index-1].name); while (len1 < limit && isgraph(pos[len1])) len1++; - cmp = strncmp (key_name[index-1].name, pos, - strlen(key_name[index-1].name)); - + cmp = strncmp (kn[_index-1].name, pos, + strlen(kn[_index-1].name)); + if (len0 < len1 && cmp == 0) cmp = -1; if (cmp == 0) { - *nend = pos + strlen (key_name[index-1].name); + *nend = pos + strlen (kn[_index-1].name); if (**nend != '\n' && **nend != '\t' && @@ -78,13 +90,13 @@ int parse_keyname (char *pos, char **nend, int limit) *nend != pos) return -3; - return key_name[index-1].key; + return kn[_index-1].key; } if (cmp < 0) - l = index + 1; + l = _index + 1; else - r = index - 1; + r = _index - 1; if (r < l) { static const char msg [] = "\nunknown key '"; @@ -151,18 +163,18 @@ int main (int argc, char **argv) while (pos < buf + len) { int key, keycode; - + while (!isxdigit(*pos) && pos < buf + len) pos++; if (pos == buf + len) break; - + key = strtol (pos, &pos, 0); keycode = parse_keyname (pos, &pos, buf + len - pos); if (key < 0 || key > 0xff) { - const char msg [] = + const char msg [] = "\nERROR: key must be in range 0 ... 0xff!\n\n"; write (0, msg, strlen(msg)); @@ -174,7 +186,7 @@ int main (int argc, char **argv) setup.keytab[key] = keycode; } - + munmap (buf, len); close (fd); @@ -182,5 +194,3 @@ int main (int argc, char **argv) return 0; } - - |