home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / sysv386 / 12421 < prev    next >
Encoding:
Internet Message Format  |  1992-07-25  |  37.2 KB

  1. Xref: sparky comp.unix.sysv386:12421 alt.sources:1757
  2. Path: sparky!uunet!mcsun!uknet!dcl-cs!gdt!aber!aberfa!pcg
  3. From: pcg@aber.ac.uk (Piercarlo Grandi)
  4. Newsgroups: comp.unix.sysv386,alt.sources
  5. Subject: A mapkey(1) clone that works!
  6. Message-ID: <PCG.92Jul25132605@aberdb.aber.ac.uk>
  7. Date: 25 Jul 92 13:26:05 GMT
  8. References: <stritzi.711924024@Physik.TU-Muenchen.DE> <1992Jul24.192412.28726@crd.ge.com>
  9. Sender: news@aber.ac.uk (USENET news service)
  10. Reply-To: pcg@aber.ac.uk (Piercarlo Grandi)
  11. Organization: Coleg Prifysgol Cymru
  12. Lines: 1459
  13. In-Reply-To: davidsen@ariel.crd.GE.COM's message of 24 Jul 92 19: 24:12 GMT
  14. Nntp-Posting-Host: aberdb
  15. X-Old-Subject: Re: DELL UNIX SysVr4 and ttydefs
  16.  
  17. On 24 Jul 92 19:24:12 GMT, davidsen@ariel.crd.GE.COM (william E Davidsen) said:
  18.  
  19. davidsen> To change what keys generate you use a map??? program.
  20.  
  21. Unfortunately most mapkey programs for SVR4 and SVR3 are creepy.
  22. Here follows a shar archive with my own mapkbd(1) program.
  23.  
  24. It is a drop in replacement for mapkey(1), but with several bug fixes
  25. and extensions. Among these:
  26.  
  27. * it allows to set keys to generate "meta" (high bit turned on)
  28.   characters, and indeed with option '-m' will automatically set up the
  29.   keyboard to do so;
  30.  
  31. * with option '-i' it can load incrementally several key definition
  32.   files, and the last key definition encounted for a given key code
  33.   prevails.
  34.  
  35. I have enclosed sample keyboard mapping files; in particular for the US
  36. keyboard with meta keys (and some extra keys to switch VTs), and key
  37. redefinitions for the UK and IT keyboards.
  38.  
  39. Copyright notice: this program is copyrighted by me and can be copied
  40. in accordance with the GNU public license, version 2 or later.
  41.  
  42. This programs comes with NO WARRANTY implied or otherwise; it is not
  43. error free, and there is no promise of corrections or support.
  44.  
  45. Finally, the usual disclaimer:
  46.  
  47.   This program has been written entirely by me, with the use of my own
  48.   resources, money and time. It is in no way related or supported by the
  49.   the University of Wales, Aberystwyth, and its activities and research
  50.   in Computer Science or otherwise. I thank them profusely for allowing
  51.   me to post such materials to this net.
  52.  
  53. -------------------------cut here-------------------------------------
  54. #! /bin/sh
  55. # This is a shell archive.  Remove anything before this line, then unpack
  56. # it by saving it into a file and typing "sh file".  To overwrite existing
  57. # files, type "sh file -c".  You can also feed this as standard input via
  58. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  59. # will see the following message at the end:
  60. #        "End of archive 1 (of 1)."
  61. # Contents:  ita-meta.kbd mapkbd.1 mapkbd.c ukd-meta.kbd usa-meta.kbd
  62. # Wrapped by pcg@aberdb on Sat Jul 25 13:19:16 1992
  63. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  64. if test -f 'ita-meta.kbd' -a "${1}" != "-c" ; then 
  65.   echo shar: Will not clobber existing file \"'ita-meta.kbd'\"
  66. else
  67. echo shar: Extracting \"'ita-meta.kbd'\" \(841 characters\)
  68. sed "s/^X//" >'ita-meta.kbd' <<'END_OF_FILE'
  69. X# Italian keyboard
  70. X
  71. X3    '2'    '"'    nop    nop    0xb2    0xa2    nop    nop    O
  72. X# simbolo di lira
  73. X4    '3'    0x9c    nop    nop    0xb3    '#'    nop    nop    O
  74. X7    '6'    '&'    nop    nop    0xb6    0xa6    rs    rs    O
  75. X8    '7'    '/'    nop    ns    0xb7    0xaf    nop    0x9f    O
  76. X9    '8'    '('    nop    nop    0xb8    0xa8    nop    nop    O
  77. X10    '9'    ')'    nop    nop    0xb9    0xa9    nop    nop    O
  78. X11    '0'    '='    nop    nop    0xb0    0xbd    nop    nop    O
  79. X12    '\''    '?'    del    del    0xa7    0xbf    0xff    0xff    O
  80. X# u accentata
  81. X13    0x8d    '^'    rs    rs    '~'    0xde    0x9e    0x9e    O
  82. X# e accentata lunga e breve
  83. X26    0x8a    0x82    nop    nop    '['    '{'    esc    esc    O
  84. X27    '+'    '*'    nop    nop    ']'    '}'    gs    gs    O
  85. X# o accentata
  86. X39    0x95    '@'    nul    nul    '@'    0xc0    0x80    0x80    O
  87. X# a accentata
  88. X40    0x85    '#'    nop    nop    '#'    0xa3    nop    nop    O
  89. X41    '<'    '>'    nop    nop    0xbc    0xbe    nop    nop    O
  90. X# u accentata e simbolo di paragrafo
  91. X43    0x97    0xb2    nop    nop    '`'    '~'    nul    nul    O
  92. X51    ','    ';'    nop    nop    0xac    0xbb    nop    nop    O
  93. X52    '.'    ':'    nop    nop    0xae    0xba    nop    nop    O
  94. X53    '-'    '_'    ns    ns    0xad    0xdf    0x9f    0x9f    O
  95. END_OF_FILE
  96. if test 841 -ne `wc -c <'ita-meta.kbd'`; then
  97.     echo shar: \"'ita-meta.kbd'\" unpacked with wrong size!
  98. fi
  99. # end of 'ita-meta.kbd'
  100. fi
  101. if test -f 'mapkbd.1' -a "${1}" != "-c" ; then 
  102.   echo shar: Will not clobber existing file \"'mapkbd.1'\"
  103. else
  104. echo shar: Extracting \"'mapkbd.1'\" \(6529 characters\)
  105. sed "s/^X//" >'mapkbd.1' <<'END_OF_FILE'
  106. X.TH MAPKBD 1M
  107. X.ad b
  108. X.SH NAME
  109. Xmapkbd \- remap the keyboard under System V
  110. X.SH SYNOPSYS
  111. X.B mapkbd
  112. X.BR \- [ mcivdox ]
  113. X.BR \-t " path"
  114. X.BR \-T " fd"
  115. X.RB [ \- ]
  116. X[ file ... ]
  117. X.SH DESCRIPTION
  118. XThis program remaps the keyboard under System V. It is an extended
  119. Xclone of
  120. X.IR mapkey (1M).
  121. X.LP
  122. XIt has some additional facilities, the most important of which is that it
  123. Xactually works and does not make a mess of the keyboard mappings like the
  124. XSVR4 supplied one. Among the others are the ability to make the
  125. X.B alt
  126. Xkey into a
  127. X.B meta
  128. Xkey, reading in one go multiple input files, setting the keyboard map
  129. Xassociated to a specified device file or a file descriptor (thus being
  130. Xto read the keymap file from the standard input), and doing a dry run.
  131. X.LP
  132. XThe
  133. X.IR mapkey (1M)
  134. Xcompatible options are:
  135. X.TP
  136. X.BR \- [ dox ]
  137. XDump the now current keymap table to standard output, scancodes in decimal,
  138. Xoctal or hexdecimal respectively.
  139. X.TP
  140. X.B \-m
  141. XIf a non
  142. X.B alt
  143. Xkey combination generates an ASCII character code, the corresponding
  144. X.B alt
  145. Xcombination will generate the same character code with the eight bit set.
  146. XIn other words it makes
  147. X.B alt
  148. Xbecome a
  149. X.B meta
  150. Xkey.
  151. X.TP
  152. X.B \-c
  153. XDon't install the new keymap table into the system; use this option to
  154. Xcheck the syntax of a keymap file.
  155. X.TP
  156. X.B \-i
  157. XDon't clear the current keymap; fetch it first, modify it and then
  158. Xload the modified one. Useful for incremental keymap modification,
  159. Xfor example to modify a single key.
  160. X.TP
  161. X.B \-v
  162. XBe verbose and print a list of the steps being performed by the program.
  163. XMainly useful to understand the complex interplay of the various options.
  164. X.TP
  165. X.BI \-t " path"
  166. XUpdate the keymap table associated with the given device. The device must
  167. Xbe a (virtual) console, and the user must be the superuser.
  168. X.TP
  169. X.BI \-T " fd"
  170. XUpdate the keymap table associated with the given file descriptor.
  171. XThe device accessed via that file descriptor must
  172. Xbe a (virtual) console, and the use must be the superuser. The default
  173. Xis standard input, or file descriptor 0.
  174. X.TP
  175. X.I "file ..."
  176. XThese are the pathnames of the files that contain the scancode tables.
  177. XThe files are read sequentially, and this means that scancode lines in
  178. Xlater files override those in earlier files. If
  179. X.B "\-"
  180. Xis used as pathname, the standard input is used instead. If no name is
  181. Xgiven, the default is the system key table file.
  182. X.SH "INPUT SYNTAX"
  183. XEach line of an input file has ten columns; the first, numeric, is the
  184. Xscancode, (in hex, octal or decimal),
  185. Xthe next eight are for the character codes to generate for the modifier
  186. Xcombinations
  187. X.IR (NONE) ,
  188. X.IR "SHIFT" ,
  189. X.IR "CTRL" ,
  190. X.IR "CTRL-SHIFT" ,
  191. X.IR "ALT" ,
  192. X.IR "ALT-SHIFT" ,
  193. X.IR "ALT-CTRL" ,
  194. X.IR "ALT-CTRL-SHIFT" ,
  195. Xin the given order, and the last column is a single character,
  196. X.I O
  197. Xfor no special casing,
  198. X.I N
  199. Xif the key is affected by the
  200. X.I "NumLock"
  201. Xkey,
  202. X.I "C"
  203. Xif by the
  204. X.I "CapsLock"
  205. Xkey,
  206. Xand
  207. X.I "B"
  208. Xif by both.
  209. X.LP
  210. XThe character code to be generated can be specified as a:
  211. X.TP
  212. X.I number
  213. Xin hex, octal or decimal.
  214. X.TP
  215. X.BI "'" x "'"
  216. Xa literal character .
  217. X.TP
  218. X.BR nul - gs
  219. Xan ascii control character with the names given in
  220. X.I /usr/pub/ascii
  221. Xor some variations like
  222. X.I nl
  223. Xfor line feed,
  224. X.I np
  225. Xfor form feed,
  226. X.I ns
  227. Xfor unit separator.
  228. X.TP
  229. X.I special
  230. Xthe name of an action or effect, with no character code generated. The names
  231. Xare:
  232. X.nf
  233. X.ce 3
  234. Xagr alt break btab clock ctl debug
  235. Xfnscrn fpscrn lalt lctrl lshift nlock nop
  236. Xnscr pscr ralt rctrl reboot rshift slock sysreq
  237. X.fi
  238. X.TP
  239. X.B "fN fO f["
  240. XOne of these keys means to generate the base character code preceded
  241. Xby the escape character and then either
  242. X.B N
  243. Xor
  244. X.B O
  245. Xor
  246. X.BR [ .
  247. XThis is useful for defining function key sequences.
  248. X.TP
  249. X.BI scr number
  250. Xswitch the to the virtual console whose one or two digit
  251. X.I number
  252. Xis given (the main console has number 0).
  253. X.TP
  254. X.BI fkey number
  255. Xreturn the function key string with that
  256. X.IR number .
  257. X.TP
  258. X.BI "^" x
  259. Xan ascii control character.
  260. X.TP
  261. X.BI "C-" x
  262. Xan ascii control character.
  263. X.TP
  264. X.BI "M-" x
  265. Xa meta character.
  266. X.TP
  267. X.BI "M-C-" x
  268. Xa meta control character.
  269. X.SH EXAMPLES
  270. X.LP
  271. XThe first three examples are the same as for
  272. X.I mapkey (1M).
  273. XThe others illustrate new functionality.
  274. X.TP
  275. X.B mapkbd
  276. XIt reads the
  277. Xsystem key table file and sets the standard input keymap table to it.
  278. X.TP
  279. X.B "mapkbd /usr/local/etc/keys.lumbard"
  280. X.br
  281. XIt reads the given symbolic keymap file and sets the standard input
  282. Xkeymap table to it.
  283. X.TP
  284. X.B "mapkbd \-d"
  285. X.br
  286. XDump symbolically to the standard output, in a format suitable for
  287. Xrereading it, the currently installed keymap.
  288. X.TP
  289. X.B "mapkbd \-m file1 file2 file3"
  290. X.br
  291. XInstalls the indicated keymap files, but with the
  292. X.B alt
  293. Xkey as a
  294. X.B meta
  295. Xkey.
  296. X.TP
  297. X.BI "mapkbd \-c \-d " files...
  298. X.br
  299. XRead anch check the given files, and dump the resulting keymap
  300. Xsymbolically to standard output. This can be used to merge several
  301. Xkeymap files. If none given, the default system keymap file is checked
  302. Xand dumped.
  303. X.TP
  304. X.BI "mapkbd \-c \-m \-d" " file"
  305. X.br
  306. XRead and check the given file,
  307. X.I metaize
  308. Xit and dump the resulting keymap
  309. Xsymbolically to standard output. This can be used to add
  310. X.B meta
  311. Xlike bindings to an existing keymap file. If no file name were
  312. Xspecified, the system default file would be used.
  313. X.TP
  314. X.BI "mapkbd \-i keypad-emacs.kb"
  315. X.br
  316. XOverlay the current keymap with the entries contained in the named file,
  317. Xfor example one that redefines only the scancodes belonging to the keypad
  318. Xto values more suitable with
  319. X.IR emacs (1).
  320. X.TP
  321. X.BI "mapkbd \-m"
  322. X.br
  323. XModify the currently installed keymap file so that the
  324. X.B alt
  325. Xkey becomes a
  326. X.B meta
  327. Xkey. Note that this does not load the system default keymap file, it
  328. Xmodifies the currently installed keymap, without reading any file.
  329. X.TP
  330. X.BI "/usr/local/sbin/mapkbd \-m </dev/console >/dev/sysmsg 2>&1"
  331. X.br
  332. XThis is a possible
  333. X.I init.base
  334. Xline to make sure that the default installed keymap is
  335. X.I metaized
  336. Xas it should be... I also add the path of my own map file that contains
  337. Xless convoluted bindings for screen switching.
  338. X.SH AUTHOR
  339. XCopyright 1992 Piercarlo Grandi.
  340. X.SH BUGS
  341. XBecause of compatibility with
  342. X.IR mapkey (1M)
  343. Xthe rules concerning the case where no keymap file name is given are
  344. Xfairly irregular. Basically when
  345. X.B \-c
  346. Xis specified the system default file is loaded, when
  347. X.B \-m
  348. Xis specified the currently installed keymap is read, and so on.
  349. X.LP
  350. XThe input format is (or should be) completely
  351. X.IR mapkey (1M)
  352. Xcompatible, but the output format is not. I have taken the liberty to
  353. Xuse more traditional names for certain ASCII control characters, and for
  354. Xsome specials. This can be easily changed by editing the source.
  355. END_OF_FILE
  356. if test 6529 -ne `wc -c <'mapkbd.1'`; then
  357.     echo shar: \"'mapkbd.1'\" unpacked with wrong size!
  358. fi
  359. # end of 'mapkbd.1'
  360. fi
  361. if test -f 'mapkbd.c' -a "${1}" != "-c" ; then 
  362.   echo shar: Will not clobber existing file \"'mapkbd.c'\"
  363. else
  364. echo shar: Extracting \"'mapkbd.c'\" \(18179 characters\)
  365. sed "s/^X//" >'mapkbd.c' <<'END_OF_FILE'
  366. X#include <string.h>
  367. X#include <stdlib.h>
  368. X#include <search.h>
  369. X#include <ctype.h>
  370. X#include <stdio.h>
  371. X#include <sys/types.h>
  372. X#include <sys/at_ansi.h>
  373. X#include <sys/kd.h>
  374. X
  375. X#define until(pred)    while(!(pred))
  376. X
  377. Xtypedef struct
  378. X{
  379. X  int              value;
  380. X  char              *symbol;
  381. X}
  382. X            assoc_t;
  383. X
  384. Xtypedef enum
  385. X{
  386. X  sort_none,
  387. X  sort_value,
  388. X  sort_symbol,
  389. X}
  390. X            assoc_sort_t;
  391. X
  392. Xstatic int        assoc_value_cmp(elem,table)
  393. X  register assoc_t      *elem,*table;
  394. X{
  395. X  return elem->value - table->value;
  396. X}
  397. X
  398. Xstatic assoc_t        *assoc_find_value(value,assocs,n,sorted)
  399. X  int              value;
  400. X  assoc_t          *assocs;
  401. X  unsigned          n;
  402. X  assoc_sort_t          sorted;
  403. X{
  404. X# if (!DONTSORT)
  405. X   if (sorted == sort_value)
  406. X   {
  407. X     assoc_t              assoc;
  408. X
  409. X     assoc.value = value;
  410. X
  411. X     return
  412. X       (assoc_t *) bsearch
  413. X     (
  414. X       (void *) &assoc,(void *) assocs,n,
  415. X       sizeof (assoc_t),assoc_value_cmp
  416. X     );
  417. X   }
  418. X   else
  419. X# endif
  420. X  {
  421. X    register assoc_t          *assoc;
  422. X
  423. X    for (assoc = assocs; assoc < assocs+n; assoc++)
  424. X      if (assoc->value == value)
  425. X    return assoc;
  426. X
  427. X    return 0;
  428. X  }
  429. X}
  430. X
  431. Xstatic int        assoc_symbol_cmp(elem,table)
  432. X  register assoc_t      *elem,*table;
  433. X{
  434. X  return strcmp(elem->symbol,table->symbol);
  435. X}
  436. X
  437. Xstatic assoc_t        *assoc_find_symbol(symbol,assocs,n,sorted)
  438. X  char              *symbol;
  439. X  assoc_t          *assocs;
  440. X  unsigned          n;
  441. X  assoc_sort_t          sorted;
  442. X{
  443. X# if (!DONTSORT)
  444. X    if (sorted == sort_symbol)
  445. X    {
  446. X      assoc_t              assoc;
  447. X
  448. X      assoc.symbol = symbol;
  449. X
  450. X      return
  451. X    (assoc_t *) bsearch
  452. X      (
  453. X        (void *) &assoc,(void *) assocs,n,
  454. X        sizeof (assoc_t),assoc_symbol_cmp
  455. X      );
  456. X    }
  457. X  else
  458. X# endif
  459. X  {
  460. X    register assoc_t          *assoc;
  461. X
  462. X    for (assoc = assocs; assoc < assocs+n; assoc++)
  463. X      if (strcmp(assoc->symbol,symbol) == 0)
  464. X    return assoc;
  465. X
  466. X    return 0;
  467. X  }
  468. X}
  469. X
  470. Xstatic assoc_t        states[] =
  471. X{
  472. X  {    NORMAL,        "normal"    },
  473. X  {    SHIFT,        "shift"        },
  474. X  {    CNTRL,        "cntrl"        },
  475. X  {    SHFCTL,        "shfctl"    },
  476. X  {    ALT,        "alt"        },
  477. X  {    ALTSHF,        "altshf"    },
  478. X  {    ALTCTL,        "altctl"    },
  479. X  {    ALTSHFCTL,    "altshfctl"    },
  480. X};
  481. X
  482. Xstatic unsigned        n_states = sizeof states / sizeof *states;
  483. X
  484. Xstatic assoc_t        flags[] =
  485. X{
  486. X  {    L_O,    "O"    },
  487. X  {    L_C,    "C"    },
  488. X  {    L_N,    "N"    },
  489. X  {    L_B,    "B"    },
  490. X};
  491. X
  492. Xstatic unsigned        n_flags = sizeof flags / sizeof *flags;
  493. X
  494. Xstatic assoc_t        controls[] =
  495. X{
  496. X  {    0x00,    "nul"    },
  497. X  {    0x01,    "soh"    },
  498. X  {    0x02,    "stx"    },
  499. X  {    0x03,    "etx"    },
  500. X  {    0x04,    "eot"    },
  501. X  {    0x05,    "enq"    },
  502. X  {    0x06,    "ack"    },
  503. X  {    0x07,    "bel"    },
  504. X  {    0x08,    "bs"    },
  505. X  {    0x09,    "ht"    },
  506. X  {    0x0a,    "nl"    },
  507. X  {    0x0a,    "lf"    },
  508. X  {    0x0b,    "vt"    },
  509. X  {    0x0c,    "ff"    },
  510. X  {    0x0c,    "np"    },
  511. X  {    0x0d,    "cr"    },
  512. X  {    0x0e,    "so"    },
  513. X  {    0x0f,    "si"    },
  514. X  {    0x10,    "dle"    },
  515. X  {    0x11,    "dc1"    },
  516. X  {    0x12,    "dc2"    },
  517. X  {    0x13,    "dc3"    },
  518. X  {    0x14,    "dc4"    },
  519. X  {    0x15,    "nak"    },
  520. X  {    0x16,    "syn"    },
  521. X  {    0x17,    "etb"    },
  522. X  {    0x18,    "can"    },
  523. X  {    0x19,    "em"    },
  524. X  {    0x1a,    "sub"    },
  525. X  {    0x1b,    "esc"    },
  526. X  {    0x1c,    "fs"    },
  527. X  {    0x1d,    "gs"    },
  528. X  {    0x1e,    "rs"    }, 
  529. X  {    0x1f,    "us"    },
  530. X  {    0x1f,    "ns"    },
  531. X  {    0x20,    "0x20"    },
  532. X  {    0x20,    "sp"    },
  533. X};
  534. X
  535. Xstatic unsigned        n_controls = sizeof controls / sizeof *controls;
  536. Xstatic assoc_sort_t    s_controls = sort_value;
  537. X
  538. Xstatic assoc_t            specials[] =
  539. X{
  540. X  {    K_NOP,    "nop"        },
  541. X  {    K_LSH,    "lshift"    },
  542. X  {    K_RSH,    "rshift"    },
  543. X  {    K_CLK,    "clock"        },
  544. X  {    K_NLK,    "nlock"        },
  545. X  {    K_SLK,    "slock"        },
  546. X  {    K_ALT,    "alt"        },
  547. X  {    K_BTAB,    "btab"        },
  548. X  {    K_CTL,    "ctrl"        },
  549. X  {    K_LAL,    "lalt"        },
  550. X  {    K_RAL,    "ralt"        },
  551. X  {    K_LCT,    "lctrl"        },
  552. X  {    K_RCT,    "rctrl"        },
  553. X  {    K_AGR,    "agr"        },
  554. X  {    K_SRQ,    "sysreq"    },
  555. X  {    K_BRK,    "brk"        },
  556. X  {    K_BRK,    "break"        },
  557. X  {    K_ESN,    "fN"        },
  558. X  {    K_ESN,    "escn"        },
  559. X  {    K_ESO,    "fO"        },
  560. X  {    K_ESO,    "esco"        },
  561. X  {    K_ESL,    "f["        },
  562. X  {    K_ESL,    "escl"        },
  563. X  {    K_RBT,    "reboot"    },
  564. X  {    K_RBT,    "rboot"        },
  565. X  {    K_DBG,    "debug"        },
  566. X  {    K_NEXT,    "nscr"        },
  567. X  {    K_PREV,    "pscr"        },
  568. X  {    K_FRCNEXT, "fnscrn"    },
  569. X  {    K_FRCPREV, "fpscrn"    },
  570. X};
  571. X
  572. Xstatic unsigned        n_specials = sizeof specials / sizeof *specials;
  573. Xstatic assoc_sort_t    s_specials = sort_value;
  574. X
  575. Xtypedef struct
  576. X{
  577. X  int              first,last;
  578. X  char              *symbol;
  579. X}
  580. X            range_t;
  581. X
  582. Xstatic range_t        *range_find_value(value,ranges,n)
  583. X  int              value;
  584. X  range_t          *ranges;
  585. X  unsigned          n;
  586. X{
  587. X  register range_t      *range;
  588. X
  589. X  for (range = ranges; range < ranges+n; range++)
  590. X    if (range->first <= value && value <= range->last)
  591. X      return range;
  592. X
  593. X  return 0;
  594. X}
  595. X
  596. Xstatic range_t        *range_find_symbol(symbol,ranges,n)
  597. X  char              *symbol;
  598. X  range_t          *ranges;
  599. X  unsigned          n;
  600. X{
  601. X  register range_t      *range;
  602. X
  603. X  for (range = ranges; range < ranges+n; range++)
  604. X    if (strncmp(range->symbol,symbol,strlen(range->symbol)) == 0)
  605. X      return range;
  606. X
  607. X  return 0;
  608. X}
  609. X
  610. Xstatic range_t        ranges[] =
  611. X{
  612. X  {    K_FUNF,K_FUNL,    "fkey"    },
  613. X  {    K_VTF,K_VTL,    "scr"    },
  614. X  {    K_MGRF,K_MGRL,    "mgr"    },
  615. X  {    K_MGRF,K_MGRL,    "MGR"    },
  616. X  {    K_VTF,K_MGRL,    "vt"    },
  617. X  {    K_VTF,K_MGRL,    "VT"    },
  618. X  {    K_PFXF,K_PFXL,    "pfx"    },
  619. X  {    K_PFXF,K_PFXL,    "PFX"    },
  620. X};
  621. X
  622. Xstatic unsigned        n_ranges = sizeof ranges / sizeof *ranges;
  623. X
  624. Xstatic void        kmap_clear(kmap)
  625. X  keymap_t          *kmap;
  626. X{
  627. X  register unsigned      code;
  628. X  register struct key_t      *key;
  629. X
  630. X  for
  631. X  (
  632. X    code = 0, key = &kmap->key[0];
  633. X    code < NUM_KEYS;
  634. X    code++, key++
  635. X  )
  636. X  {
  637. X    register unsigned        state;
  638. X
  639. X    for (state = 0; state < NUM_STATES; state++)
  640. X      key->map[state] = K_NOP;
  641. X    key->spcl = 0xFF;
  642. X    key->flgs = L_O;
  643. X  }
  644. X
  645. X  kmap->n_keys = 0;
  646. X}
  647. X
  648. Xtypedef char            symbol_t[12];
  649. X
  650. Xstatic void        skipoverwhite(file)
  651. X  register FILE          *file;
  652. X{
  653. X  register int          ch;
  654. X
  655. X  do ch = getc(file);
  656. X  until (ch == EOF || ch == '\n' || !isspace(ch));
  657. X
  658. X  if (ch != EOF) ungetc(ch,file);
  659. X}
  660. X
  661. Xstatic void        skipovereol(file)
  662. X  register FILE          *file;
  663. X{
  664. X  register int          ch;
  665. X
  666. X  do ch = getc(file);
  667. X  until (ch == '\n' || ch == EOF);
  668. X}
  669. X  
  670. Xstatic unsigned        getsymbol(file,symbol)
  671. X  register FILE          *file;
  672. X  register char          *symbol;
  673. X{
  674. X  register int          ch;
  675. X  register char          *last = symbol + sizeof (symbol_t) - 1;
  676. X
  677. X  ch = getc(file);
  678. X  if (ch == EOF)
  679. X  {
  680. X    *symbol = '\0';  
  681. X    return 0;
  682. X  }
  683. X
  684. X  /*
  685. X    Here we spend some effort to special case ' '...
  686. X  */
  687. X
  688. X  if (ch == '\'')
  689. X  {
  690. X    if (symbol < last)
  691. X      *symbol++ = ch;
  692. X    ch = getc(file);
  693. X    if (ch != EOF && ch == ' ')
  694. X    {
  695. X      if (symbol < last)
  696. X    *symbol++ = ch;
  697. X      ch = getc(file);
  698. X    }
  699. X  }
  700. X
  701. X  until (ch == EOF || ch == '\n' || isspace(ch))
  702. X  {
  703. X    if (symbol < last)
  704. X      *symbol++ = ch;
  705. X    ch = getc(file);
  706. X  }
  707. X
  708. X  *symbol = '\0';
  709. X
  710. X  ungetc(ch,file);
  711. X
  712. X  return symbol < last;
  713. X}
  714. X
  715. Xstatic unsigned        tonumber(symbol,valuep)
  716. X  register char          *symbol;
  717. X  unsigned          *valuep;
  718. X{
  719. X  unsigned          value;
  720. X  char              *tail = symbol;
  721. X
  722. X  value =
  723. X    (symbol[0] == '0')
  724. X      ? (symbol[1] == 'x' || symbol[1] == 'X')
  725. X        ? strtoul(symbol+2,&tail,16) : strtoul(symbol+1,&tail,8)
  726. X    : (strchr("123456789",symbol[0]))
  727. X    ? strtoul(symbol,&tail,10) : (tail = symbol, 0);
  728. X
  729. X  if (tail > symbol)
  730. X    *valuep = value;
  731. X
  732. X  return tail > symbol;
  733. X}
  734. X
  735. Xstatic unsigned        getstate(file,code,valuep,specp)
  736. X  FILE              *file;
  737. X  unsigned          code;
  738. X  unsigned char          *valuep;
  739. X  unsigned          *specp;
  740. X{
  741. X  symbol_t          symbol;
  742. X  unsigned          value;
  743. X  register assoc_t      *assoc;
  744. X  register range_t      *range;
  745. X
  746. X  if (!getsymbol(file,symbol))
  747. X  {
  748. X    fprintf(stderr,"scancode %d: badly formed symbol '%s'\n",code,symbol);
  749. X    return 0;
  750. X  }
  751. X
  752. X  if (isdigit(symbol[0]) && tonumber(symbol,&value))
  753. X    /*skip*/;
  754. X  else if (symbol[0] == '\'')
  755. X  {
  756. X    value = symbol[(symbol[1] != '\\') ? 1 : 2];
  757. X    if (!(' ' <= value && value <= '~'))
  758. X      return 0;
  759. X  }
  760. X  else if (assoc = assoc_find_symbol(symbol,controls,n_controls,s_controls))
  761. X    value = assoc->value;
  762. X  else if (assoc = assoc_find_symbol(symbol,specials,n_specials,s_specials))
  763. X  {
  764. X    value = assoc->value;
  765. X    *specp = 1;
  766. X  }
  767. X  else if (range = range_find_symbol(symbol,ranges,n_ranges))
  768. X  {
  769. X    value = range->first
  770. X    + strtoul(symbol+strlen(range->symbol),(char **) 0,10);
  771. X    *specp = 1;
  772. X  }
  773. X  else if (strcmp(symbol,"del") == 0)
  774. X    value = 0x7F;
  775. X  else if
  776. X  (
  777. X    (symbol[0] == '^' && symbol[2] == '\0') 
  778. X    || (symbol[0] == 'C' && symbol[1] == '-' && symbol[3] == '\0')
  779. X    || (symbol[5] == '0' && strncmp(symbol,"M-C-",4))
  780. X  )
  781. X  {
  782. X    value = symbol[(symbol[0] == '^') ? 1 : (symbol[1] == 'C') ? 2 : 4];
  783. X    if ((value < '@' || value > '_') && value != '?')
  784. X      return 0;
  785. X    value = (value != '?') ? value & 0x1F : 0x7F;
  786. X    if (symbol[0] == 'M')
  787. X      value |= 0x80;
  788. X  }
  789. X  else if (symbol[0] == 'M' && symbol[1] == '-' && symbol[3] == '\0')
  790. X  {
  791. X    value = symbol[2];
  792. X    if (value < ' ' || value > '~')
  793. X      return 0;
  794. X    value |= 0x80;
  795. X  }
  796. X  else
  797. X    return 0;
  798. X
  799. X  *valuep = (unsigned char) value;
  800. X  return 1;
  801. X}
  802. X
  803. Xstatic unsigned        loadkey(file,code,key)
  804. X  FILE              *file;
  805. X  unsigned          code;
  806. X  register struct key_t   *key;
  807. X{
  808. X  symbol_t          symbol;
  809. X  register unsigned      state;
  810. X  unsigned char                values[NUM_STATES];
  811. X  unsigned          spcl;
  812. X  unsigned          flgs;
  813. X  register assoc_t      *assoc;
  814. X  unsigned          failures;
  815. X
  816. X  spcl = 0;
  817. X  flgs = 0;
  818. X  failures = 0;
  819. X
  820. X  for (state = 0; state < NUM_STATES; state++)
  821. X  {
  822. X    unsigned            spec = 0;
  823. X
  824. X    skipoverwhite(file);
  825. X
  826. X    if (getstate(file,code,&values[state],&spec))
  827. X    {
  828. X      if (spec)
  829. X    spcl |= (0x80 >> state);
  830. X    }
  831. X    else
  832. X    {
  833. X      fprintf(stderr,"scancode %d: symbol unrecognized",code);
  834. X      if (assoc = assoc_find_value(states,n_states,state,sort_none))
  835. X    fprintf(stderr," for state %s\n",assoc->symbol);
  836. X      else
  837. X    fprintf(stderr," for state %d\n",state);
  838. X      failures++;
  839. X    }
  840. X  }
  841. X
  842. X  skipoverwhite(file);
  843. X
  844. X  if
  845. X  (
  846. X    !getsymbol(file,symbol)
  847. X    || (assoc = assoc_find_symbol(symbol,flags,n_flags,sort_none)) == 0)
  848. X  {
  849. X    fprintf(stderr,"scancode %d: bad flags '%s'\n",code,symbol);
  850. X    failures++;
  851. X  }
  852. X  flgs = assoc->value;  
  853. X
  854. X  if (!failures)
  855. X  {
  856. X    for (state = 0; state < NUM_STATES; state++)
  857. X      key->map[state] = values[state];
  858. X    key->spcl = spcl;
  859. X    key->flgs = flgs;
  860. X  }
  861. X
  862. X  return failures;
  863. X}
  864. X
  865. Xstatic unsigned        kmap_load(lowest,kmap,file,path)
  866. X  unsigned          lowest;
  867. X  keymap_t          *kmap;
  868. X  FILE              *file;
  869. X  char              *path;
  870. X{
  871. X  register int          ch;
  872. X  int              hcode;
  873. X  unsigned          failures;
  874. X
  875. X# if (DONTSORT)
  876. X  {
  877. X    s_controls = sort_none;
  878. X    s_specials = sort_none;
  879. X  }
  880. X# else
  881. X  {
  882. X    if (s_controls != sort_symbol)
  883. X    {
  884. X      qsort(&controls, n_controls, sizeof (assoc_t), assoc_symbol_cmp);
  885. X      s_controls = sort_symbol;
  886. X    }
  887. X
  888. X    if (s_specials != sort_symbol)
  889. X    {
  890. X      qsort(&specials, n_specials, sizeof (assoc_t), assoc_symbol_cmp);
  891. X      s_specials = sort_symbol;
  892. X    }
  893. X  }
  894. X# endif
  895. X
  896. X  hcode = -1;
  897. X  failures = 0;
  898. X
  899. X  while ((ch = getc(file)) != EOF)
  900. X  {
  901. X    ungetc(ch,file);
  902. X
  903. X    if (ch == '#')        skipovereol(file);
  904. X    else if (ch == '\n')    ch = getc(file);
  905. X    else if (isspace(ch))    skipoverwhite(file);
  906. X    else /* A scancode line */
  907. X    {
  908. X      symbol_t              symbol;
  909. X      unsigned              code;
  910. X
  911. X      if (!getsymbol(file,symbol) || !tonumber(symbol,&code)
  912. X    || code >= NUM_KEYS)
  913. X      {
  914. X    fprintf(stderr,"scancode '%s' in file '%s' is illegal\n",symbol,path);
  915. X    failures++;
  916. X      }
  917. X      else
  918. X      {
  919. X    if (hcode < (int) code)
  920. X      hcode = code;
  921. X
  922. X    failures += loadkey(file,code,&kmap->key[code]);
  923. X      }
  924. X
  925. X      skipovereol(file);
  926. X    }
  927. X  }
  928. X
  929. X  if (failures)
  930. X    fprintf(stderr,"%d items in file '%s' could not be recognized\n",
  931. X      failures,path);
  932. X  else if (kmap->n_keys <= hcode)
  933. X    kmap->n_keys = hcode+1;
  934. X
  935. X  return failures == 0 && hcode >= lowest;
  936. X}
  937. X
  938. Xstatic void        kmap_dump(kmap,base)
  939. X  keymap_t          *kmap;
  940. X  unsigned          base;
  941. X{
  942. X  register unsigned      code;
  943. X  register struct key_t      *key;
  944. X
  945. X# if (DONTSORT)
  946. X  {
  947. X    s_controls = sort_none;
  948. X    s_specials = sort_none;
  949. X  }
  950. X# else
  951. X  {
  952. X    if (s_controls != sort_value)
  953. X    {
  954. X      qsort(&controls, n_controls, sizeof (assoc_t), assoc_value_cmp);
  955. X      s_controls = sort_value;
  956. X    }
  957. X
  958. X    if (s_specials != sort_value)
  959. X    {
  960. X      qsort(&specials, n_specials, sizeof (assoc_t), assoc_value_cmp);
  961. X      s_specials = sort_value;
  962. X    }
  963. X  }
  964. X# endif
  965. X
  966. X  for
  967. X  (
  968. X    code = 0, key = &kmap->key[0];
  969. X    code < kmap->n_keys;
  970. X    code++, key++
  971. X  )
  972. X  {
  973. X    register unsigned          state;
  974. X
  975. X    printf((base == 10) ? "%d" : (base == 16) ? "0x%02x" : "0%o",code);
  976. X    for (state = 0; state < NUM_STATES; state++)
  977. X    {
  978. X      register unsigned char    value = key->map[state];
  979. X
  980. X
  981. X      putchar('\t');
  982. X
  983. X      if (key->spcl & (0x80 >> state))
  984. X      {
  985. X        register assoc_t      *assoc;
  986. X    register range_t      *range;
  987. X
  988. X    if (assoc = assoc_find_value(value,specials,n_specials,s_specials))
  989. X      fputs(assoc->symbol,stdout);
  990. X    else if (range = range_find_value(value,ranges,n_ranges))
  991. X      printf("%s%02d",range->symbol,value-range->first);
  992. X        else
  993. X      fputs("SPEC?",stdout);
  994. X      }
  995. X      else
  996. X      {
  997. X        if (value > ' ' && value <= '~')
  998. X      printf((value == '\'' || value == '\\') ? "'\\%c'" : "'%c'",value);
  999. X        else if (value <= ' ')
  1000. X        {
  1001. X      register assoc_t      *assoc;
  1002. X
  1003. X      if (assoc = assoc_find_value(value,controls,n_controls,s_controls))
  1004. X        fputs(assoc->symbol,stdout);
  1005. X        }
  1006. X        else if (value == 0x7F)
  1007. X      fputs("del",stdout);
  1008. X        else
  1009. X      printf("0x%02x",value);
  1010. X      }
  1011. X    }
  1012. X
  1013. X    printf("\t%c\n","OCNB"[key->flgs&0x03]);
  1014. X  }
  1015. X}
  1016. X
  1017. Xstatic void        metaize(kmap)
  1018. X  keymap_t          *kmap;
  1019. X{
  1020. X  register short      code;
  1021. X  register struct key_t      *key;
  1022. X
  1023. X  for
  1024. X  (
  1025. X    code = 0, key = &kmap->key[0];
  1026. X    code < kmap->n_keys;
  1027. X    code++, key++
  1028. X  )
  1029. X  {
  1030. X    register unsigned        state;
  1031. X    register unsigned char  *map = key->map;
  1032. X    register unsigned        spcl = key->spcl;
  1033. X
  1034. X    for (state = ALT; state <= ALTSHFCTL; state++)
  1035. X    {
  1036. X      if ((spcl & (0x80 >> state)) == 0)
  1037. X     map[state] = map[state-(ALT-NORMAL)] | 0x80;
  1038. X    }
  1039. X  }
  1040. X}
  1041. X
  1042. X#if (defined KDDFLTKEYMAP)
  1043. X  static struct key_dflt  kdflt;
  1044. X# define kmap          kdflt.key_map
  1045. X#else
  1046. X  static keymap_t      kmap;
  1047. X#endif
  1048. X
  1049. Xextern int    main(argc,argv,envp)
  1050. X  int          argc;
  1051. X  char          **argv;
  1052. X  char          **envp;
  1053. X{
  1054. X  int          opt;
  1055. X
  1056. X  char          *ttypath = 0;
  1057. X  int          ttyfd = -1;
  1058. X
  1059. X  char          **keypaths = 0;
  1060. X  unsigned      keycount = 0;
  1061. X
  1062. X  enum
  1063. X  {
  1064. X    opt_DUMP      = 0x003F,
  1065. X    opt_META      = 0x0040,
  1066. X    opt_INCR      = 0x0080,
  1067. X    opt_CHECK      = 0x0100,
  1068. X    opt_VERBOSE      = 0x0200,
  1069. X    opt_FILES      = 0x0400,
  1070. X  };
  1071. X
  1072. X  enum
  1073. X  {
  1074. X    do_GET      = 0x0001,
  1075. X    do_CLEAR      = 0x0002,
  1076. X    do_LOAD      = 0x0004,
  1077. X    do_META      = 0x0008,
  1078. X    do_PUT      = 0x0010,
  1079. X    do_DUMP      = 0x0020,
  1080. X  };
  1081. X
  1082. X  unsigned      opts = 0;
  1083. X  unsigned      dos = 0;
  1084. X
  1085. X  unsigned      failed = 0;
  1086. X
  1087. X  /*
  1088. X    These are for compatibility with SVR4 mapkey(1M):
  1089. X
  1090. X     <empty>            load default, put
  1091. X     -[dox] <empty>        get, dump
  1092. X     <files>            load files, put
  1093. X
  1094. X    These are new combinations:
  1095. X
  1096. X     -[dox] <files>        load files, put, dump
  1097. X
  1098. X     -c <empty>            load default
  1099. X     -c <files>            load files
  1100. X     -[dox] -c <files>        load files, dump
  1101. X     -m -[dox] -c <files>    load files, metaize, dump
  1102. X
  1103. X     -m <empty>            get, metaize, put
  1104. X     -m -[dox] <empty>        get, metaize, put, dump
  1105. X
  1106. X     -m <files>            load files, metaize, put
  1107. X     -m -[dox] <files>        load files, metaize, put, dump
  1108. X  */
  1109. X
  1110. X  while ((opt = getopt(argc,argv,"odxcmivt:T:")) != EOF)
  1111. X  switch (opt)
  1112. X  {
  1113. X  case 'o':    opts = (opts&~opt_DUMP) | 8; break;
  1114. X  case 'd':    opts = (opts&~opt_DUMP) | 10; break;
  1115. X  case 'x':    opts = (opts&~opt_DUMP) | 16; break;
  1116. X
  1117. X  case 'c':    opts |= opt_CHECK; break;
  1118. X  case 'm':    opts |= opt_META; break;
  1119. X  case 'i':    opts |= opt_INCR; break;
  1120. X  case 'v':    opts |= opt_VERBOSE; break;
  1121. X
  1122. X  case 't':    ttypath = optarg; break;
  1123. X  case 'T':    ttyfd = atoi(optarg); break;
  1124. X  }
  1125. X
  1126. X  if (optind < argc)
  1127. X  {
  1128. X    keypaths = &argv[optind];
  1129. X    keycount = argc-optind;
  1130. X    opts |= opt_FILES;
  1131. X  }
  1132. X
  1133. X  if ((opts & (opt_DUMP|opt_FILES|opt_META)) == (opt_DUMP))
  1134. X    opts |= opt_CHECK;
  1135. X
  1136. X  if ((!(opts & opt_FILES) && (opts & (opt_META|opt_DUMP)))
  1137. X    || (opts & opt_INCR))
  1138. X    dos |= do_GET;
  1139. X
  1140. X  if (!(dos & do_GET) && !(opts & opt_INCR))
  1141. X    dos |= do_CLEAR;
  1142. X
  1143. X  if (opts & opt_META)
  1144. X    dos |= do_META;
  1145. X
  1146. X  if ((opts & opt_FILES) || !(opts & (opt_META|opt_DUMP)))
  1147. X    dos |= do_LOAD;
  1148. X
  1149. X  if (((opts & opt_META) || (dos & do_LOAD)) && !(opts & opt_CHECK))
  1150. X    dos |= do_PUT;
  1151. X
  1152. X  if (opts & opt_DUMP)
  1153. X    dos |= do_DUMP;
  1154. X
  1155. X  if (opts & opt_VERBOSE)
  1156. X    fprintf(stderr,"opts 0x%04x, dos 0x%04x\n",opts,dos);
  1157. X
  1158. X  if (!(opts & opt_FILES) && (dos & do_LOAD))
  1159. X  {
  1160. X    static char        *(libpaths[]) = { "/usr/lib/keyboard/keys", 0 };
  1161. X
  1162. X    if (opts & opt_VERBOSE)
  1163. X      fprintf(stderr,"defaulting file to '%s'\n",libpaths[0]);
  1164. X
  1165. X    keypaths = &libpaths[0];
  1166. X    keycount = 1;
  1167. X  }
  1168. X
  1169. X  if ((dos & (do_GET|do_LOAD)) == 0)
  1170. X  {
  1171. X    fputs("no action requested!?\n",stderr);
  1172. X    exit(1);
  1173. X  }
  1174. X
  1175. X  if (ttyfd < 0)
  1176. X  {
  1177. X    if (ttypath == 0)
  1178. X      ttyfd = 0;
  1179. X    else
  1180. X    {
  1181. X      if (opts & opt_VERBOSE)
  1182. X          fprintf(stderr,"opening tty '%s'\n",ttypath);
  1183. X
  1184. X      ttyfd = open(ttypath,0);
  1185. X      if (ttyfd < 0)
  1186. X      {
  1187. X    perror(ttypath);
  1188. X    exit(1);
  1189. X      }
  1190. X    }
  1191. X  }
  1192. X
  1193. X  if (dos & do_GET)
  1194. X  {
  1195. X    kmap_clear(&kmap);
  1196. X
  1197. X    if (opts & opt_VERBOSE)
  1198. X      fprintf(stderr,"getting map from fd %d\n",ttyfd);
  1199. X
  1200. X#   if (!defined KDDFLTKEYMAP)
  1201. X      if (ioctl(ttyfd,GIO_KEYMAP,&kmap) < 0)
  1202. X#   else
  1203. X      kdflt.key_direction = KD_DFLTGET;
  1204. X      if (ioctl(ttyfd,KDDFLTKEYMAP,&kdflt) < 0)
  1205. X#   endif
  1206. X    {
  1207. X      perror("get keymap");
  1208. X      exit(1);
  1209. X    }
  1210. X  }
  1211. X
  1212. X  if (dos & do_CLEAR)
  1213. X  {
  1214. X    if (opts & opt_VERBOSE)
  1215. X      fprintf(stderr,"clearing map\n");
  1216. X
  1217. X    kmap_clear(&kmap);
  1218. X  }
  1219. X
  1220. X  if (dos & do_LOAD)
  1221. X  {
  1222. X
  1223. X    for (keypaths, keycount; keycount != 0; keypaths++, --keycount)
  1224. X    {
  1225. X      FILE            *keys;
  1226. X      char            *keypath = *keypaths;
  1227. X
  1228. X      if (strcmp(keypath,"-") == 0)
  1229. X    keys = stdin, keypath = "<stdin>";
  1230. X      else if ((keys = fopen(keypath,"r")) == 0)
  1231. X      {
  1232. X    perror(keypath);
  1233. X        failed = 1; 
  1234. X      }
  1235. X      else
  1236. X      {
  1237. X        if (opts & opt_VERBOSE)
  1238. X      fprintf(stderr,"loading from '%s'\n",keypath);
  1239. X
  1240. X    failed |= !kmap_load((dos&do_CLEAR) ? 'Z' : 0,&kmap,keys,keypath);
  1241. X
  1242. X    if (keys != stdin)
  1243. X      fclose(keys);
  1244. X      }
  1245. X    }
  1246. X  }
  1247. X
  1248. X  if (dos & do_META)
  1249. X  {
  1250. X    if (opts & opt_VERBOSE)
  1251. X      fprintf(stderr,"metaizing\n");
  1252. X
  1253. X    metaize(&kmap);
  1254. X  }
  1255. X
  1256. X  if (!failed && (dos & do_PUT))
  1257. X  {
  1258. X    if (opts & opt_VERBOSE)
  1259. X      fprintf(stderr,"putting map to fd %d\n",ttyfd);
  1260. X
  1261. X#   if (!defined KDDFLTKEYMAP)
  1262. X      if (ioctl(ttyfd,PIO_KEYMAP,&kmap) < 0)
  1263. X#   else
  1264. X      kdflt.key_direction = KD_DFLTSET;
  1265. X      if (ioctl(ttyfd,KDDFLTKEYMAP,&kdflt) < 0)
  1266. X#   endif
  1267. X    {
  1268. X      perror("put keymap");
  1269. X      exit(1);
  1270. X    }
  1271. X  }
  1272. X
  1273. X  if (dos & do_DUMP)
  1274. X  {
  1275. X    if (opts & opt_VERBOSE)
  1276. X      fprintf(stderr,"dumping\n");
  1277. X
  1278. X    kmap_dump(&kmap,opts & opt_DUMP);
  1279. X  }
  1280. X
  1281. X  return failed;
  1282. X}
  1283. END_OF_FILE
  1284. if test 18179 -ne `wc -c <'mapkbd.c'`; then
  1285.     echo shar: \"'mapkbd.c'\" unpacked with wrong size!
  1286. fi
  1287. # end of 'mapkbd.c'
  1288. fi
  1289. if test -f 'ukd-meta.kbd' -a "${1}" != "-c" ; then 
  1290.   echo shar: Will not clobber existing file \"'ukd-meta.kbd'\"
  1291. else
  1292. echo shar: Extracting \"'ukd-meta.kbd'\" \(271 characters\)
  1293. sed "s/^X//" >'ukd-meta.kbd' <<'END_OF_FILE'
  1294. X# Rebindings for UK keyboard
  1295. X
  1296. X3    '2'    '"'    nop    nop    0xb2    0xa2    nop    nop    O
  1297. X4    '3'    0x9c    nop    nop    0xb3    '#'    nop    nop    O
  1298. X40    '\''    '@'    nul    nul    0xa7    0xc0    0x80    0x80    O
  1299. X41    '`'    0xaa    nul    nul    0xe0    0xfe    0x80    0x80    O
  1300. X43    '#'    '~'    nul    nul    0xa3    0xfe    0x80    0x80    O
  1301. X86    '\\'    '|'    fs    fs    0xdc    0xfc    0x9c    0x9c    O
  1302. END_OF_FILE
  1303. if test 271 -ne `wc -c <'ukd-meta.kbd'`; then
  1304.     echo shar: \"'ukd-meta.kbd'\" unpacked with wrong size!
  1305. fi
  1306. # end of 'ukd-meta.kbd'
  1307. fi
  1308. if test -f 'usa-meta.kbd' -a "${1}" != "-c" ; then 
  1309.   echo shar: Will not clobber existing file \"'usa-meta.kbd'\"
  1310. else
  1311. echo shar: Extracting \"'usa-meta.kbd'\" \(5742 characters\)
  1312. sed "s/^X//" >'usa-meta.kbd' <<'END_OF_FILE'
  1313. X# USA keys. ALT is used as a META key (code|0x80) and CTRL as a
  1314. X# CTL key (code&0x1f). We tend to leave undefine CTRL version of keys
  1315. X# that don't have a reasonable interpretation, but purely for
  1316. X# convenience we often have that SHIFT is allowed and gives the same
  1317. X# code a without the SHIFT.
  1318. X#
  1319. X#code    key    S    C    CS    M    MS    MC    MCS    LCK
  1320. X#
  1321. X0    nop    nop    nop    nop    nop    nop    nop    nop    O
  1322. X1    esc    esc    sysreq    nop    0x9b    0x9b    nop    nop    O
  1323. X2    '1'    '!'    nop    nop    0xb1    0xa1    nop    nop    O
  1324. X3    '2'    '@'    nul    nul    0xb2    0xc0    0x80    0x80    O
  1325. X4    '3'    '#'    nop    nop    0xb3    0xa3    nop    nop    O
  1326. X5    '4'    '$'    nop    nop    0xb4    0xa4    nop    nop    O
  1327. X6    '5'    '%'    nop    nop    0xb5    0xa5    nop    nop    O
  1328. X7    '6'    '^'    rs    rs    0xb6    0xde    0x9e    0x9e    O
  1329. X8    '7'    '&'    nop    nop    0xb7    0xa6    nop    nop    O
  1330. X9    '8'    '*'    nop    nop    0xb8    0xaa    nop    nop    O
  1331. X10    '9'    '('    nop    nop    0xb9    0xa8    nop    nop    O
  1332. X11    '0'    ')'    nop    nop    0xb0    0xa9    nop    nop    O
  1333. X12    '-'    '_'    ns    ns    0xad    0xdf    0x9f    0x9f    O
  1334. X13    '='    '+'    nop    nop    0xbd    0xab    nop    nop    O
  1335. X14    bs    bs    nop    nop    0x88    0x88    nop    nop    O
  1336. X15    ht    gs    nop    nop    0x89    0x9d    nop    nop    O
  1337. X16    'q'    'Q'    dc1    dc1    0xf1    0xd1    0x91    0x91    C
  1338. X17    'w'    'W'    etb    etb    0xf7    0xd7    0x97    0x97    C
  1339. X18    'e'    'E'    enq    enq    0xe5    0xc5    0x85    0x85    C
  1340. X19    'r'    'R'    dc2    dc2    0xf2    0xd2    0x92    0x92    C
  1341. X20    't'    'T'    dc4    dc4    0xf4    0xd4    0x94    0x94    C
  1342. X21    'y'    'Y'    em    em    0xf9    0xd9    0x99    0x99    C
  1343. X22    'u'    'U'    nak    nak    0xf5    0xd5    0x95    0x95    C
  1344. X23    'i'    'I'    ht    ht    0xe9    0xc9    0x89    0x89    C
  1345. X24    'o'    'O'    si    si    0xef    0xcf    0x8f    0x8f    C
  1346. X25    'p'    'P'    dle    dle    0xf0    0xd0    0x90    0x90    C
  1347. X26    '['    '{'    esc    esc    0xdb    0xfb    0x9b    0x9b    O
  1348. X27    ']'    '}'    gs    gs    0xdd    0xfd    0x9d    0x9d    O
  1349. X28    cr    cr    nop    nop    0x8d    0x8d    nop    nop    O
  1350. X29    lctrl    lctrl    lctrl    lctrl    lctrl    lctrl    lctrl    lctrl    O
  1351. X30    'a'    'A'    soh    soh    0xe1    0xc1    0x81    0x81    C
  1352. X31    's'    'S'    dc3    dc3    0xf3    0xd3    0x93    0x93    C
  1353. X32    'd'    'D'    eot    eot    0xe4    0xc4    debug    0x84    C
  1354. X33    'f'    'F'    ack    ack    0xe6    0xc6    0x86    0x87    C
  1355. X34    'g'    'G'    bel    bel    0xe7    0xc7    0x87    0x87    C
  1356. X35    'h'    'H'    bs    bs    0xe8    0xc8    0x88    0x88    C
  1357. X36    'j'    'J'    nl    nl    0xea    0xca    0x8a    0x8a    C
  1358. X37    'k'    'K'    vt    vt    0xeb    0xcb    0x8b    0x8b    C
  1359. X38    'l'    'L'    np    np    0xec    0xcc    0x8c    0x8c    C
  1360. X39    ';'    ':'    nop    nop    0xbb    0xba    nop    nop    O
  1361. X40    '\''    '"'    nop    nop    0xa7    0xa2    nop    nop    O
  1362. X41    '`'    '~'    nul    nul    0xe0    0xfe    0x80    0x80    O
  1363. X42    lshift    lshift    lshift    lshift    lshift    lshift    lshift    lshift    O
  1364. X43    '\\'    '|'    fs    fs    0xdc    0xfc    0x9c    0x9c    O
  1365. X44    'z'    'Z'    sub    sub    0xfa    0xda    0x9a    0x9a    C
  1366. X45    'x'    'X'    can    can    0xf8    0xd8    0x98    0x98    C
  1367. X46    'c'    'C'    etx    etx    0xe3    0xc3    0x83    0x83    C
  1368. X47    'v'    'V'    syn    syn    0xf6    0xd6    0x96    0x96    C
  1369. X48    'b'    'B'    stx    stx    0xe2    0xc2    0x82    0x82    C
  1370. X49    'n'    'N'    so    so    0xee    0xce    0x8e    0x8e    C
  1371. X50    'm'    'M'    cr    cr    0xed    0xcd    0x8d    0x8d    C
  1372. X51    ','    '<'    nop    nop    0xac    0xbc    nop    nop    O
  1373. X52    '.'    '>'    nop    nop    0xae    0xbe    nop    nop    O
  1374. X53    '/'    '?'    ns    del    0xaf    0xbf    0x9f    0xff    O
  1375. X54    rshift    rshift    rshift    rshift    rshift    rshift    rshift    rshift    O
  1376. X55    '*'    '*'    nop    nop    0xaa    0xaa    nop    nop    O
  1377. X56    lalt    lalt    lalt    lalt    lalt    lalt    lalt    lalt    O
  1378. X57    0x20    0x20    nul    nul    0xa0    0xa0    0x80    0x80    O
  1379. X58    clock    clock    clock    clock    clock    clock    clock    clock    O
  1380. X59    fkey00    fkey12    fkey24    fkey36    nop    nop    nop    nop    O
  1381. X60    fkey01    fkey13    fkey25    fkey37    nop    nop    nop    nop    O
  1382. X61    fkey02    fkey14    fkey26    fkey38    nop    nop    nop    nop    O
  1383. X62    fkey03    fkey15    fkey27    fkey39    nop    nop    nop    nop    O
  1384. X63    fkey04    fkey16    fkey28    fkey40    nop    nop    nop    nop    O
  1385. X64    fkey05    fkey17    fkey29    fkey41    nop    nop    nop    nop    O
  1386. X65    fkey06    fkey18    fkey30    fkey42    nop    nop    nop    nop    O
  1387. X66    fkey07    fkey19    fkey31    fkey43    nop    nop    nop    nop    O
  1388. X67    fkey08    fkey20    fkey32    fkey44    nop    nop    nop    nop    O
  1389. X68    fkey09    fkey21    fkey33    fkey45    nop    nop    nop    nop    O
  1390. X69    nlock    nlock    nlock    nlock    nlock    nlock    nlock    nlock    O
  1391. X70    slock    slock    break    break    break    break    nop    nop    O
  1392. X71    fkey48    '7'    nop    nop    scr07    0xb7    scr17    nop    N
  1393. X72    fkey49    '8'    nop    nop    scr08    0xb8    scr18    nop    N
  1394. X73    fkey50    '9'    nop    nop    scr09    0xb9    scr19    nop    N
  1395. X74    fkey51    '-'    nop    nop    nop    0xad    nop    nop    N
  1396. X75    fkey52    '4'    nop    nop    scr04    0xb4    scr14    nop    N
  1397. X76    fkey53    '5'    nop    nop    scr05    0xb5    scr15    nop    N
  1398. X77    fkey54    '6'    nop    nop    scr06    0xb6    scr16    nop    N
  1399. X78    fkey55    '+'    nop    nop    nop    0xab    nop    nop    N
  1400. X79    fkey56    '1'    nop    nop    scr01    0xb1    scr11    nop    N
  1401. X80    fkey57    '2'    nop    nop    scr02    0xb2    scr12    nop    N
  1402. X81    fkey58    '3'    nop    nop    scr03    0xb3    scr13    nop    N
  1403. X82    fkey59    '0'    nop    nop    scr00    0xb0    scr10    nop    N
  1404. X83    del    '.'    nop    nop    0xff    0xae    reboot    nop    N
  1405. X84    fkey59    fkey25    sysreq    sysreq    sysreq    sysreq    nop    nop    O
  1406. X85    fkey57    fkey57    nop    nop    scr00    scr00    nop    nop    O
  1407. X86    fkey52    fkey52    nop    nop    nop    nop    nop    nop    O
  1408. X87    fkey10    fkey22    fkey34    fkey46    scr10    scr22    scr34    scr46    O
  1409. X88    fkey11    fkey23    fkey35    fkey47    scr11    scr23    scr35    scr47    O
  1410. X89    nop    nop    nop    nop    nop    nop    nop    nop    O
  1411. X90    nop    nop    nop    nop    nop    nop    nop    nop    O
  1412. X91    nop    nop    nop    nop    nop    nop    nop    nop    O
  1413. X92    nop    nop    nop    nop    nop    nop    nop    nop    O
  1414. X93    nop    nop    nop    nop    nop    nop    nop    nop    O
  1415. X94    nop    nop    nop    nop    nop    nop    nop    nop    O
  1416. X95    nop    nop    nop    nop    nop    nop    nop    nop    O
  1417. X96    nop    nop    nop    nop    nop    nop    nop    nop    O
  1418. X97    nop    nop    nop    nop    nop    nop    nop    nop    O
  1419. X98    nop    nop    nop    nop    nop    nop    nop    nop    O
  1420. X99    nop    nop    nop    nop    nop    nop    nop    nop    O
  1421. X100    nop    nop    nop    nop    nop    nop    nop    nop    O
  1422. X101    nop    nop    nop    nop    nop    nop    nop    nop    O
  1423. X102    nop    nop    nop    nop    nop    nop    nop    nop    O
  1424. X103    nop    nop    nop    nop    nop    nop    nop    nop    O
  1425. X104    nop    nop    nop    nop    nop    nop    nop    nop    O
  1426. X105    nop    nop    nop    nop    nop    nop    nop    nop    O
  1427. X106    nop    nop    nop    nop    nop    nop    nop    nop    O
  1428. X107    fkey52    fkey52    nop    nop    pscr    fpscrn    nop    nop    O
  1429. X108    nop    nop    nop    nop    nop    nop    nop    nop    O
  1430. X109    nop    nop    nop    nop    nop    nop    nop    nop    O
  1431. X110    nop    nop    nop    nop    nop    nop    nop    nop    O
  1432. X111    fkey50    fkey50    nop    nop    nop    nop    nop    nop    O
  1433. X112    nop    nop    nop    nop    nop    nop    nop    nop    O
  1434. X113    nop    nop    nop    nop    nop    nop    nop    nop    O
  1435. X114    ralt    ralt    ralt    ralt    ralt    ralt    ralt    ralt    O
  1436. X115    rctrl    rctrl    rctrl    rctrl    rctrl    rctrl    rctrl    rctrl    O
  1437. X116    nl    nl    nop    nop    0x8a    0x8a    nop    nop    O
  1438. X117    '/'    '/'    nop    nop    0xaf    0xaf    nop    nop    O
  1439. X118    nop    nop    nop    nop    nop    nop    nop    nop    O
  1440. X119    break    break    break    break    break    break    break    break    O
  1441. X120    fkey49    fkey49    nop    nop    scr00    scr00    nop    nop    O
  1442. X121    del    del    nop    nop    0xff    0xff    nop    nop    O
  1443. X122    fkey56    fkey56    nop    nop    nop    nop    nop    nop    O
  1444. X123    fkey59    fkey59    nop    nop    nop    nop    nop    nop    O
  1445. X124    nop    nop    nop    nop    nop    nop    nop    nop    O
  1446. X125    fkey54    fkey54    nop    nop    nscr    fnscrn    nop    nop    O
  1447. X126    fkey58    fkey58    nop    nop    nop    nop    nop    nop    O
  1448. X127    fkey48    fkey48    nop    nop    nop    nop    nop    nop    O
  1449. END_OF_FILE
  1450. if test 5742 -ne `wc -c <'usa-meta.kbd'`; then
  1451.     echo shar: \"'usa-meta.kbd'\" unpacked with wrong size!
  1452. fi
  1453. # end of 'usa-meta.kbd'
  1454. fi
  1455. echo shar: End of archive 1 \(of 1\).
  1456. cp /dev/null ark1isdone
  1457. MISSING=""
  1458. for I in 1 ; do
  1459.     if test ! -f ark${I}isdone ; then
  1460.     MISSING="${MISSING} ${I}"
  1461.     fi
  1462. done
  1463. if test "${MISSING}" = "" ; then
  1464.     echo You have the archive.
  1465.     rm -f ark[1-9]isdone
  1466. else
  1467.     echo You still need to unpack the following archives:
  1468.     echo "        " ${MISSING}
  1469. fi
  1470. ##  End of shell archive.
  1471. exit 0
  1472. --
  1473. Piercarlo Grandi                   | ARPA: pcg%uk.ac.aber@nsfnet-relay.ac.uk
  1474. Dept of CS, UCW Aberystwyth        | UUCP: ...!mcsun!ukc!aber-cs!pcg
  1475. Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@aber.ac.uk
  1476.