diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-04-19 03:59:10 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-04-19 03:59:10 +0000 |
commit | 3fe7f9f20b6562e667ff3c9388a6ce00bd1ba19f (patch) | |
tree | 98c78a2d9487f52752ed3057d9dd233be6f65161 /console-tools/loadkmap.c | |
parent | a3e57ca7008cbaf612675b9de3dd18109f8150de (diff) | |
download | busybox-w32-3fe7f9f20b6562e667ff3c9388a6ce00bd1ba19f.tar.gz busybox-w32-3fe7f9f20b6562e667ff3c9388a6ce00bd1ba19f.tar.bz2 busybox-w32-3fe7f9f20b6562e667ff3c9388a6ce00bd1ba19f.zip |
More minor updates to docs (and making apps behave as the docs
suggest they should)
-Erik
Diffstat (limited to 'console-tools/loadkmap.c')
-rw-r--r-- | console-tools/loadkmap.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c index fe533d522..75e52e148 100644 --- a/console-tools/loadkmap.c +++ b/console-tools/loadkmap.c | |||
@@ -29,11 +29,8 @@ | |||
29 | #include <sys/ioctl.h> | 29 | #include <sys/ioctl.h> |
30 | 30 | ||
31 | 31 | ||
32 | static const char loadkmap_usage[] = "loadkmap\n" | 32 | static const char loadkmap_usage[] = "loadkmap\n\n" |
33 | "\n" | 33 | "Loads a binary keyboard translation table from standard input.\n"; |
34 | |||
35 | "\tLoad a binary keyboard translation table from standard input.\n" | ||
36 | "\n"; | ||
37 | 34 | ||
38 | 35 | ||
39 | int loadkmap_main(int argc, char **argv) | 36 | int loadkmap_main(int argc, char **argv) |
@@ -43,28 +40,32 @@ int loadkmap_main(int argc, char **argv) | |||
43 | int i, j, fd, readsz, pos, ibuffsz = NR_KEYS * sizeof(u_short); | 40 | int i, j, fd, readsz, pos, ibuffsz = NR_KEYS * sizeof(u_short); |
44 | char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap", buff[7]; | 41 | char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap", buff[7]; |
45 | 42 | ||
43 | if (argc>=2 && *argv[1]=='-') { | ||
44 | usage(loadkmap_usage); | ||
45 | } | ||
46 | |||
46 | fd = open("/dev/tty0", O_RDWR); | 47 | fd = open("/dev/tty0", O_RDWR); |
47 | if (fd < 0) { | 48 | if (fd < 0) { |
48 | fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); | 49 | fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); |
49 | return 1; | 50 | exit(FALSE); |
50 | } | 51 | } |
51 | 52 | ||
52 | read(0, buff, 7); | 53 | read(0, buff, 7); |
53 | if (0 != strncmp(buff, magic, 7)) { | 54 | if (0 != strncmp(buff, magic, 7)) { |
54 | fprintf(stderr, "This is not a valid binary keymap.\n"); | 55 | fprintf(stderr, "This is not a valid binary keymap.\n"); |
55 | return 1; | 56 | exit(FALSE); |
56 | } | 57 | } |
57 | 58 | ||
58 | if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) { | 59 | if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) { |
59 | fprintf(stderr, "Error reading keymap flags: %s\n", | 60 | fprintf(stderr, "Error reading keymap flags: %s\n", |
60 | strerror(errno)); | 61 | strerror(errno)); |
61 | return 1; | 62 | exit(FALSE); |
62 | } | 63 | } |
63 | 64 | ||
64 | ibuff = (u_short *) malloc(ibuffsz); | 65 | ibuff = (u_short *) malloc(ibuffsz); |
65 | if (!ibuff) { | 66 | if (!ibuff) { |
66 | fprintf(stderr, "Out of memory.\n"); | 67 | fprintf(stderr, "Out of memory.\n"); |
67 | return 1; | 68 | exit(FALSE); |
68 | } | 69 | } |
69 | 70 | ||
70 | for (i = 0; i < MAX_NR_KEYMAPS; i++) { | 71 | for (i = 0; i < MAX_NR_KEYMAPS; i++) { |
@@ -75,7 +76,7 @@ int loadkmap_main(int argc, char **argv) | |||
75 | < 0) { | 76 | < 0) { |
76 | fprintf(stderr, "Error reading keymap: %s\n", | 77 | fprintf(stderr, "Error reading keymap: %s\n", |
77 | strerror(errno)); | 78 | strerror(errno)); |
78 | return 1; | 79 | exit(FALSE); |
79 | } | 80 | } |
80 | pos += readsz; | 81 | pos += readsz; |
81 | } | 82 | } |
@@ -90,5 +91,5 @@ int loadkmap_main(int argc, char **argv) | |||
90 | /* Don't bother to close files. Exit does that | 91 | /* Don't bother to close files. Exit does that |
91 | * automagically, so we can save a few bytes */ | 92 | * automagically, so we can save a few bytes */ |
92 | /* close(fd); */ | 93 | /* close(fd); */ |
93 | return 0; | 94 | exit(TRUE); |
94 | } | 95 | } |