diff options
| author | Eric Andersen <andersen@codepoet.org> | 1999-10-05 16:24:54 +0000 |
|---|---|---|
| committer | Eric Andersen <andersen@codepoet.org> | 1999-10-05 16:24:54 +0000 |
| commit | cc8ed39b240180b58810784f844e253263594ac3 (patch) | |
| tree | 15feebbb4be9a9168209609f48f0b100f9364420 /console-tools | |
| download | busybox-w32-0_29alpha2.tar.gz busybox-w32-0_29alpha2.tar.bz2 busybox-w32-0_29alpha2.zip | |
Initial revision0_29alpha2
Diffstat (limited to 'console-tools')
| -rw-r--r-- | console-tools/clear.c | 13 | ||||
| -rw-r--r-- | console-tools/loadkmap.c | 68 |
2 files changed, 81 insertions, 0 deletions
diff --git a/console-tools/clear.c b/console-tools/clear.c new file mode 100644 index 000000000..21a890c9e --- /dev/null +++ b/console-tools/clear.c | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | #include "internal.h" | ||
| 2 | #include <stdio.h> | ||
| 3 | |||
| 4 | const char clear_usage[] = "clear\n" | ||
| 5 | "\n" | ||
| 6 | "\tClears the screen.\n"; | ||
| 7 | |||
| 8 | extern int | ||
| 9 | clear_main(struct FileInfo * i, int argc, char * * argv) | ||
| 10 | { | ||
| 11 | printf("\033[H\033[J"); | ||
| 12 | return 0; | ||
| 13 | } | ||
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c new file mode 100644 index 000000000..0f092d193 --- /dev/null +++ b/console-tools/loadkmap.c | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | #include "internal.h" | ||
| 2 | #include <errno.h> | ||
| 3 | #include <fcntl.h> | ||
| 4 | #include <stdio.h> | ||
| 5 | #include <linux/kd.h> | ||
| 6 | #include <linux/keyboard.h> | ||
| 7 | #include <sys/ioctl.h> | ||
| 8 | |||
| 9 | |||
| 10 | const char loadkmap_usage[] = "loadkmap\n" | ||
| 11 | "\n" | ||
| 12 | "\tLoad a binary keyboard translation table from standard input.\n" | ||
| 13 | "\n"; | ||
| 14 | |||
| 15 | |||
| 16 | int | ||
| 17 | loadkmap_main(struct FileInfo * info, int argc, char * * argv) | ||
| 18 | { | ||
| 19 | struct kbentry ke; | ||
| 20 | u_short *ibuff; | ||
| 21 | int i,j,fd,readsz,pos,ibuffsz=NR_KEYS * sizeof(u_short); | ||
| 22 | char flags[MAX_NR_KEYMAPS],magic[]="bkeymap",buff[7]; | ||
| 23 | |||
| 24 | fd = open("/dev/tty0", O_RDWR); | ||
| 25 | if (fd < 0) { | ||
| 26 | fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); | ||
| 27 | return 1; | ||
| 28 | } | ||
| 29 | |||
| 30 | read(0,buff,7); | ||
| 31 | if (0 != strncmp(buff,magic,7)) { | ||
| 32 | fprintf(stderr, "This is not a valid binary keymap.\n"); | ||
| 33 | return 1; | ||
| 34 | } | ||
| 35 | |||
| 36 | if ( MAX_NR_KEYMAPS != read(0,flags,MAX_NR_KEYMAPS) ) { | ||
| 37 | fprintf(stderr, "Error reading keymap flags: %s\n", strerror(errno)); | ||
| 38 | return 1; | ||
| 39 | } | ||
| 40 | |||
| 41 | ibuff=(u_short *) malloc(ibuffsz); | ||
| 42 | if (!ibuff) { | ||
| 43 | fprintf(stderr, "Out of memory.\n"); | ||
| 44 | return 1; | ||
| 45 | } | ||
| 46 | |||
| 47 | for(i=0; i<MAX_NR_KEYMAPS; i++) { | ||
| 48 | if (flags[i]==1){ | ||
| 49 | pos=0; | ||
| 50 | while (pos < ibuffsz) { | ||
| 51 | if ( (readsz = read(0,ibuff+pos,ibuffsz-pos)) < 0 ) { | ||
| 52 | fprintf(stderr, "Error reading keymap: %s\n", | ||
| 53 | strerror(errno)); | ||
| 54 | return 1; | ||
| 55 | } | ||
| 56 | pos += readsz; | ||
| 57 | } | ||
| 58 | for(j=0; j<NR_KEYS; j++) { | ||
| 59 | ke.kb_index = j; | ||
| 60 | ke.kb_table = i; | ||
| 61 | ke.kb_value = ibuff[j]; | ||
| 62 | ioctl(fd, KDSKBENT, &ke); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | } | ||
| 66 | close (fd); | ||
| 67 | return 0; | ||
| 68 | } | ||
