summaryrefslogtreecommitdiffstats
path: root/contrib/syslinux-4.02/com32/modules/kbdmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/syslinux-4.02/com32/modules/kbdmap.c')
-rw-r--r--contrib/syslinux-4.02/com32/modules/kbdmap.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/contrib/syslinux-4.02/com32/modules/kbdmap.c b/contrib/syslinux-4.02/com32/modules/kbdmap.c
new file mode 100644
index 0000000..f1c736d
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/modules/kbdmap.c
@@ -0,0 +1,54 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2009 Intel Corporation; author: H. Peter Anvin
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston MA 02110-1301, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include <stdio.h>
+#include <string.h>
+#include <console.h>
+#include <syslinux/loadfile.h>
+#include <syslinux/keyboard.h>
+
+static inline void error(const char *msg)
+{
+ fputs(msg, stderr);
+}
+
+int main(int argc, char *argv[])
+{
+ const struct syslinux_keyboard_map *const kmap = syslinux_keyboard_map();
+ size_t map_size;
+ void *kbdmap;
+
+ openconsole(&dev_null_r, &dev_stdcon_w);
+
+ if (argc != 2) {
+ error("Usage: kbdmap mapfile\n");
+ return 1;
+ }
+
+ if (kmap->version != 1) {
+ error("Syslinux core version mismatch\n");
+ return 1;
+ }
+
+ if (loadfile(argv[1], &kbdmap, &map_size)) {
+ error("Keyboard map file load error\n");
+ return 1;
+ }
+
+ if (map_size != kmap->length) {
+ error("Keyboard map file format error\n");
+ return 1;
+ }
+
+ memcpy(kmap->map, kbdmap, map_size);
+ return 0;
+}