1994-10-26 05:01:24 +03:00
|
|
|
/* $NetBSD: loadkmap.c,v 1.4 1994/10/26 02:07:09 cgd Exp $ */
|
1994-02-11 10:00:37 +03:00
|
|
|
|
1993-09-02 20:52:31 +04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include "../../dev/iteioctl.h"
|
|
|
|
#include "../../dev/kbdmap.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
|
|
void load_kmap __P((const char *));
|
|
|
|
void dump_kmap();
|
|
|
|
|
|
|
|
int
|
|
|
|
main(argc, argv)
|
|
|
|
int argc;
|
|
|
|
char *argv[];
|
|
|
|
{
|
|
|
|
if (argc > 2)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "%s keymap\n", argv[0]);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc == 1)
|
|
|
|
dump_kmap ();
|
|
|
|
else
|
|
|
|
load_kmap (argv[1]);
|
|
|
|
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
load_kmap (file)
|
|
|
|
const char *file;
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
char buf[sizeof (struct kbdmap)];
|
|
|
|
|
|
|
|
if ((fd = open (file, 0)) >= 0)
|
|
|
|
{
|
|
|
|
if (read (fd, buf, sizeof (buf)) == sizeof (buf))
|
|
|
|
{
|
1994-05-11 23:09:29 +04:00
|
|
|
if (ioctl (0, ITEIOCSKMAP, buf) == 0)
|
1993-09-02 20:52:31 +04:00
|
|
|
return;
|
|
|
|
else
|
1994-05-11 23:09:29 +04:00
|
|
|
perror ("ITEIOCSKMAP");
|
1993-09-02 20:52:31 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
perror ("read kmap");
|
|
|
|
|
|
|
|
close (fd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
perror ("open kmap");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dump_kmap()
|
|
|
|
{
|
|
|
|
char buf[sizeof (struct kbdmap)];
|
1994-05-11 23:09:29 +04:00
|
|
|
if (ioctl (0, ITEIOCGKMAP, buf) == 0)
|
1993-09-02 20:52:31 +04:00
|
|
|
write (1, buf, sizeof (buf));
|
|
|
|
else
|
1994-05-11 23:09:29 +04:00
|
|
|
perror ("ITEIOCGKMAP");
|
1993-09-02 20:52:31 +04:00
|
|
|
}
|