1 /* $NetBSD: loadkmap.c,v 1.7 2009/03/14 21:04:07 dsl Exp $ */
6 #include "../../dev/iteioctl.h"
7 #include "../../dev/kbdmap.h"
12 int load_kmap(const char *, int);
16 main(int argc
, char *argv
[])
23 if ((argc
== 3) && !strcmp(argv
[1], "-f")) {
28 fprintf(stderr
, "%s [-f] keymap\n", argv
[0]);
32 else mapfile
= argv
[1];
36 else rc
= load_kmap(mapfile
, set_sysmap
);
43 load_kmap(const char *file
, int set_sysmap
)
46 char buf
[sizeof (struct kbdmap
)];
49 ioc
= set_sysmap
? ITEIOCSSKMAP
: ITEIOCSKMAP
;
51 if ((fd
= open (file
, 0)) >= 0) {
52 if (read (fd
, buf
, sizeof (buf
)) == sizeof (buf
)) {
53 if (ioctl (0, ioc
, buf
) == 0) {
57 else perror("ITEIOCSKMAP");
59 else perror("read kmap");
63 else perror("open kmap");
70 char buf
[sizeof (struct kbdmap
)];
72 if (ioctl (0, ITEIOCGKMAP
, buf
) == 0) {
73 write (1, buf
, sizeof (buf
));
76 perror ("ITEIOCGKMAP");