diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2009-07-18 14:27:50 +0200 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2009-07-18 14:27:50 +0200 |
commit | b02c9fa19bb3da9cd1c4684322333732cc2996de (patch) | |
tree | 5714067fd107a58638c802e0a73448c4c64d7d95 /extras/keymap/keymap.c | |
parent | acdf6ae7ac401d502359c29cbc5ada6f5fb6344c (diff) |
keymap tool: improve help
Do not duplicate help strings, and add missing calling variant for
interactivity.
Diffstat (limited to 'extras/keymap/keymap.c')
-rw-r--r-- | extras/keymap/keymap.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/extras/keymap/keymap.c b/extras/keymap/keymap.c index b708f38e7b..8fc731debf 100644 --- a/extras/keymap/keymap.c +++ b/extras/keymap/keymap.c @@ -272,6 +272,19 @@ static void interactive(int fd) ioctl(fd, EVIOCGRAB, 0); } +static void help(int error) +{ + const char* h = "Usage: keymap <event device> [<map file>]\n" + " keymap -i <event device>\n"; + if (error) { + fputs(h, stderr); + exit(2); + } else { + fputs(h, stdout); + exit(0); + } +} + int main(int argc, char **argv) { static const struct option options[] = { @@ -291,8 +304,7 @@ int main(int argc, char **argv) switch (option) { case 'h': - printf("Usage: keymap <event device> [<map file>]\n\n"); - return 0; + help(0); case 'i': opt_interactive = 1; @@ -302,10 +314,8 @@ int main(int argc, char **argv) } } - if (argc < optind+1 || argc > optind+2) { - fprintf(stderr, "Usage: keymap <event device> [<map file>]\n\n"); - return 2; - } + if (argc < optind+1 || argc > optind+2) + help (1); if ((fd = evdev_open(argv[optind])) < 0) return 3; |