loadkmap.c revision 1.7 1 /* $NetBSD: loadkmap.c,v 1.7 2004/05/12 14:25:08 minoura Exp $ */
2 /*
3 * loadkmap - load keyboard map (for NetBSD/X680x0)
4 * from: amiga/stand/loadkmap/loadkmap.c
5 * Copyright 1994 by Masaru Oki
6 */
7
8 #include <sys/cdefs.h>
9 __RCSID("$NetBSD: loadkmap.c,v 1.7 2004/05/12 14:25:08 minoura Exp $");
10
11 #include <stdio.h>
12 #include <sys/types.h>
13 #include <sys/ioctl.h>
14 #include <machine/kbdmap.h>
15 #include <machine/iteioctl.h>
16
17 void load_kmap(const char *);
18
19 int
20 main(int argc, char *argv[])
21 {
22
23 if (argc != 2) {
24 fprintf(stderr, "Usage: %s kmapfile\n", argv[0]);
25 exit (1);
26 }
27
28 load_kmap(argv[1]);
29 exit(0);
30 }
31
32 void
33 load_kmap(const char *file)
34 {
35 unsigned char buf[sizeof(struct kbdmap)];
36 int fd;
37
38 if ((fd = open(file, 0)) >= 0) {
39 if (read(fd, buf, sizeof(buf)) == sizeof(buf)) {
40 if (ioctl(0, ITEIOCSKMAP, buf) == 0)
41 return;
42 else
43 perror("ITEIOCSKMAP");
44 } else {
45 perror("read kbdmap");
46 }
47
48 close (fd);
49 } else {
50 perror("open kbdmap");
51 }
52 }
53