*
*/
-#include "internal.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
#include <sys/ioctl.h>
+#include "busybox.h"
/* From <linux/kd.h> */
struct kbentry {
unsigned char kb_index;
unsigned short kb_value;
};
-#define KDGKBENT 0x4B46 /* gets one entry in translation table */
+static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
/* From <linux/keyboard.h> */
-#define NR_KEYS 128
-#define MAX_NR_KEYMAPS 256
-
-
-static const char dumpkmap_usage[] = "dumpkmap\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nPrints out a binary keyboard translation table to standard input.\n"
-#endif
- ;
-
+static const int NR_KEYS = 128;
+static const int MAX_NR_KEYMAPS = 256;
int dumpkmap_main(int argc, char **argv)
{
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
if (argc>=2 && *argv[1]=='-') {
- usage(dumpkmap_usage);
+ show_usage();
}
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
- errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
- return 1;
+ perror_msg("Error opening /dev/tty0");
+ return EXIT_FAILURE;
}
write(1, magic, 7);
ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) {
- errorMsg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
+ error_msg("ioctl returned: %s, %s, %s, %xqq", strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
}
else {
- write(1,&ke.kb_value,2);
+ write(1,(void*)&ke.kb_value,2);
}
}
}
}
close(fd);
- return 0;
+ return EXIT_SUCCESS;
}