kbdcontrol.c revision 9202
12088Ssos/*- 25536Ssos * Copyright (c) 1994-1995 S�ren Schmidt 32088Ssos * All rights reserved. 42088Ssos * 52088Ssos * Redistribution and use in source and binary forms, with or without 62088Ssos * modification, are permitted provided that the following conditions 72088Ssos * are met: 82088Ssos * 1. Redistributions of source code must retain the above copyright 95994Ssos * notice, this list of conditions and the following disclaimer, 105994Ssos * in this position and unchanged. 112088Ssos * 2. Redistributions in binary form must reproduce the above copyright 122088Ssos * notice, this list of conditions and the following disclaimer in the 132088Ssos * documentation and/or other materials provided with the distribution. 142088Ssos * 3. The name of the author may not be used to endorse or promote products 152088Ssos * derived from this software withough specific prior written permission 162088Ssos * 172088Ssos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 182088Ssos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 192088Ssos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 202088Ssos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 212088Ssos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 222088Ssos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232088Ssos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242088Ssos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252088Ssos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 262088Ssos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272088Ssos * 289202Srgrimes * $Id: kbdcontrol.c,v 1.6.2.1 1995/06/05 09:23:13 davidg Exp $ 292088Ssos */ 302088Ssos 312088Ssos#include <ctype.h> 322088Ssos#include <stdio.h> 333864Sswallace#include <string.h> 342088Ssos#include <machine/console.h> 352088Ssos#include "path.h" 362088Ssos#include "lex.h" 372088Ssos 382088Ssoschar ctrl_names[32][4] = { 398857Srgrimes "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel", 402088Ssos "bs ", "ht ", "nl ", "vt ", "ff ", "cr ", "so ", "si ", 412088Ssos "dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb", 422088Ssos "can", "em ", "sub", "esc", "fs ", "gs ", "rs ", "ns " 432088Ssos }; 442088Ssos 455994Ssoschar fkey_table[96][MAXFK] = { 465994Ssos/* 01-04 */ "\033[M", "\033[N", "\033[O", "\033[P", 475994Ssos/* 05-08 */ "\033[Q", "\033[R", "\033[S", "\033[T", 485994Ssos/* 09-12 */ "\033[U", "\033[V", "\033[W", "\033[X", 495994Ssos/* 13-16 */ "\033[Y", "\033[Z", "\033[a", "\033[b", 505994Ssos/* 17-20 */ "\033[c", "\033[d", "\033[e", "\033[f", 515994Ssos/* 21-24 */ "\033[g", "\033[h", "\033[i", "\033[j", 525994Ssos/* 25-28 */ "\033[k", "\033[l", "\033[m", "\033[n", 535994Ssos/* 29-32 */ "\033[o", "\033[p", "\033[q", "\033[r", 545994Ssos/* 33-36 */ "\033[s", "\033[t", "\033[u", "\033[v", 555994Ssos/* 37-40 */ "\033[w", "\033[x", "\033[y", "\033[z", 565994Ssos/* 41-44 */ "\033[@", "\033[[", "\033[\\","\033[]", 579202Srgrimes/* 45-48 */ "\033[^", "\033[_", "\033[`", "\033[{", 585994Ssos/* 49-52 */ "\033[H", "\033[A", "\033[I", "-" , 595994Ssos/* 53-56 */ "\033[D", "\033[E", "\033[C", "+" , 605994Ssos/* 57-60 */ "\033[F", "\033[B", "\033[G", "\033[L", 619202Srgrimes/* 61-64 */ "\177", "\033[J", "\033[~", "\033[}", 625994Ssos/* 65-68 */ "" , "" , "" , "" , 635994Ssos/* 69-72 */ "" , "" , "" , "" , 645994Ssos/* 73-76 */ "" , "" , "" , "" , 655994Ssos/* 77-80 */ "" , "" , "" , "" , 665994Ssos/* 81-84 */ "" , "" , "" , "" , 675994Ssos/* 85-88 */ "" , "" , "" , "" , 685994Ssos/* 89-92 */ "" , "" , "" , "" , 695994Ssos/* 93-96 */ "" , "" , "" , "" , 702088Ssos }; 712088Ssos 722088Ssosconst int delays[] = {250, 500, 750, 1000}; 732088Ssosconst int repeats[] = { 34, 38, 42, 46, 50, 55, 59, 63, 742088Ssos 68, 76, 84, 92, 100, 110, 118, 126, 752088Ssos 136, 152, 168, 184, 200, 220, 236, 252, 762088Ssos 272, 304, 336, 368, 400, 440, 472, 504}; 772088Ssosconst int ndelays = (sizeof(delays) / sizeof(int)); 782088Ssosconst int nrepeats = (sizeof(repeats) / sizeof(int)); 792088Ssosint hex = 0; 806046Ssosint number; 812088Ssoschar letter; 822088Ssos 832088Ssos 842088Ssoschar * 852088Ssosnextarg(int ac, char **av, int *indp, int oc) 862088Ssos{ 872088Ssos if (*indp < ac) 882088Ssos return(av[(*indp)++]); 892088Ssos fprintf(stderr, "%s: option requires two arguments -- %c\n", av[0], oc); 902088Ssos usage(); 912088Ssos exit(1); 922088Ssos return(""); 932088Ssos} 942088Ssos 952088Ssos 962088Ssoschar * 972088Ssosmkfullname(const char *s1, const char *s2, const char *s3) 982088Ssos{ 995536Ssos static char *buf = NULL; 1005536Ssos static int bufl = 0; 1015536Ssos int f; 1022088Ssos 1032088Ssos f = strlen(s1) + strlen(s2) + strlen(s3) + 1; 1042088Ssos if (f > bufl) 1052088Ssos if (buf) 1062088Ssos buf = (char *)realloc(buf, f); 1072088Ssos else 1082088Ssos buf = (char *)malloc(f); 1092088Ssos if (!buf) { 1102088Ssos bufl = 0; 1112088Ssos return(NULL); 1122088Ssos } 1132088Ssos 1142088Ssos bufl = f; 1152088Ssos strcpy(buf, s1); 1162088Ssos strcat(buf, s2); 1172088Ssos strcat(buf, s3); 1182088Ssos return(buf); 1192088Ssos} 1202088Ssos 1212088Ssos 1222088Ssosint 1232088Ssosget_entry() 1242088Ssos{ 1252088Ssos switch (yylex()) { 1262088Ssos case TNOP: 1272088Ssos return NOP | 0x100; 1282088Ssos case TLSH: 1292088Ssos return LSH | 0x100; 1302088Ssos case TRSH: 1312088Ssos return RSH | 0x100; 1322088Ssos case TCLK: 1332088Ssos return CLK | 0x100; 1342088Ssos case TNLK: 1352088Ssos return NLK | 0x100; 1362088Ssos case TSLK: 1372088Ssos return SLK | 0x100; 1382088Ssos case TBTAB: 1392088Ssos return BTAB | 0x100; 1402088Ssos case TLALT: 1412088Ssos return LALT | 0x100; 1422088Ssos case TLCTR: 1432088Ssos return LCTR | 0x100; 1442088Ssos case TNEXT: 1452088Ssos return NEXT | 0x100; 1462088Ssos case TRCTR: 1472088Ssos return RCTR | 0x100; 1482088Ssos case TRALT: 1492088Ssos return RALT | 0x100; 1502088Ssos case TALK: 1512088Ssos return ALK | 0x100; 1522088Ssos case TASH: 1532088Ssos return ASH | 0x100; 1542088Ssos case TMETA: 1552088Ssos return META | 0x100; 1562088Ssos case TRBT: 1572088Ssos return RBT | 0x100; 1582088Ssos case TDBG: 1592088Ssos return DBG | 0x100; 1605994Ssos case TSUSP: 1615994Ssos return SUSP | 0x100; 1622088Ssos case TFUNC: 1632088Ssos if (F(number) > L_FN) 1642088Ssos return -1; 1652088Ssos return F(number) | 0x100; 1662088Ssos case TSCRN: 1672088Ssos if (S(number) > L_SCR) 1682088Ssos return -1; 1692088Ssos return S(number) | 0x100; 1702088Ssos case TLET: 1712088Ssos return (unsigned char)letter; 1722088Ssos case TNUM: 1732088Ssos if (number < 0 || number > 255) 1742088Ssos return -1; 1752088Ssos return number; 1762088Ssos default: 1772088Ssos return -1; 1782088Ssos } 1792088Ssos} 1802088Ssos 1818857Srgrimes 1822088Ssosint 1832088Ssosget_key_definition_line(FILE* fd, keymap_t *map) 1842088Ssos{ 1852088Ssos int i, def, scancode; 1862088Ssos 1872088Ssos yyin = fd; 1882088Ssos 1892088Ssos /* get scancode number */ 1908857Srgrimes if (yylex() != TNUM) 1912088Ssos return -1; 1922088Ssos if (number < 0 || number >= NUM_KEYS) 1932088Ssos return -1; 1942088Ssos scancode = number; 1952088Ssos 1962088Ssos /* get key definitions */ 1972088Ssos map->key[scancode].spcl = 0; 1982088Ssos for (i=0; i<NUM_STATES; i++) { 1992088Ssos if ((def = get_entry()) == -1) 2002088Ssos return -1; 2012088Ssos if (def & 0x100) 2022088Ssos map->key[scancode].spcl |= (0x80 >> i); 2032088Ssos map->key[scancode].map[i] = def & 0xFF; 2042088Ssos } 2052088Ssos /* get lock state key def */ 2062088Ssos if (yylex() != TFLAG) 2072088Ssos return -1; 2082088Ssos map->key[scancode].flgs = number; 2092088Ssos return scancode; 2102088Ssos} 2112088Ssos 2122088Ssos 2138857Srgrimesint 2142088Ssosprint_entry(FILE *fp, int value) 2152088Ssos{ 2162088Ssos int val = value & 0xFF; 2172088Ssos 2182088Ssos switch (value) { 2192088Ssos case NOP | 0x100: 2208857Srgrimes fprintf(fp, " nop "); 2212088Ssos break; 2222088Ssos case LSH | 0x100: 2232088Ssos fprintf(fp, " lshift"); 2242088Ssos break; 2252088Ssos case RSH | 0x100: 2262088Ssos fprintf(fp, " rshift"); 2272088Ssos break; 2282088Ssos case CLK | 0x100: 2292088Ssos fprintf(fp, " clock "); 2302088Ssos break; 2312088Ssos case NLK | 0x100: 2322088Ssos fprintf(fp, " nlock "); 2332088Ssos break; 2342088Ssos case SLK | 0x100: 2352088Ssos fprintf(fp, " slock "); 2362088Ssos break; 2372088Ssos case BTAB | 0x100: 2382088Ssos fprintf(fp, " btab "); 2392088Ssos break; 2402088Ssos case LALT | 0x100: 2412088Ssos fprintf(fp, " lalt "); 2422088Ssos break; 2432088Ssos case LCTR | 0x100: 2442088Ssos fprintf(fp, " lctrl "); 2452088Ssos break; 2462088Ssos case NEXT | 0x100: 2472088Ssos fprintf(fp, " nscr "); 2482088Ssos break; 2492088Ssos case RCTR | 0x100: 2502088Ssos fprintf(fp, " rctrl "); 2512088Ssos break; 2522088Ssos case RALT | 0x100: 2532088Ssos fprintf(fp, " ralt "); 2542088Ssos break; 2552088Ssos case ALK | 0x100: 2562088Ssos fprintf(fp, " alock "); 2572088Ssos break; 2582088Ssos case ASH | 0x100: 2592088Ssos fprintf(fp, " ashift"); 2602088Ssos break; 2612088Ssos case META | 0x100: 2622088Ssos fprintf(fp, " meta "); 2632088Ssos break; 2642088Ssos case RBT | 0x100: 2652088Ssos fprintf(fp, " boot "); 2662088Ssos break; 2672088Ssos case DBG | 0x100: 2682088Ssos fprintf(fp, " debug "); 2692088Ssos break; 2702088Ssos default: 2712088Ssos if (value & 0x100) { 2728857Srgrimes if (val >= F_FN && val <= L_FN) 2732088Ssos fprintf(fp, " fkey%02d", val - F_FN + 1); 2748857Srgrimes else if (val >= F_SCR && val <= L_SCR) 2752088Ssos fprintf(fp, " scr%02d ", val - F_SCR + 1); 2762088Ssos else if (hex) 2778857Srgrimes fprintf(fp, " 0x%02x ", val); 2782088Ssos else 2798857Srgrimes fprintf(fp, " %3d ", val); 2802088Ssos } 2812088Ssos else { 2822088Ssos if (val < ' ') 2838857Srgrimes fprintf(fp, " %s ", ctrl_names[val]); 2842088Ssos else if (val == 127) 2858857Srgrimes fprintf(fp, " del "); 2869202Srgrimes else if (isascii(val) && isprint(val)) 2878857Srgrimes fprintf(fp, " '%c' ", val); 2882088Ssos else if (hex) 2898857Srgrimes fprintf(fp, " 0x%02x ", val); 2902088Ssos else 2918857Srgrimes fprintf(fp, " %3d ", val); 2922088Ssos } 2932088Ssos } 2942088Ssos} 2952088Ssos 2962088Ssos 2972088Ssosvoid 2982088Ssosprint_key_definition_line(FILE *fp, int scancode, struct key_t *key) 2992088Ssos{ 3002088Ssos int i, value; 3012088Ssos 3022088Ssos /* print scancode number */ 3032088Ssos if (hex) 3042088Ssos fprintf(fp, " 0x%02x ", scancode); 3052088Ssos else 3062088Ssos fprintf(fp, " %03d ", scancode); 3072088Ssos 3082088Ssos /* print key definitions */ 3092088Ssos for (i=0; i<NUM_STATES; i++) { 3102088Ssos if (key->spcl & (0x80 >> i)) 3112088Ssos print_entry(fp, key->map[i] | 0x100); 3122088Ssos else 3138857Srgrimes print_entry(fp, key->map[i]); 3142088Ssos } 3152088Ssos 3162088Ssos /* print lock state key def */ 3172088Ssos switch (key->flgs) { 3182088Ssos case 0: 3192088Ssos fprintf(fp, " O\n"); 3202088Ssos break; 3212088Ssos case 1: 3222088Ssos fprintf(fp, " C\n"); 3232088Ssos break; 3242088Ssos case 2: 3252088Ssos fprintf(fp, " N\n"); 3262088Ssos break; 3276046Ssos case 3: 3286046Ssos fprintf(fp, " B\n"); 3296046Ssos break; 3308857Srgrimes } 3312088Ssos} 3322088Ssos 3332088Ssos 3342088Ssosvoid 3352088Ssosload_keymap(char *opt) 3362088Ssos{ 3372088Ssos keymap_t map; 3382088Ssos FILE *fd; 3392088Ssos int scancode, i; 3402088Ssos char *name; 3412088Ssos char *prefix[] = {"", "", KEYMAP_PATH, NULL}; 3422088Ssos char *postfix[] = {"", ".kbd", ".kbd"}; 3432088Ssos 3442088Ssos for (i=0; prefix[i]; i++) { 3452088Ssos name = mkfullname(prefix[i], opt, postfix[i]); 3462088Ssos if (fd = fopen(name, "r")) 3472088Ssos break; 3482088Ssos } 3492088Ssos if (fd == NULL) { 3502088Ssos perror("keymap file not found"); 3512088Ssos return; 3522088Ssos } 3533864Sswallace memset(&map, 0, sizeof(map)); 3542088Ssos while (1) { 3552088Ssos if ((scancode = get_key_definition_line(fd, &map)) < 0) 3562088Ssos break; 3572088Ssos if (scancode > map.n_keys) map.n_keys = scancode; 3582088Ssos } 3592088Ssos if (ioctl(0, PIO_KEYMAP, &map) < 0) { 3602088Ssos perror("setting keymap"); 3612088Ssos fclose(fd); 3622088Ssos return; 3632088Ssos } 3642088Ssos} 3652088Ssos 3662088Ssos 3672088Ssosvoid 3682088Ssosprint_keymap() 3692088Ssos{ 3702088Ssos keymap_t map; 3712088Ssos int i; 3722088Ssos 3732088Ssos if (ioctl(0, GIO_KEYMAP, &map) < 0) { 3742088Ssos perror("getting keymap"); 3752088Ssos exit(1); 3762088Ssos } 3772088Ssos printf( 3782088Ssos"# alt\n" 3792088Ssos"# scan cntrl alt alt cntrl lock\n" 3802088Ssos"# code base shift cntrl shift alt shift cntrl shift state\n" 3812088Ssos"# ------------------------------------------------------------------\n" 3822088Ssos ); 3832088Ssos for (i=0; i<map.n_keys; i++) 3842088Ssos print_key_definition_line(stdout, i, &map.key[i]); 3852088Ssos} 3862088Ssos 3872088Ssos 3882088Ssosvoid 3892088Ssosload_default_functionkeys() 3902088Ssos{ 3912088Ssos fkeyarg_t fkey; 3922088Ssos int i; 3932088Ssos 3942088Ssos for (i=0; i<NUM_FKEYS; i++) { 3952088Ssos fkey.keynum = i; 3962088Ssos strcpy(fkey.keydef, fkey_table[i]); 3972088Ssos fkey.flen = strlen(fkey_table[i]); 3982088Ssos if (ioctl(0, SETFKEY, &fkey) < 0) 3992088Ssos perror("setting function key"); 4002088Ssos } 4012088Ssos} 4022088Ssos 4032088Ssosvoid 4042088Ssosset_functionkey(char *keynumstr, char *string) 4052088Ssos{ 4062088Ssos fkeyarg_t fkey; 4072088Ssos int keynum; 4082088Ssos 4092088Ssos if (!strcmp(keynumstr, "load") && !strcmp(string, "default")) { 4102088Ssos load_default_functionkeys(); 4112088Ssos return; 4122088Ssos } 4132088Ssos fkey.keynum = atoi(keynumstr); 4142088Ssos if (fkey.keynum < 1 || fkey.keynum > NUM_FKEYS) { 4158857Srgrimes fprintf(stderr, 4162088Ssos "function key number must be between 1 and %d\n", 4172088Ssos NUM_FKEYS); 4182088Ssos return; 4192088Ssos } 4202088Ssos if ((fkey.flen = strlen(string)) > MAXFK) { 4212088Ssos fprintf(stderr, "function key string too long (%d > %d)\n", 4222088Ssos fkey.flen, MAXFK); 4232088Ssos return; 4242088Ssos } 4252088Ssos strcpy(fkey.keydef, string); 4262088Ssos fkey.keynum -= 1; 4272088Ssos if (ioctl(0, SETFKEY, &fkey) < 0) 4282088Ssos perror("setting function key"); 4292088Ssos} 4302088Ssos 4312088Ssos 4322088Ssosvoid 4332088Ssosset_bell_values(char *opt) 4342088Ssos{ 4355536Ssos int bell, duration, pitch; 4362088Ssos 4378857Srgrimes if (!strcmp(opt, "visual")) 4385536Ssos bell = 1, duration = 1, pitch = 800; 4395536Ssos else if (!strcmp(opt, "normal")) 4405536Ssos bell = 0, duration = 1, pitch = 800; 4412088Ssos else { 4422088Ssos int n; 4432088Ssos char *v1; 4448857Srgrimes 4455536Ssos bell = 0; 4462088Ssos duration = strtol(opt, &v1, 0); 4472088Ssos if ((duration < 0) || (*v1 != '.')) 4482088Ssos goto badopt; 4492088Ssos opt = ++v1; 4502088Ssos pitch = strtol(opt, &v1, 0); 4512088Ssos if ((pitch < 0) || (*opt == '\0') || (*v1 != '\0')) { 4522088Ssosbadopt: 4538857Srgrimes fprintf(stderr, 4542088Ssos "argument to -b must be DURATION.PITCH\n"); 4552088Ssos return; 4562088Ssos } 4572088Ssos } 4582088Ssos 4595536Ssos ioctl(0, CONS_BELLTYPE, &bell); 4605536Ssos if (!bell) 4615536Ssos fprintf(stderr, "[=%d;%dB", pitch, duration); 4622088Ssos} 4632088Ssos 4642088Ssos 4652088Ssosvoid 4662088Ssosset_keyrates(char *opt) 4672088Ssos{ 4682088Ssosstruct { 4692088Ssos int rep:5; 4702088Ssos int del:2; 4712088Ssos int pad:1; 4722088Ssos }rate; 4732088Ssos 4742088Ssos if (!strcmp(opt, "slow")) 4752088Ssos rate.del = 3, rate.rep = 31; 4762088Ssos else if (!strcmp(opt, "normal")) 4772088Ssos rate.del = 1, rate.rep = 15; 4782088Ssos else if (!strcmp(opt, "fast")) 4792088Ssos rate.del = rate.rep = 0; 4802088Ssos else { 4812088Ssos int n; 4822088Ssos int delay, repeat; 4832088Ssos char *v1; 4842088Ssos 4852088Ssos delay = strtol(opt, &v1, 0); 4862088Ssos if ((delay < 0) || (*v1 != '.')) 4872088Ssos goto badopt; 4882088Ssos opt = ++v1; 4892088Ssos repeat = strtol(opt, &v1, 0); 4902088Ssos if ((repeat < 0) || (*opt == '\0') || (*v1 != '\0')) { 4912088Ssosbadopt: 4928857Srgrimes fprintf(stderr, 4932088Ssos "argument to -r must be delay.repeat\n"); 4942088Ssos return; 4952088Ssos } 4962088Ssos for (n = 0; n < ndelays - 1; n++) 4972088Ssos if (delay <= delays[n]) 4982088Ssos break; 4992088Ssos rate.del = n; 5002088Ssos for (n = 0; n < nrepeats - 1; n++) 5012088Ssos if (repeat <= repeats[n]) 5022088Ssos break; 5032088Ssos rate.rep = n; 5042088Ssos } 5052088Ssos 5062088Ssos if (ioctl(0, KDSETRAD, rate) < 0) 5072088Ssos perror("setting keyboard rate"); 5082088Ssos} 5092088Ssos 5102088Ssos 5116046Ssosvoid 5126046Ssosset_history(char *opt) 5136046Ssos{ 5146046Ssos int size; 5156046Ssos 5166046Ssos size = atoi(opt); 5176046Ssos if ((*opt == '\0') || size < 0) { 5186046Ssos fprintf(stderr, "argument must be a positive number\n"); 5196046Ssos return; 5206046Ssos } 5216046Ssos if (ioctl(0, CONS_HISTORY, &size) == -1) 5226046Ssos perror("setting history buffer size"); 5236046Ssos} 5246046Ssos 5256046Ssos 5262088Ssosusage() 5272088Ssos{ 5282088Ssos fprintf(stderr, 5295536Ssos"Usage: kbdcontrol -b duration.pitch (set bell duration & pitch)\n" 5305536Ssos" -b normal | visual (set bell to visual type)\n" 5315536Ssos" -d (dump keyboard map to stdout)\n" 5325536Ssos" -l filename (load keyboard map file)\n" 5336046Ssos" -h <N> (set history buffer size (in lines))\n" 5345536Ssos" -f <N> string (set function key N to send <string>)\n" 5355536Ssos" -F (set function keys back to default)\n" 5365536Ssos" -r delay.repeat (set keyboard delay & repeat rate)\n" 5375536Ssos" -r slow (set keyboard delay & repeat to slow)\n" 5385536Ssos" -r normal (set keyboard delay & repeat to normal)\n" 5395536Ssos" -r fast (set keyboard delay & repeat to fast)\n" 5409202Srgrimes" -x (use hexadecimal numbers in -d option)\n" 5412088Ssos ); 5422088Ssos} 5432088Ssos 5442088Ssos 5452088Ssosvoid 5462088Ssosmain(int argc, char **argv) 5472088Ssos{ 5482088Ssos extern char *optarg; 5492088Ssos extern int optind; 5502088Ssos int opt; 5512088Ssos 5526046Ssos while((opt = getopt(argc, argv, "b:df:h:Fl:r:x")) != -1) 5532088Ssos switch(opt) { 5542088Ssos case 'b': 5552088Ssos set_bell_values(optarg); 5562088Ssos break; 5572088Ssos case 'd': 5582088Ssos print_keymap(); 5592088Ssos break; 5602088Ssos case 'l': 5612088Ssos load_keymap(optarg); 5622088Ssos break; 5632088Ssos case 'f': 5648857Srgrimes set_functionkey(optarg, 5652088Ssos nextarg(argc, argv, &optind, 'f')); 5662088Ssos break; 5672088Ssos case 'F': 5682088Ssos load_default_functionkeys(); 5692088Ssos break; 5706046Ssos case 'h': 5716046Ssos set_history(optarg); 5726046Ssos break; 5732088Ssos case 'r': 5742088Ssos set_keyrates(optarg); 5752088Ssos break; 5762088Ssos case 'x': 5772088Ssos hex = 1; 5782088Ssos break; 5792088Ssos default: 5802088Ssos usage(); 5812088Ssos exit(1); 5822088Ssos } 5832088Ssos if ((optind != argc) || (argc == 1)) { 5842088Ssos usage(); 5852088Ssos exit(1); 5862088Ssos } 5872088Ssos exit(0); 5882088Ssos} 5892088Ssos 5902088Ssos 591