summaryrefslogtreecommitdiff
path: root/com32/modules/kbdmap.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-02-03 22:09:45 -0800
committerH. Peter Anvin <hpa@zytor.com>2009-02-03 22:09:45 -0800
commit2b02abdaa91f41235f40f846d08bb09d8841baa6 (patch)
treef19f6cabf0f1a2b6e4227bbb2c9901f30991ef57 /com32/modules/kbdmap.c
parentfd3b1f970c6385d178762fb5cfe922a2930d0cad (diff)
downloadsyslinux-2b02abdaa91f41235f40f846d08bb09d8841baa6.tar.gz
kbdmap.c32: new module to load a keyboard map dynamically
Load a new keyboard map dynamically
Diffstat (limited to 'com32/modules/kbdmap.c')
-rw-r--r--com32/modules/kbdmap.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/com32/modules/kbdmap.c b/com32/modules/kbdmap.c
new file mode 100644
index 00000000..39d7301c
--- /dev/null
+++ b/com32/modules/kbdmap.c
@@ -0,0 +1,56 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2009 H. Peter Anvin - All Rights Reserved
+ *
+ * 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;
+}
+
+