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