kbdcontrol.c (3864) | kbdcontrol.c (5536) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 1994 S�ren Schmidt | 2 * Copyright (c) 1994-1995 S�ren Schmidt |
3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright --- 8 unchanged lines hidden (view full) --- 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * | 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright --- 8 unchanged lines hidden (view full) --- 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * |
27 * $Id: kbdcontrol.c,v 1.1 1994/08/17 08:59:34 sos Exp $ | 27 * $Id: kbdcontrol.c,v 1.2 1994/10/25 20:50:41 swallace Exp $ |
28 */ 29 30#include <ctype.h> 31#include <stdio.h> 32#include <string.h> 33#include <machine/console.h> 34#include "path.h" 35#include "lex.h" --- 45 unchanged lines hidden (view full) --- 81 exit(1); 82 return(""); 83} 84 85 86char * 87mkfullname(const char *s1, const char *s2, const char *s3) 88{ | 28 */ 29 30#include <ctype.h> 31#include <stdio.h> 32#include <string.h> 33#include <machine/console.h> 34#include "path.h" 35#include "lex.h" --- 45 unchanged lines hidden (view full) --- 81 exit(1); 82 return(""); 83} 84 85 86char * 87mkfullname(const char *s1, const char *s2, const char *s3) 88{ |
89static char *buf = NULL; 90static int bufl = 0; 91int f; | 89 static char *buf = NULL; 90 static int bufl = 0; 91 int f; |
92 | 92 |
93 | |
94 f = strlen(s1) + strlen(s2) + strlen(s3) + 1; 95 if (f > bufl) 96 if (buf) 97 buf = (char *)realloc(buf, f); 98 else 99 buf = (char *)malloc(f); 100 if (!buf) { 101 bufl = 0; --- 314 unchanged lines hidden (view full) --- 416 if (ioctl(0, SETFKEY, &fkey) < 0) 417 perror("setting function key"); 418} 419 420 421void 422set_bell_values(char *opt) 423{ | 93 f = strlen(s1) + strlen(s2) + strlen(s3) + 1; 94 if (f > bufl) 95 if (buf) 96 buf = (char *)realloc(buf, f); 97 else 98 buf = (char *)malloc(f); 99 if (!buf) { 100 bufl = 0; --- 314 unchanged lines hidden (view full) --- 415 if (ioctl(0, SETFKEY, &fkey) < 0) 416 perror("setting function key"); 417} 418 419 420void 421set_bell_values(char *opt) 422{ |
424 int duration, pitch; | 423 int bell, duration, pitch; |
425 | 424 |
426 if (!strcmp(opt, "normal")) 427 duration = 1, pitch = 15; | 425 if (!strcmp(opt, "visual")) 426 bell = 1, duration = 1, pitch = 800; 427 else if (!strcmp(opt, "normal")) 428 bell = 0, duration = 1, pitch = 800; |
428 else { 429 int n; 430 char *v1; | 429 else { 430 int n; 431 char *v1; |
431 | 432 433 bell = 0; |
432 duration = strtol(opt, &v1, 0); 433 if ((duration < 0) || (*v1 != '.')) 434 goto badopt; 435 opt = ++v1; 436 pitch = strtol(opt, &v1, 0); 437 if ((pitch < 0) || (*opt == '\0') || (*v1 != '\0')) { 438badopt: 439 fprintf(stderr, 440 "argument to -b must be DURATION.PITCH\n"); 441 return; 442 } 443 } 444 445 if (verbose) | 434 duration = strtol(opt, &v1, 0); 435 if ((duration < 0) || (*v1 != '.')) 436 goto badopt; 437 opt = ++v1; 438 pitch = strtol(opt, &v1, 0); 439 if ((pitch < 0) || (*opt == '\0') || (*v1 != '\0')) { 440badopt: 441 fprintf(stderr, 442 "argument to -b must be DURATION.PITCH\n"); 443 return; 444 } 445 } 446 447 if (verbose) |
446 fprintf(stderr, "setting bell values to %d.%d\n", 447 duration, pitch); 448 fprintf(stderr, "[=%d;%dB", pitch, duration); | 448 if (bell) 449 fprintf(stderr, "setting visual bell\n"); 450 else 451 fprintf(stderr, "setting bell values to %d.%d\n", 452 duration, pitch); 453 ioctl(0, CONS_BELLTYPE, &bell); 454 if (!bell) 455 fprintf(stderr, "[=%d;%dB", pitch, duration); |
449} 450 451 452void 453set_keyrates(char *opt) 454{ 455struct { 456 int rep:5; --- 39 unchanged lines hidden (view full) --- 496 if (ioctl(0, KDSETRAD, rate) < 0) 497 perror("setting keyboard rate"); 498} 499 500 501usage() 502{ 503 fprintf(stderr, | 456} 457 458 459void 460set_keyrates(char *opt) 461{ 462struct { 463 int rep:5; --- 39 unchanged lines hidden (view full) --- 503 if (ioctl(0, KDSETRAD, rate) < 0) 504 perror("setting keyboard rate"); 505} 506 507 508usage() 509{ 510 fprintf(stderr, |
504"Usage: kbdcontrol -b duration.pitch (set bell duration & pitch)\n" 505" -d (dump keyboard map to stdout)\n" 506" -l filename (load keyboard map file)\n" 507" -f <N> string (set function key N to send <string>)\n" 508" -F (set function keys back to default)\n" 509" -r delay.repeat (set keyboard delay & repeat rate)\n" 510" -r slow (set keyboard delay & repeat to slow)\n" 511" -r normal (set keyboard delay & repeat to normal)\n" 512" -r fast (set keyboard delay & repeat to fast)\n" 513" -v (verbose)\n" | 511"Usage: kbdcontrol -b duration.pitch (set bell duration & pitch)\n" 512" -b normal | visual (set bell to visual type)\n" 513" -d (dump keyboard map to stdout)\n" 514" -l filename (load keyboard map file)\n" 515" -f <N> string (set function key N to send <string>)\n" 516" -F (set function keys back to default)\n" 517" -r delay.repeat (set keyboard delay & repeat rate)\n" 518" -r slow (set keyboard delay & repeat to slow)\n" 519" -r normal (set keyboard delay & repeat to normal)\n" 520" -r fast (set keyboard delay & repeat to fast)\n" 521" -v (verbose)\n" |
514 ); 515} 516 517 518void 519main(int argc, char **argv) 520{ 521 extern char *optarg; --- 46 unchanged lines hidden --- | 522 ); 523} 524 525 526void 527main(int argc, char **argv) 528{ 529 extern char *optarg; --- 46 unchanged lines hidden --- |