1 /* $NetBSD: loadkmap.c,v 1.5 2003/05/17 10:37:56 isaki 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 <stdio.h> 9 #include <sys/types.h> 10 #include <sys/ioctl.h> 11 #define ITEKANJI 1 /* XXX */ 12 #include <machine/iteioctl.h> 13 #include "kbdmap.h" 14 15 void load_kmap(const char *); 16 17 int 18 main(int argc, char *argv[]) 19 { 20 21 if (argc != 2) { 22 fprintf(stderr, "Usage: %s kmapfile\n", argv[0]); 23 exit (1); 24 } 25 26 load_kmap(argv[1]); 27 exit(0); 28 } 29 30 void 31 load_kmap(const char *file) 32 { 33 unsigned char buf[sizeof(struct kbdmap)]; 34 int fd; 35 36 if ((fd = open(file, 0)) >= 0) { 37 if (read(fd, buf, sizeof(buf)) == sizeof(buf)) { 38 if (ioctl(0, ITEIOCSKMAP, buf) == 0) 39 return; 40 else 41 perror("ITEIOCSKMAP"); 42 } else { 43 perror("read kbdmap"); 44 } 45 46 close (fd); 47 } else { 48 perror("open kbdmap"); 49 } 50 } 51