Style fixes:
- Use EXIT_SUCCESS/EXIT_FAILURE where appropriate. - Cut long lines. - Properly indent continuation of lines. - Sort includes. - Replace u_int with unsigned int. - Remove parenthesis around return values. - Add blank line at the beginning of functions without local parameters. - Cast *printf calls to void.
This commit is contained in:
parent
fb038910ea
commit
c799a9c4c0
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: display.c,v 1.11 2005/04/30 16:38:21 jmmv Exp $ */
|
||||
/* $NetBSD: display.c,v 1.12 2006/02/05 18:11:46 jmmv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -39,13 +39,14 @@
|
|||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "wsconsctl.h"
|
||||
|
||||
static int border;
|
||||
|
@ -65,8 +66,8 @@ struct field display_field_tab[] = {
|
|||
{ "backlight", &backlight.curval, FMT_UINT, 0 },
|
||||
{ "brightness", &brightness.curval, FMT_UINT, FLG_MODIFY },
|
||||
{ "contrast", &contrast.curval, FMT_UINT, FLG_MODIFY },
|
||||
{ "scroll.fastlines", &scroll_l.fastlines, FMT_UINT, FLG_MODIFY },
|
||||
{ "scroll.slowlines", &scroll_l.slowlines, FMT_UINT, FLG_MODIFY },
|
||||
{ "scroll.fastlines", &scroll_l.fastlines, FMT_UINT, FLG_MODIFY },
|
||||
{ "scroll.slowlines", &scroll_l.slowlines, FMT_UINT, FLG_MODIFY },
|
||||
{ "msg.default.attrs", &msg_default_attrs, FMT_ATTRS, 0 },
|
||||
{ "msg.default.bg", &msg_default_bg, FMT_COLOR, 0 },
|
||||
{ "msg.default.fg", &msg_default_fg, FMT_COLOR, 0 },
|
||||
|
@ -75,15 +76,16 @@ struct field display_field_tab[] = {
|
|||
{ "msg.kernel.fg", &msg_kernel_fg, FMT_COLOR, 0 },
|
||||
};
|
||||
|
||||
int display_field_tab_len = sizeof(display_field_tab)/
|
||||
sizeof(display_field_tab[0]);
|
||||
int display_field_tab_len = sizeof(display_field_tab) /
|
||||
sizeof(display_field_tab[0]);
|
||||
|
||||
void
|
||||
display_get_values(int fd)
|
||||
{
|
||||
|
||||
if (field_by_value(&dpytype)->flags & FLG_GET)
|
||||
if (ioctl(fd, WSDISPLAYIO_GTYPE, &dpytype) < 0)
|
||||
err(1, "WSDISPLAYIO_GTYPE");
|
||||
err(EXIT_FAILURE, "WSDISPLAYIO_GTYPE");
|
||||
|
||||
if (field_by_value(&border)->flags & FLG_GET)
|
||||
if (ioctl(fd, WSDISPLAYIO_GBORDER, &border) < 0)
|
||||
|
@ -152,36 +154,37 @@ void
|
|||
display_put_values(fd)
|
||||
int fd;
|
||||
{
|
||||
|
||||
if (field_by_value(&font.name)->flags & FLG_SET) {
|
||||
if (ioctl(fd, WSDISPLAYIO_SFONT, &font) < 0)
|
||||
err(1, "WSDISPLAYIO_SFONT");
|
||||
err(EXIT_FAILURE, "WSDISPLAYIO_SFONT");
|
||||
pr_field(field_by_value(&font.name), " -> ");
|
||||
}
|
||||
|
||||
if (field_by_value(&border)->flags & FLG_SET) {
|
||||
if (ioctl(fd, WSDISPLAYIO_SBORDER, &border) < 0)
|
||||
err(1, "WSDISPLAYIO_SBORDER");
|
||||
err(EXIT_FAILURE, "WSDISPLAYIO_SBORDER");
|
||||
pr_field(field_by_value(&border), " -> ");
|
||||
}
|
||||
|
||||
if (field_by_value(&backlight.curval)->flags & FLG_SET) {
|
||||
backlight.param = WSDISPLAYIO_PARAM_BACKLIGHT;
|
||||
if (ioctl(fd, WSDISPLAYIO_SETPARAM, &backlight) < 0)
|
||||
err(1, "WSDISPLAYIO_PARAM_BACKLIGHT");
|
||||
err(EXIT_FAILURE, "WSDISPLAYIO_PARAM_BACKLIGHT");
|
||||
pr_field(field_by_value(&backlight.curval), " -> ");
|
||||
}
|
||||
|
||||
if (field_by_value(&brightness.curval)->flags & FLG_SET) {
|
||||
brightness.param = WSDISPLAYIO_PARAM_BRIGHTNESS;
|
||||
if (ioctl(fd, WSDISPLAYIO_SETPARAM, &brightness) < 0)
|
||||
err(1, "WSDISPLAYIO_PARAM_BRIGHTNESS");
|
||||
err(EXIT_FAILURE, "WSDISPLAYIO_PARAM_BRIGHTNESS");
|
||||
pr_field(field_by_value(&brightness.curval), " -> ");
|
||||
}
|
||||
|
||||
if (field_by_value(&contrast.curval)->flags & FLG_SET) {
|
||||
contrast.param = WSDISPLAYIO_PARAM_CONTRAST;
|
||||
if (ioctl(fd, WSDISPLAYIO_SETPARAM, &contrast) < 0)
|
||||
err(1, "WSDISPLAYIO_PARAM_CONTRAST");
|
||||
err(EXIT_FAILURE, "WSDISPLAYIO_PARAM_CONTRAST");
|
||||
pr_field(field_by_value(&contrast.curval), " -> ");
|
||||
}
|
||||
|
||||
|
@ -194,7 +197,7 @@ display_put_values(fd)
|
|||
struct wsdisplay_msgattrs ma;
|
||||
|
||||
if (ioctl(fd, WSDISPLAYIO_GMSGATTRS, &ma) < 0)
|
||||
err(1, "WSDISPLAYIO_GMSGATTRS");
|
||||
err(EXIT_FAILURE, "WSDISPLAYIO_GMSGATTRS");
|
||||
|
||||
if (field_by_value(&msg_default_attrs)->flags & FLG_SET) {
|
||||
ma.default_attrs = msg_default_attrs;
|
||||
|
@ -204,12 +207,12 @@ display_put_values(fd)
|
|||
if (field_by_value(&msg_default_bg)->flags & FLG_SET) {
|
||||
ma.default_bg = msg_default_bg;
|
||||
pr_field(field_by_value(&msg_default_bg),
|
||||
" -> ");
|
||||
" -> ");
|
||||
}
|
||||
if (field_by_value(&msg_default_fg)->flags & FLG_SET) {
|
||||
ma.default_fg = msg_default_fg;
|
||||
pr_field(field_by_value(&msg_default_fg),
|
||||
" -> ");
|
||||
" -> ");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,17 +224,17 @@ display_put_values(fd)
|
|||
if (field_by_value(&msg_kernel_bg)->flags & FLG_SET) {
|
||||
ma.kernel_bg = msg_kernel_bg;
|
||||
pr_field(field_by_value(&msg_kernel_bg),
|
||||
" -> ");
|
||||
" -> ");
|
||||
}
|
||||
if (field_by_value(&msg_kernel_fg)->flags & FLG_SET) {
|
||||
ma.kernel_fg = msg_kernel_fg;
|
||||
pr_field(field_by_value(&msg_kernel_fg),
|
||||
" -> ");
|
||||
" -> ");
|
||||
}
|
||||
}
|
||||
|
||||
if (ioctl(fd, WSDISPLAYIO_SMSGATTRS, &ma) < 0)
|
||||
err(1, "WSDISPLAYIO_SMSGATTRS");
|
||||
err(EXIT_FAILURE, "WSDISPLAYIO_SMSGATTRS");
|
||||
}
|
||||
|
||||
scroll_l.which = 0;
|
||||
|
@ -241,7 +244,7 @@ display_put_values(fd)
|
|||
scroll_l.which |= WSDISPLAY_SCROLL_DOSLOWLINES;
|
||||
if (scroll_l.which != 0 &&
|
||||
ioctl(fd, WSDISPLAYIO_DSSCROLL, &scroll_l) < 0)
|
||||
err (1, "WSDISPLAYIO_DSSCROLL");
|
||||
err(EXIT_FAILURE, "WSDISPLAYIO_DSSCROLL");
|
||||
if (scroll_l.which & WSDISPLAY_SCROLL_DOFASTLINES)
|
||||
pr_field(field_by_value(&scroll_l.fastlines), " -> ");
|
||||
if (scroll_l.which & WSDISPLAY_SCROLL_DOSLOWLINES)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: keyboard.c,v 1.7 2005/01/19 20:37:52 xtraeme Exp $ */
|
||||
/* $NetBSD: keyboard.c,v 1.8 2006/02/05 18:11:46 jmmv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -38,10 +38,14 @@
|
|||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <dev/wscons/wsksymdef.h>
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "wsconsctl.h"
|
||||
|
||||
static int kbtype;
|
||||
|
@ -49,8 +53,8 @@ static int keyclick;
|
|||
static struct wskbd_bell_data bell;
|
||||
static struct wskbd_bell_data dfbell;
|
||||
static struct wscons_keymap mapdata[KS_NUMKEYCODES];
|
||||
struct wskbd_map_data kbmap = { KS_NUMKEYCODES, mapdata }; /* used in map_parse.y
|
||||
and in util.c */
|
||||
struct wskbd_map_data kbmap = /* used in map_parse.y and in util.c */
|
||||
{ KS_NUMKEYCODES, mapdata };
|
||||
static struct wskbd_keyrepeat_data repeat;
|
||||
static struct wskbd_keyrepeat_data dfrepeat;
|
||||
static struct wskbd_scroll_data scroll;
|
||||
|
@ -66,7 +70,8 @@ struct field keyboard_field_tab[] = {
|
|||
{ "bell.pitch.default", &dfbell.pitch, FMT_UINT, FLG_MODIFY },
|
||||
{ "bell.period.default", &dfbell.period, FMT_UINT, FLG_MODIFY },
|
||||
{ "bell.volume.default", &dfbell.volume, FMT_UINT, FLG_MODIFY },
|
||||
{ "map", &kbmap, FMT_KBMAP, FLG_MODIFY|FLG_NOAUTO },
|
||||
{ "map", &kbmap, FMT_KBMAP, FLG_MODIFY |
|
||||
FLG_NOAUTO },
|
||||
{ "repeat.del1", &repeat.del1, FMT_UINT, FLG_MODIFY },
|
||||
{ "repeat.deln", &repeat.delN, FMT_UINT, FLG_MODIFY },
|
||||
{ "repeat.del1.default", &dfrepeat.del1, FMT_UINT, FLG_MODIFY },
|
||||
|
@ -74,19 +79,20 @@ struct field keyboard_field_tab[] = {
|
|||
{ "ledstate", &ledstate, FMT_UINT, 0 },
|
||||
{ "encoding", &kbdencoding, FMT_KBDENC, FLG_MODIFY },
|
||||
{ "keyclick", &keyclick, FMT_UINT, FLG_MODIFY },
|
||||
{ "scroll.mode", &scroll.mode, FMT_UINT, FLG_MODIFY },
|
||||
{ "scroll.modifier", &scroll.modifier, FMT_UINT, FLG_MODIFY },
|
||||
{ "scroll.mode", &scroll.mode, FMT_UINT, FLG_MODIFY },
|
||||
{ "scroll.modifier", &scroll.modifier, FMT_UINT, FLG_MODIFY },
|
||||
};
|
||||
|
||||
int keyboard_field_tab_len = sizeof(keyboard_field_tab)/
|
||||
sizeof(keyboard_field_tab[0]);
|
||||
int keyboard_field_tab_len = sizeof(keyboard_field_tab) /
|
||||
sizeof(keyboard_field_tab[0]);
|
||||
|
||||
void
|
||||
keyboard_get_values(int fd)
|
||||
{
|
||||
|
||||
if (field_by_value(&kbtype)->flags & FLG_GET)
|
||||
if (ioctl(fd, WSKBDIO_GTYPE, &kbtype) < 0)
|
||||
err(1, "WSKBDIO_GTYPE");
|
||||
err(EXIT_FAILURE, "WSKBDIO_GTYPE");
|
||||
|
||||
bell.which = 0;
|
||||
if (field_by_value(&bell.pitch)->flags & FLG_GET)
|
||||
|
@ -96,7 +102,7 @@ keyboard_get_values(int fd)
|
|||
if (field_by_value(&bell.volume)->flags & FLG_GET)
|
||||
bell.which |= WSKBD_BELL_DOVOLUME;
|
||||
if (bell.which != 0 && ioctl(fd, WSKBDIO_GETBELL, &bell) < 0)
|
||||
err(1, "WSKBDIO_GETBELL");
|
||||
err(EXIT_FAILURE, "WSKBDIO_GETBELL");
|
||||
|
||||
dfbell.which = 0;
|
||||
if (field_by_value(&dfbell.pitch)->flags & FLG_GET)
|
||||
|
@ -107,12 +113,12 @@ keyboard_get_values(int fd)
|
|||
dfbell.which |= WSKBD_BELL_DOVOLUME;
|
||||
if (dfbell.which != 0 &&
|
||||
ioctl(fd, WSKBDIO_GETDEFAULTBELL, &dfbell) < 0)
|
||||
err(1, "WSKBDIO_GETDEFAULTBELL");
|
||||
err(EXIT_FAILURE, "WSKBDIO_GETDEFAULTBELL");
|
||||
|
||||
if (field_by_value(&kbmap)->flags & FLG_GET) {
|
||||
kbmap.maplen = KS_NUMKEYCODES;
|
||||
if (ioctl(fd, WSKBDIO_GETMAP, &kbmap) < 0)
|
||||
err(1, "WSKBDIO_GETMAP");
|
||||
err(EXIT_FAILURE, "WSKBDIO_GETMAP");
|
||||
}
|
||||
|
||||
repeat.which = 0;
|
||||
|
@ -122,7 +128,7 @@ keyboard_get_values(int fd)
|
|||
repeat.which |= WSKBD_KEYREPEAT_DODELN;
|
||||
if (repeat.which != 0 &&
|
||||
ioctl(fd, WSKBDIO_GETKEYREPEAT, &repeat) < 0)
|
||||
err(1, "WSKBDIO_GETKEYREPEAT");
|
||||
err(EXIT_FAILURE, "WSKBDIO_GETKEYREPEAT");
|
||||
|
||||
dfrepeat.which = 0;
|
||||
if (field_by_value(&dfrepeat.del1)->flags & FLG_GET)
|
||||
|
@ -131,15 +137,15 @@ keyboard_get_values(int fd)
|
|||
dfrepeat.which |= WSKBD_KEYREPEAT_DODELN;
|
||||
if (dfrepeat.which != 0 &&
|
||||
ioctl(fd, WSKBDIO_GETKEYREPEAT, &dfrepeat) < 0)
|
||||
err(1, "WSKBDIO_GETKEYREPEAT");
|
||||
err(EXIT_FAILURE, "WSKBDIO_GETKEYREPEAT");
|
||||
|
||||
if (field_by_value(&ledstate)->flags & FLG_GET)
|
||||
if (ioctl(fd, WSKBDIO_GETLEDS, &ledstate) < 0)
|
||||
err(1, "WSKBDIO_GETLEDS");
|
||||
err(EXIT_FAILURE, "WSKBDIO_GETLEDS");
|
||||
|
||||
if (field_by_value(&kbdencoding)->flags & FLG_GET)
|
||||
if (ioctl(fd, WSKBDIO_GETENCODING, &kbdencoding) < 0)
|
||||
err(1, "WSKBDIO_GETENCODING");
|
||||
err(EXIT_FAILURE, "WSKBDIO_GETENCODING");
|
||||
|
||||
if (field_by_value(&keyclick)->flags & FLG_GET) {
|
||||
ioctl(fd, WSKBDIO_GETKEYCLICK, &keyclick);
|
||||
|
@ -154,7 +160,7 @@ keyboard_get_values(int fd)
|
|||
if (scroll.which != 0) {
|
||||
if (ioctl(fd, WSKBDIO_GETSCROLL, &scroll) == -1) {
|
||||
if (errno != ENODEV)
|
||||
err(1, "WSKBDIO_GETSCROLL");
|
||||
err(EXIT_FAILURE, "WSKBDIO_GETSCROLL");
|
||||
else
|
||||
havescroll = 0;
|
||||
}
|
||||
|
@ -164,6 +170,7 @@ keyboard_get_values(int fd)
|
|||
void
|
||||
keyboard_put_values(int fd)
|
||||
{
|
||||
|
||||
bell.which = 0;
|
||||
if (field_by_value(&bell.pitch)->flags & FLG_SET)
|
||||
bell.which |= WSKBD_BELL_DOPITCH;
|
||||
|
@ -172,7 +179,7 @@ keyboard_put_values(int fd)
|
|||
if (field_by_value(&bell.volume)->flags & FLG_SET)
|
||||
bell.which |= WSKBD_BELL_DOVOLUME;
|
||||
if (bell.which != 0 && ioctl(fd, WSKBDIO_SETBELL, &bell) < 0)
|
||||
err(1, "WSKBDIO_SETBELL");
|
||||
err(EXIT_FAILURE, "WSKBDIO_SETBELL");
|
||||
if (bell.which & WSKBD_BELL_DOPITCH)
|
||||
pr_field(field_by_value(&bell.pitch), " -> ");
|
||||
if (bell.which & WSKBD_BELL_DOPERIOD)
|
||||
|
@ -189,7 +196,7 @@ keyboard_put_values(int fd)
|
|||
dfbell.which |= WSKBD_BELL_DOVOLUME;
|
||||
if (dfbell.which != 0 &&
|
||||
ioctl(fd, WSKBDIO_SETDEFAULTBELL, &dfbell) < 0)
|
||||
err(1, "WSKBDIO_SETDEFAULTBELL");
|
||||
err(EXIT_FAILURE, "WSKBDIO_SETDEFAULTBELL");
|
||||
if (dfbell.which & WSKBD_BELL_DOPITCH)
|
||||
pr_field(field_by_value(&dfbell.pitch), " -> ");
|
||||
if (dfbell.which & WSKBD_BELL_DOPERIOD)
|
||||
|
@ -199,7 +206,7 @@ keyboard_put_values(int fd)
|
|||
|
||||
if (field_by_value(&kbmap)->flags & FLG_SET) {
|
||||
if (ioctl(fd, WSKBDIO_SETMAP, &kbmap) < 0)
|
||||
err(1, "WSKBDIO_SETMAP");
|
||||
err(EXIT_FAILURE, "WSKBDIO_SETMAP");
|
||||
pr_field(field_by_value(&kbmap), " -> ");
|
||||
}
|
||||
|
||||
|
@ -210,7 +217,7 @@ keyboard_put_values(int fd)
|
|||
repeat.which |= WSKBD_KEYREPEAT_DODELN;
|
||||
if (repeat.which != 0 &&
|
||||
ioctl(fd, WSKBDIO_SETKEYREPEAT, &repeat) < 0)
|
||||
err(1, "WSKBDIO_SETKEYREPEAT");
|
||||
err(EXIT_FAILURE, "WSKBDIO_SETKEYREPEAT");
|
||||
if (repeat.which & WSKBD_KEYREPEAT_DODEL1)
|
||||
pr_field(field_by_value(&repeat.del1), " -> ");
|
||||
if (repeat.which & WSKBD_KEYREPEAT_DODELN)
|
||||
|
@ -223,7 +230,7 @@ keyboard_put_values(int fd)
|
|||
dfrepeat.which |= WSKBD_KEYREPEAT_DODELN;
|
||||
if (dfrepeat.which != 0 &&
|
||||
ioctl(fd, WSKBDIO_SETDEFAULTKEYREPEAT, &dfrepeat) < 0)
|
||||
err(1, "WSKBDIO_SETDEFAULTKEYREPEAT");
|
||||
err(EXIT_FAILURE, "WSKBDIO_SETDEFAULTKEYREPEAT");
|
||||
if (dfrepeat.which &WSKBD_KEYREPEAT_DODEL1)
|
||||
pr_field(field_by_value(&dfrepeat.del1), " -> ");
|
||||
if (dfrepeat.which & WSKBD_KEYREPEAT_DODELN)
|
||||
|
@ -231,19 +238,19 @@ keyboard_put_values(int fd)
|
|||
|
||||
if (field_by_value(&ledstate)->flags & FLG_SET) {
|
||||
if (ioctl(fd, WSKBDIO_SETLEDS, &ledstate) < 0)
|
||||
err(1, "WSKBDIO_SETLEDS");
|
||||
err(EXIT_FAILURE, "WSKBDIO_SETLEDS");
|
||||
pr_field(field_by_value(&ledstate), " -> ");
|
||||
}
|
||||
|
||||
if (field_by_value(&kbdencoding)->flags & FLG_SET) {
|
||||
if (ioctl(fd, WSKBDIO_SETENCODING, &kbdencoding) < 0)
|
||||
err(1, "WSKBDIO_SETENCODING");
|
||||
err(EXIT_FAILURE, "WSKBDIO_SETENCODING");
|
||||
pr_field(field_by_value(&kbdencoding), " -> ");
|
||||
}
|
||||
|
||||
if (field_by_value(&keyclick)->flags & FLG_SET) {
|
||||
if (ioctl(fd, WSKBDIO_SETKEYCLICK, &keyclick) < 0)
|
||||
err(1, "WSKBDIO_SETKEYCLICK");
|
||||
err(EXIT_FAILURE, "WSKBDIO_SETKEYCLICK");
|
||||
pr_field(field_by_value(&keyclick), " -> ");
|
||||
}
|
||||
|
||||
|
@ -264,9 +271,10 @@ keyboard_put_values(int fd)
|
|||
if (scroll.which != 0) {
|
||||
if (ioctl(fd, WSKBDIO_SETSCROLL, &scroll) == -1) {
|
||||
if (errno != ENODEV)
|
||||
err(1, "WSKBDIO_SETSCROLL");
|
||||
err(EXIT_FAILURE, "WSKBDIO_SETSCROLL");
|
||||
else {
|
||||
warnx("scrolling is not supported by this kernel");
|
||||
warnx("scrolling is not supported by this "
|
||||
"kernel");
|
||||
havescroll = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: keysym.c,v 1.6 2005/06/26 22:45:50 christos Exp $ */
|
||||
/* $NetBSD: keysym.c,v 1.7 2006/02/05 18:11:46 jmmv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -37,10 +37,12 @@
|
|||
*/
|
||||
|
||||
#include <dev/wscons/wsksymdef.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "keysym.h"
|
||||
#include "wsconsctl.h"
|
||||
|
||||
|
@ -52,7 +54,7 @@ static struct ksym ksym_tab_by_ksym[NUMKSYMS];
|
|||
/* copied from dev/wscons/wskbdutil.c ... */
|
||||
|
||||
static const u_char latin1_to_upper[256] = {
|
||||
/* 0 8 1 9 2 a 3 b 4 c 5 d 6 e 7 f */
|
||||
/* 0 8 1 9 2 a 3 b 4 c 5 d 6 e 7 f */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
||||
|
@ -97,27 +99,31 @@ static void sort_ksym_tab(void);
|
|||
static int
|
||||
qcmp_name(const void *a, const void *b)
|
||||
{
|
||||
return(strcmp(((const struct ksym *) a)->name,
|
||||
((const struct ksym *) b)->name));
|
||||
|
||||
return strcmp(((const struct ksym *) a)->name,
|
||||
((const struct ksym *) b)->name);
|
||||
}
|
||||
|
||||
static int
|
||||
qcmp_ksym(const void *a, const void *b)
|
||||
{
|
||||
return(((const struct ksym *) b)->value -
|
||||
((const struct ksym *) a)->value);
|
||||
|
||||
return ((const struct ksym *) b)->value -
|
||||
((const struct ksym *) a)->value;
|
||||
}
|
||||
|
||||
static int
|
||||
bcmp_name(const void *a, const void *b)
|
||||
{
|
||||
return(strcmp((const char *) a, ((const struct ksym *) b)->name));
|
||||
|
||||
return strcmp((const char *) a, ((const struct ksym *) b)->name);
|
||||
}
|
||||
|
||||
static int
|
||||
bcmp_ksym(const void *a, const void *b)
|
||||
{
|
||||
return(((const struct ksym *) b)->value - *((const int *) a));
|
||||
|
||||
return ((const struct ksym *) b)->value - *((const int *) a);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -147,10 +153,10 @@ ksym2name(int k)
|
|||
NUMKSYMS, sizeof(struct ksym), bcmp_ksym);
|
||||
|
||||
if (r != NULL)
|
||||
return(r->name);
|
||||
return r->name;
|
||||
else {
|
||||
snprintf(tmp, sizeof(tmp), "unknown_%d", k);
|
||||
return(tmp);
|
||||
(void)snprintf(tmp, sizeof(tmp), "unknown_%d", k);
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,22 +173,23 @@ name2ksym(char *n)
|
|||
NUMKSYMS, sizeof(struct ksym), bcmp_name);
|
||||
|
||||
if (r != NULL)
|
||||
return(r->value);
|
||||
return r->value;
|
||||
else if (sscanf(n, "unknown_%d", &res) == 1)
|
||||
return(res);
|
||||
return res;
|
||||
else
|
||||
return(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
keysym_t
|
||||
ksym_upcase(keysym_t ksym)
|
||||
{
|
||||
|
||||
if (ksym >= KS_f1 && ksym <= KS_f20)
|
||||
return(KS_F1 - KS_f1 + ksym);
|
||||
return KS_F1 - KS_f1 + ksym;
|
||||
|
||||
if (KS_GROUP(ksym) == KS_GROUP_Ascii && ksym <= 0xff &&
|
||||
latin1_to_upper[ksym] != 0x00)
|
||||
return(latin1_to_upper[ksym]);
|
||||
return latin1_to_upper[ksym];
|
||||
|
||||
return(ksym);
|
||||
return ksym;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: map_parse.y,v 1.5 2005/06/26 22:45:50 christos Exp $ */
|
||||
/* $NetBSD: map_parse.y,v 1.6 2006/02/05 18:11:46 jmmv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -55,9 +55,13 @@
|
|||
%{
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <dev/wscons/wsksymdef.h>
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "wsconsctl.h"
|
||||
|
||||
extern struct wskbd_map_data kbmap; /* from keyboard.c */
|
||||
|
@ -82,7 +86,7 @@ ksym_lookup(keysym_t ksym)
|
|||
return(i);
|
||||
}
|
||||
|
||||
errx(1, "keysym %s not found", ksym2name(ksym));
|
||||
errx(EXIT_FAILURE, "keysym %s not found", ksym2name(ksym));
|
||||
}
|
||||
|
||||
%}
|
||||
|
@ -139,7 +143,7 @@ keysym_expr : T_KEYSYM keysym_var "=" keysym_var = {
|
|||
|
||||
keycode_expr : T_KEYCODE T_NUMBER "=" = {
|
||||
if ($2 >= KS_NUMKEYCODES)
|
||||
errx(1, "%d: keycode too large", $2);
|
||||
errx(EXIT_FAILURE, "%d: keycode too large", $2);
|
||||
if ($2 >= newkbmap.maplen)
|
||||
newkbmap.maplen = $2 + 1;
|
||||
cur_mp = mapdata + $2;
|
||||
|
@ -199,5 +203,6 @@ keysym_var : T_KEYSYM_VAR = {
|
|||
void
|
||||
yyerror(const char *msg)
|
||||
{
|
||||
errx(1, "parse: %s", msg);
|
||||
|
||||
errx(EXIT_FAILURE, "parse: %s", msg);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: map_scan.l,v 1.2 2005/01/19 20:37:52 xtraeme Exp $ */
|
||||
/* $NetBSD: map_scan.l,v 1.3 2006/02/05 18:11:46 jmmv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -40,7 +40,10 @@
|
|||
|
||||
#include <dev/wscons/wsksymdef.h>
|
||||
#include <dev/wscons/wsksymvar.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "wsconsctl.h"
|
||||
#include "map_parse.h"
|
||||
|
||||
|
@ -49,6 +52,7 @@
|
|||
void
|
||||
map_scan_setinput(char *str)
|
||||
{
|
||||
|
||||
yy_scan_string(str);
|
||||
}
|
||||
|
||||
|
@ -77,7 +81,7 @@ keysym {
|
|||
|
||||
i = name2ksym(yytext);
|
||||
if (i == -1)
|
||||
errx(1, "%s: not a keysym", yytext);
|
||||
errx(EXIT_FAILURE, "%s: not a keysym", yytext);
|
||||
yylval.kval = i;
|
||||
if (KS_GROUP(i) == KS_GROUP_Command ||
|
||||
i == KS_Cmd || i == KS_Cmd1 || i == KS_Cmd2)
|
||||
|
@ -93,9 +97,11 @@ keysym {
|
|||
|
||||
. {
|
||||
if (yytext[0] >= ' ' && yytext[0] <= '~')
|
||||
errx(1, "%c: illegal character in input", yytext[0]);
|
||||
errx(EXIT_FAILURE, "%c: illegal character in input",
|
||||
yytext[0]);
|
||||
else
|
||||
errx(1, "%03o: illegal character in input", yytext[0] & 255);
|
||||
errx(EXIT_FAILURE, "%03o: illegal character in input",
|
||||
yytext[0] & 255);
|
||||
|
||||
/* To quiet the compiler */
|
||||
if (0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mouse.c,v 1.6 2006/02/05 17:45:06 jmmv Exp $ */
|
||||
/* $NetBSD: mouse.c,v 1.7 2006/02/05 18:11:46 jmmv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2006 The NetBSD Foundation, Inc.
|
||||
|
@ -62,13 +62,13 @@ struct field mouse_field_tab[] = {
|
|||
{ "samplerate", &samplerate, FMT_UINT, FLG_WRONLY },
|
||||
{ "type", &mstype, FMT_MSTYPE, FLG_RDONLY },
|
||||
{ "repeat.buttons", &repeat.wr_buttons,
|
||||
FMT_BITFIELD, FLG_MODIFY },
|
||||
FMT_BITFIELD, FLG_MODIFY },
|
||||
{ "repeat.delay.first", &repeat.wr_delay_first,
|
||||
FMT_UINT, FLG_MODIFY },
|
||||
FMT_UINT, FLG_MODIFY },
|
||||
{ "repeat.delay.decrement", &repeat.wr_delay_decrement,
|
||||
FMT_UINT, FLG_MODIFY },
|
||||
FMT_UINT, FLG_MODIFY },
|
||||
{ "repeat.delay.minimum", &repeat.wr_delay_minimum,
|
||||
FMT_UINT, FLG_MODIFY },
|
||||
FMT_UINT, FLG_MODIFY },
|
||||
};
|
||||
|
||||
int mouse_field_tab_len = sizeof(mouse_field_tab)/
|
||||
|
@ -77,9 +77,10 @@ int mouse_field_tab_len = sizeof(mouse_field_tab)/
|
|||
void
|
||||
mouse_get_values(int fd)
|
||||
{
|
||||
|
||||
if (field_by_value(&mstype)->flags & FLG_GET)
|
||||
if (ioctl(fd, WSMOUSEIO_GTYPE, &mstype) < 0)
|
||||
err(1, "WSMOUSEIO_GTYPE");
|
||||
err(EXIT_FAILURE, "WSMOUSEIO_GTYPE");
|
||||
|
||||
if (field_by_value(&repeat.wr_buttons)->flags & FLG_GET ||
|
||||
field_by_value(&repeat.wr_delay_first)->flags & FLG_GET ||
|
||||
|
@ -94,7 +95,7 @@ mouse_get_repeat(int fd)
|
|||
struct wsmouse_repeat tmp;
|
||||
|
||||
if (ioctl(fd, WSMOUSEIO_GETREPEAT, &tmp) == -1)
|
||||
err(1, "WSMOUSEIO_GETREPEAT");
|
||||
err(EXIT_FAILURE, "WSMOUSEIO_GETREPEAT");
|
||||
|
||||
if (field_by_value(&repeat.wr_buttons)->flags & FLG_GET)
|
||||
repeat.wr_buttons = tmp.wr_buttons;
|
||||
|
@ -114,14 +115,14 @@ mouse_put_values(int fd)
|
|||
if (field_by_value(&resolution)->flags & FLG_SET) {
|
||||
tmp = resolution;
|
||||
if (ioctl(fd, WSMOUSEIO_SRES, &tmp) < 0)
|
||||
err(1, "WSMOUSEIO_SRES");
|
||||
err(EXIT_FAILURE, "WSMOUSEIO_SRES");
|
||||
pr_field(field_by_value(&resolution), " -> ");
|
||||
}
|
||||
|
||||
if (field_by_value(&samplerate)->flags & FLG_SET) {
|
||||
tmp = samplerate;
|
||||
if (ioctl(fd, WSMOUSEIO_SRATE, &tmp) < 0)
|
||||
err(1, "WSMOUSEIO_SRATE");
|
||||
err(EXIT_FAILURE, "WSMOUSEIO_SRATE");
|
||||
pr_field(field_by_value(&samplerate), " -> ");
|
||||
}
|
||||
|
||||
|
@ -139,7 +140,7 @@ mouse_put_repeat(int fd)
|
|||
|
||||
/* Fetch current values into the temporary structure. */
|
||||
if (ioctl(fd, WSMOUSEIO_GETREPEAT, &tmp) == -1)
|
||||
err(1, "WSMOUSEIO_GETREPEAT");
|
||||
err(EXIT_FAILURE, "WSMOUSEIO_GETREPEAT");
|
||||
|
||||
/* Overwrite the desired values in the temporary structure. */
|
||||
if (field_by_value(&repeat.wr_buttons)->flags & FLG_SET)
|
||||
|
@ -153,7 +154,7 @@ mouse_put_repeat(int fd)
|
|||
|
||||
/* Set new values for repeating events. */
|
||||
if (ioctl(fd, WSMOUSEIO_SETREPEAT, &tmp) == -1)
|
||||
err(1, "WSMOUSEIO_SETREPEAT");
|
||||
err(EXIT_FAILURE, "WSMOUSEIO_SETREPEAT");
|
||||
|
||||
/* Now print what changed. */
|
||||
if (field_by_value(&repeat.wr_buttons)->flags & FLG_SET)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: util.c,v 1.24 2006/02/05 17:38:33 jmmv Exp $ */
|
||||
/* $NetBSD: util.c,v 1.25 2006/02/05 18:11:46 jmmv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2006 The NetBSD Foundation, Inc.
|
||||
|
@ -37,6 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wsksymdef.h>
|
||||
|
||||
|
@ -180,6 +181,7 @@ static void pr_bitfield(unsigned int);
|
|||
void
|
||||
field_setup(struct field *ftab, int len)
|
||||
{
|
||||
|
||||
field_tab = ftab;
|
||||
field_tab_len = len;
|
||||
}
|
||||
|
@ -191,9 +193,9 @@ field_by_name(char *name)
|
|||
|
||||
for (i = 0; i < field_tab_len; i++)
|
||||
if (strcmp(field_tab[i].name, name) == 0)
|
||||
return(field_tab + i);
|
||||
return field_tab + i;
|
||||
|
||||
errx(1, "%s: not found", name);
|
||||
errx(EXIT_FAILURE, "%s: not found", name);
|
||||
}
|
||||
|
||||
struct field *
|
||||
|
@ -203,9 +205,9 @@ field_by_value(void *addr)
|
|||
|
||||
for (i = 0; i < field_tab_len; i++)
|
||||
if (field_tab[i].valp == addr)
|
||||
return(field_tab + i);
|
||||
return field_tab + i;
|
||||
|
||||
errx(1, "internal error: field_by_value: not found");
|
||||
errx(EXIT_FAILURE, "internal error: field_by_value: not found");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -225,13 +227,13 @@ int2name(int val, int uflag, struct nameint *tab, int len)
|
|||
|
||||
for (i = 0; i < len; i++)
|
||||
if (tab[i].value == val)
|
||||
return(tab[i].name);
|
||||
return tab[i].name;
|
||||
|
||||
if (uflag) {
|
||||
snprintf(tmp, sizeof(tmp), "unknown_%d", val);
|
||||
return(tmp);
|
||||
(void)snprintf(tmp, sizeof(tmp), "unknown_%d", val);
|
||||
return tmp;
|
||||
} else
|
||||
return(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -241,88 +243,89 @@ name2int(char *val, struct nameint *tab, int len)
|
|||
|
||||
for (i = 0; i < len; i++)
|
||||
if (strcmp(tab[i].name, val) == 0)
|
||||
return(tab[i].value);
|
||||
return(-1);
|
||||
return tab[i].value;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
pr_field(struct field *f, const char *sep)
|
||||
{
|
||||
const char *p;
|
||||
u_int flags;
|
||||
unsigned int flags;
|
||||
int first, i, mask;
|
||||
|
||||
if (sep)
|
||||
printf("%s%s", f->name, sep);
|
||||
(void)printf("%s%s", f->name, sep);
|
||||
|
||||
switch (f->format) {
|
||||
case FMT_UINT:
|
||||
printf("%u", *((u_int *) f->valp));
|
||||
(void)printf("%u", *((unsigned int *) f->valp));
|
||||
break;
|
||||
case FMT_STRING:
|
||||
printf("\"%s\"", *((char **) f->valp));
|
||||
(void)printf("\"%s\"", *((char **) f->valp));
|
||||
break;
|
||||
case FMT_BITFIELD:
|
||||
pr_bitfield(*((unsigned int *) f->valp));
|
||||
break;
|
||||
case FMT_KBDTYPE:
|
||||
p = int2name(*((u_int *) f->valp), 1,
|
||||
kbtype_tab, TABLEN(kbtype_tab));
|
||||
printf("%s", p);
|
||||
p = int2name(*((unsigned int *) f->valp), 1,
|
||||
kbtype_tab, TABLEN(kbtype_tab));
|
||||
(void)printf("%s", p);
|
||||
break;
|
||||
case FMT_MSTYPE:
|
||||
p = int2name(*((u_int *) f->valp), 1,
|
||||
mstype_tab, TABLEN(mstype_tab));
|
||||
printf("%s", p);
|
||||
p = int2name(*((unsigned int *) f->valp), 1,
|
||||
mstype_tab, TABLEN(mstype_tab));
|
||||
(void)printf("%s", p);
|
||||
break;
|
||||
case FMT_DPYTYPE:
|
||||
p = int2name(*((u_int *) f->valp), 1,
|
||||
dpytype_tab, TABLEN(dpytype_tab));
|
||||
printf("%s", p);
|
||||
p = int2name(*((unsigned int *) f->valp), 1,
|
||||
dpytype_tab, TABLEN(dpytype_tab));
|
||||
(void)printf("%s", p);
|
||||
break;
|
||||
case FMT_KBDENC:
|
||||
p = int2name(KB_ENCODING(*((u_int *) f->valp)), 1,
|
||||
kbdenc_tab, TABLEN(kbdenc_tab));
|
||||
printf("%s", p);
|
||||
p = int2name(KB_ENCODING(*((unsigned int *) f->valp)), 1,
|
||||
kbdenc_tab, TABLEN(kbdenc_tab));
|
||||
(void)printf("%s", p);
|
||||
|
||||
flags = KB_VARIANT(*((u_int *) f->valp));
|
||||
flags = KB_VARIANT(*((unsigned int *) f->valp));
|
||||
for (i = 0; i < 32; i++) {
|
||||
if (!(flags & (1 << i)))
|
||||
continue;
|
||||
p = int2name(flags & (1 << i), 1,
|
||||
kbdvar_tab, TABLEN(kbdvar_tab));
|
||||
printf(".%s", p);
|
||||
kbdvar_tab, TABLEN(kbdvar_tab));
|
||||
(void)printf(".%s", p);
|
||||
}
|
||||
break;
|
||||
case FMT_KBMAP:
|
||||
print_kmap((struct wskbd_map_data *) f->valp);
|
||||
break;
|
||||
case FMT_COLOR:
|
||||
p = int2name(*((u_int *) f->valp), 1,
|
||||
color_tab, TABLEN(color_tab));
|
||||
printf("%s", p);
|
||||
p = int2name(*((unsigned int *) f->valp), 1,
|
||||
color_tab, TABLEN(color_tab));
|
||||
(void)printf("%s", p);
|
||||
break;
|
||||
case FMT_ATTRS:
|
||||
mask = 0x10;
|
||||
first = 1;
|
||||
while (mask > 0) {
|
||||
if (*((u_int *) f->valp) & mask) {
|
||||
p = int2name(*((u_int *) f->valp) & mask, 1,
|
||||
attr_tab, TABLEN(attr_tab));
|
||||
printf("%s%s", first ? "" : ",", p);
|
||||
if (*((unsigned int *) f->valp) & mask) {
|
||||
p = int2name(*((unsigned int *) f->valp) & mask,
|
||||
1, attr_tab, TABLEN(attr_tab));
|
||||
(void)printf("%s%s", first ? "" : ",", p);
|
||||
first = 0;
|
||||
}
|
||||
mask >>= 1;
|
||||
}
|
||||
if (first)
|
||||
printf("none");
|
||||
(void)printf("none");
|
||||
break;
|
||||
default:
|
||||
errx(1, "internal error: pr_field: no format %d", f->format);
|
||||
errx(EXIT_FAILURE, "internal error: pr_field: no format %d",
|
||||
f->format);
|
||||
break;
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
(void)printf("\n");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -330,13 +333,13 @@ pr_bitfield(unsigned int f)
|
|||
{
|
||||
|
||||
if (f == 0)
|
||||
printf("none");
|
||||
(void)printf("none");
|
||||
else {
|
||||
int i, first, mask;
|
||||
|
||||
for (i = 0, first = 1, mask = 1; i < sizeof(f) * 8; i++) {
|
||||
if (f & mask) {
|
||||
printf("%s%d", first ? "" : " ", i);
|
||||
(void)printf("%s%d", first ? "" : " ", i);
|
||||
first = 0;
|
||||
}
|
||||
mask = mask << 1;
|
||||
|
@ -348,22 +351,22 @@ void
|
|||
rd_field(struct field *f, char *val, int merge)
|
||||
{
|
||||
int i;
|
||||
u_int u;
|
||||
unsigned int u;
|
||||
char *p;
|
||||
struct wscons_keymap *mp;
|
||||
|
||||
switch (f->format) {
|
||||
case FMT_UINT:
|
||||
if (sscanf(val, "%u", &u) != 1)
|
||||
errx(1, "%s: not a number", val);
|
||||
errx(EXIT_FAILURE, "%s: not a number", val);
|
||||
if (merge)
|
||||
*((u_int *) f->valp) += u;
|
||||
*((unsigned int *) f->valp) += u;
|
||||
else
|
||||
*((u_int *) f->valp) = u;
|
||||
*((unsigned int *) f->valp) = u;
|
||||
break;
|
||||
case FMT_STRING:
|
||||
if ((*((char **) f->valp) = strdup(val)) == NULL)
|
||||
err(1, "strdup");
|
||||
err(EXIT_FAILURE, "strdup");
|
||||
break;
|
||||
case FMT_BITFIELD:
|
||||
*((unsigned int *) f->valp) = rd_bitfield(val);
|
||||
|
@ -375,8 +378,8 @@ rd_field(struct field *f, char *val, int merge)
|
|||
|
||||
i = name2int(val, kbdenc_tab, TABLEN(kbdenc_tab));
|
||||
if (i == -1)
|
||||
errx(1, "%s: not a valid encoding", val);
|
||||
*((u_int *) f->valp) = i;
|
||||
errx(EXIT_FAILURE, "%s: not a valid encoding", val);
|
||||
*((unsigned int *) f->valp) = i;
|
||||
|
||||
while (p) {
|
||||
val = p;
|
||||
|
@ -385,8 +388,9 @@ rd_field(struct field *f, char *val, int merge)
|
|||
*p++ = '\0';
|
||||
i = name2int(val, kbdvar_tab, TABLEN(kbdvar_tab));
|
||||
if (i == -1)
|
||||
errx(1, "%s: not a valid variant", val);
|
||||
*((u_int *) f->valp) |= i;
|
||||
errx(EXIT_FAILURE, "%s: not a valid variant",
|
||||
val);
|
||||
*((unsigned int *) f->valp) |= i;
|
||||
}
|
||||
break;
|
||||
case FMT_KBMAP:
|
||||
|
@ -409,13 +413,13 @@ rd_field(struct field *f, char *val, int merge)
|
|||
}
|
||||
kbmap.maplen = newkbmap.maplen;
|
||||
bcopy(newkbmap.map, kbmap.map,
|
||||
kbmap.maplen*sizeof(struct wscons_keymap));
|
||||
kbmap.maplen * sizeof(struct wscons_keymap));
|
||||
break;
|
||||
case FMT_COLOR:
|
||||
i = name2int(val, color_tab, TABLEN(color_tab));
|
||||
if (i == -1)
|
||||
errx(1, "%s: not a valid color", val);
|
||||
*((u_int *) f->valp) = i;
|
||||
errx(EXIT_FAILURE, "%s: not a valid color", val);
|
||||
*((unsigned int *) f->valp) = i;
|
||||
break;
|
||||
case FMT_ATTRS:
|
||||
p = val;
|
||||
|
@ -426,12 +430,14 @@ rd_field(struct field *f, char *val, int merge)
|
|||
*p++ = '\0';
|
||||
i = name2int(val, attr_tab, TABLEN(attr_tab));
|
||||
if (i == -1)
|
||||
errx(1, "%s: not a valid attribute", val);
|
||||
*((u_int *) f->valp) |= i;
|
||||
errx(EXIT_FAILURE, "%s: not a valid attribute",
|
||||
val);
|
||||
*((unsigned int *) f->valp) |= i;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
errx(1, "internal error: rd_field: no format %d", f->format);
|
||||
errx(EXIT_FAILURE, "internal error: rd_field: no format %d",
|
||||
f->format);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -451,11 +457,11 @@ rd_bitfield(const char *str)
|
|||
errno = 0;
|
||||
lval = strtol(ptr, &ep, 10);
|
||||
if (*ep != '\0' && *ep != ' ')
|
||||
errx(1, "%s: not a valid number list", str);
|
||||
errx(EXIT_FAILURE, "%s: not a valid number list", str);
|
||||
if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
|
||||
errx(1, "%s: not a valid number list", str);
|
||||
errx(EXIT_FAILURE, "%s: not a valid number list", str);
|
||||
if (lval >= sizeof(result) * 8)
|
||||
errx(1, "%ld: number out of range", lval);
|
||||
errx(EXIT_FAILURE, "%ld: number out of range", lval);
|
||||
result |= (1 << lval);
|
||||
|
||||
ptr = ep;
|
||||
|
@ -481,19 +487,19 @@ print_kmap(struct wskbd_map_data *map)
|
|||
mp->group2[0] == KS_voidSymbol &&
|
||||
mp->group2[1] == KS_voidSymbol)
|
||||
continue;
|
||||
printf("\n");
|
||||
printf("keycode %u =", i);
|
||||
(void)printf("\n");
|
||||
(void)printf("keycode %u =", i);
|
||||
if (mp->command != KS_voidSymbol)
|
||||
printf(" %s", ksym2name(mp->command));
|
||||
printf(" %s", ksym2name(mp->group1[0]));
|
||||
(void)printf(" %s", ksym2name(mp->command));
|
||||
(void)printf(" %s", ksym2name(mp->group1[0]));
|
||||
if (mp->group1[0] != mp->group1[1] ||
|
||||
mp->group1[0] != mp->group2[0] ||
|
||||
mp->group1[0] != mp->group2[1]) {
|
||||
printf(" %s", ksym2name(mp->group1[1]));
|
||||
(void)printf(" %s", ksym2name(mp->group1[1]));
|
||||
if (mp->group1[0] != mp->group2[0] ||
|
||||
mp->group1[1] != mp->group2[1]) {
|
||||
printf(" %s", ksym2name(mp->group2[0]));
|
||||
printf(" %s", ksym2name(mp->group2[1]));
|
||||
(void)printf(" %s", ksym2name(mp->group2[0]));
|
||||
(void)printf(" %s", ksym2name(mp->group2[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: wsconsctl.c,v 1.13 2005/06/26 22:45:50 christos Exp $ */
|
||||
/* $NetBSD: wsconsctl.c,v 1.14 2006/02/05 18:11:46 jmmv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -36,12 +36,13 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "wsconsctl.h"
|
||||
|
||||
#define PATH_KEYBOARD "/dev/wskbd"
|
||||
|
@ -63,17 +64,16 @@ usage(const char *msg)
|
|||
const char *progname = getprogname();
|
||||
|
||||
if (msg != NULL)
|
||||
fprintf(stderr, "%s: %s\n\n", progname, msg);
|
||||
(void)fprintf(stderr, "%s: %s\n\n", progname, msg);
|
||||
|
||||
fprintf(stderr, "Usage: %s [-kmd] [-f file] [-n] name ...\n",
|
||||
progname);
|
||||
fprintf(stderr, " -or- %s [-kmd] [-f file] [-n] -w name=value ...\n",
|
||||
progname);
|
||||
fprintf(stderr, " -or- %s [-kmd] [-f file] [-n] -w name+=value ...\n",
|
||||
progname);
|
||||
fprintf(stderr, " -or- %s [-kmd] [-f file] [-n] -a\n", progname);
|
||||
(void)fprintf(stderr,
|
||||
"Usage: %s [-kmd] [-f file] [-n] name ...\n"
|
||||
" -or- %s [-kmd] [-f file] [-n] -w name=value ...\n"
|
||||
" -or- %s [-kmd] [-f file] [-n] -w name+=value ...\n"
|
||||
" -or- %s [-kmd] [-f file] [-n] -a\n",
|
||||
progname, progname, progname, progname);
|
||||
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -170,7 +170,7 @@ main(int argc, char **argv)
|
|||
if (fd < 0)
|
||||
fd = open(file, O_RDONLY);
|
||||
if (fd < 0)
|
||||
err(1, "%s", file);
|
||||
err(EXIT_FAILURE, "%s", file);
|
||||
|
||||
if (aflag != 0) {
|
||||
for (i = 0; i < field_tab_len; i++)
|
||||
|
@ -180,7 +180,7 @@ main(int argc, char **argv)
|
|||
for (i = 0; i < field_tab_len; i++)
|
||||
if (field_tab[i].flags & FLG_NOAUTO)
|
||||
warnx("Use explicit arg to view %s.",
|
||||
field_tab[i].name);
|
||||
field_tab[i].name);
|
||||
else if (field_tab[i].flags & FLG_GET &&
|
||||
!(field_tab[i].flags & FLG_DISABLED))
|
||||
pr_field(field_tab + i, sep);
|
||||
|
@ -189,7 +189,7 @@ main(int argc, char **argv)
|
|||
for (i = 0; i < argc; i++) {
|
||||
p = strchr(argv[i], '=');
|
||||
if (p == NULL)
|
||||
errx(1, "'=' not found");
|
||||
errx(EXIT_FAILURE, "'=' not found");
|
||||
if (p > argv[i] && *(p - 1) == '+') {
|
||||
*(p - 1) = '\0';
|
||||
do_merge = 1;
|
||||
|
@ -198,11 +198,13 @@ main(int argc, char **argv)
|
|||
*p++ = '\0';
|
||||
f = field_by_name(argv[i]);
|
||||
if ((f->flags & FLG_RDONLY) != 0)
|
||||
errx(1, "%s: read only", argv[i]);
|
||||
errx(EXIT_FAILURE, "%s: read only",
|
||||
argv[i]);
|
||||
if (do_merge) {
|
||||
if ((f->flags & FLG_MODIFY) == 0)
|
||||
errx(1, "%s: can only be set",
|
||||
argv[i]);
|
||||
errx(EXIT_FAILURE,
|
||||
"%s: can only be set",
|
||||
argv[i]);
|
||||
f->flags |= FLG_GET;
|
||||
(*getval)(fd);
|
||||
f->flags &= ~FLG_GET;
|
||||
|
@ -216,14 +218,16 @@ main(int argc, char **argv)
|
|||
for (i = 0; i < argc; i++) {
|
||||
f = field_by_name(argv[i]);
|
||||
if ((f->flags & FLG_WRONLY) != 0)
|
||||
errx(1, "%s: write only", argv[i]);
|
||||
errx(EXIT_FAILURE, "%s: write only",
|
||||
argv[i]);
|
||||
f->flags |= FLG_GET;
|
||||
}
|
||||
(*getval)(fd);
|
||||
for (i = 0; i < field_tab_len; i++) {
|
||||
if (field_tab[i].flags & FLG_DISABLED)
|
||||
errx(1, "%s: no kernel support",
|
||||
field_tab[i].name);
|
||||
errx(EXIT_FAILURE,
|
||||
"%s: no kernel support",
|
||||
field_tab[i].name);
|
||||
if (field_tab[i].flags & FLG_GET)
|
||||
pr_field(field_tab + i, sep);
|
||||
}
|
||||
|
@ -234,5 +238,6 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
close(fd);
|
||||
exit(0);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue