loadkmap.c revision 1.1
1/* $NetBSD: loadkmap.c,v 1.1 1995/07/03 20:49:40 leo Exp $ */ 2 3#include <sys/types.h> 4#include <sys/stat.h> 5#include <sys/ioctl.h> 6#include "../../dev/iteioctl.h" 7#include "../../dev/kbdmap.h" 8#include <stdio.h> 9 10 11void load_kmap __P((const char *)); 12void dump_kmap(); 13 14int 15main(argc, argv) 16 int argc; 17 char *argv[]; 18{ 19 if (argc > 2) 20 { 21 fprintf (stderr, "%s keymap\n", argv[0]); 22 exit (1); 23 } 24 25 if (argc == 1) 26 dump_kmap (); 27 else 28 load_kmap (argv[1]); 29 30 exit (0); 31} 32 33 34void 35load_kmap (file) 36 const char *file; 37{ 38 int fd; 39 char buf[sizeof (struct kbdmap)]; 40 41 if ((fd = open (file, 0)) >= 0) 42 { 43 if (read (fd, buf, sizeof (buf)) == sizeof (buf)) 44 { 45 if (ioctl (0, ITEIOCSKMAP, buf) == 0) 46 return; 47 else 48 perror ("ITEIOCSKMAP"); 49 } 50 else 51 perror ("read kmap"); 52 53 close (fd); 54 } 55 else 56 perror ("open kmap"); 57} 58 59void 60dump_kmap() 61{ 62 char buf[sizeof (struct kbdmap)]; 63 if (ioctl (0, ITEIOCGKMAP, buf) == 0) 64 write (1, buf, sizeof (buf)); 65 else 66 perror ("ITEIOCGKMAP"); 67} 68