2 # --------------------------------------------------------------------------
3 # This program was taken from the LILO-20 distribution; only this header
6 # LILO program code, documentation and auxiliary programs are
7 # Copyright 1992-1997 Werner Almesberger.
10 # Redistribution and use in source and binary forms of parts of or the
11 # whole original or derived work are permitted provided that the
12 # original work is properly attributed to the author. The name of the
13 # author may not be used to endorse or promote products derived from
14 # this software without specific prior written permission. This work
15 # is provided "as is" and without any express or implied warranties.
16 # --------------------------------------------------------------------------
18 eval { use bytes
; }; eval { binmode STDOUT
; };
20 $DEFAULT_PATH = "/usr/lib/kbd/keytables";
22 $DEFAULT_EXT = ".map";
27 "usage: $0 [ -p old_code=new_code ] ...\n".
28 (" "x
(8+length $0))."[path]default_layout[.map] ] ".
29 "[path]kbd_layout[.map]\n";
34 while ($ARGV[0] eq "-p") {
36 &usage
unless $ARGV[0] =~ /=/;
37 $table[eval($`)] = eval($');
40 &usage unless defined $ARGV[0];
41 load_map("def",defined $ARGV[1] ? $ARGV[0] : undef);
42 load_map("kbd",defined $ARGV[1] ? $ARGV[1] : $ARGV[0]);
43 &build_table("plain","shift","ctrl","altgr","shift_ctrl",
44 "altgr_ctrl","alt","shift_alt","ctrl_alt");
45 for ($i = 0; $i < 256; $i++) {
46 printf("%c",$table[$i] ? $table[$i] : $i) || die "print: $!";
48 close STDOUT || die "close: $!";
53 local ($pfx,$map) = @_;
54 local ($empty,$current);
56 $map = $DEFAULT_MAP unless defined $map;
57 $map = $DEFAULT_PATH."/".$map unless $map =~ m|/|;
58 $map .= $DEFAULT_EXT unless $map =~ m|/[^/]+\.[^/]+$|;
59 if (!open(FILE,"loadkeys -m $map |")) {
60 print STDERR "loadkeys -m $map: $!\n";
67 if (/^u_short\s+(\S+)_map\[\S+\]\s+=\s+{\s*$/) {
68 die "active at beginning of map" if defined $current;
69 $current = $pfx.":".$1;
72 undef $current if /^};\s*$/;
73 next unless defined $current;
80 print STDERR "Keymap is empty\n";
93 for (split(",",$map{"def:".$map})) {
94 die "bad map entry $_ (def, map $map)" unless /^0x\S\S(\S\S)$/;
95 $tmp[$code] = hex $1 unless $tmp[$code];
103 for (split(",",$map{"kbd:".$map})) {
104 die "bad map entry $_ (kbd, map $map)" unless /^0x\S\S(\S\S)$/;
105 $table[$tmp[$code]] = hex $1 unless $table[$tmp[$code]];