diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-05-08 22:31:10 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-05-08 22:31:10 +0000 |
commit | c212fa865e2055967a47ac71f46ad1216676cab1 (patch) | |
tree | fd3a61d72f4097fb8f806f1ebc458f8e527d53c7 | |
parent | fda42b5add85625d515849886a87228d10924814 (diff) |
add more display variables (for screen burner).
implement boolean type for variables.
-rw-r--r-- | sbin/wsconsctl/display.c | 90 | ||||
-rw-r--r-- | sbin/wsconsctl/util.c | 11 | ||||
-rw-r--r-- | sbin/wsconsctl/wsconsctl.h | 3 |
3 files changed, 100 insertions, 4 deletions
diff --git a/sbin/wsconsctl/display.c b/sbin/wsconsctl/display.c index dda351e7d52..656ec69300a 100644 --- a/sbin/wsconsctl/display.c +++ b/sbin/wsconsctl/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.1 2000/07/01 23:52:45 mickey Exp $ */ +/* $OpenBSD: display.c,v 1.2 2001/05/08 22:31:09 mickey Exp $ */ /* $NetBSD: display.c,v 1.1 1998/12/28 14:01:16 hannken Exp $ */ /*- @@ -43,10 +43,17 @@ #include <err.h> #include "wsconsctl.h" -static int dpytype; +int dpytype; +int burnon, burnoff, vblank, kbdact, msact, outact; struct field display_field_tab[] = { { "type", &dpytype, FMT_DPYTYPE, FLG_RDONLY }, + { "screen_on", &burnon, FMT_UINT, FLG_MODIFY }, + { "screen_off", &burnoff, FMT_UINT, FLG_MODIFY }, + { "vblank", &vblank, FMT_BOOL, FLG_MODIFY }, + { "kbdact", &kbdact, FMT_BOOL, FLG_MODIFY }, + { "msact", &msact, FMT_BOOL, FLG_MODIFY }, + { "outact", &outact, FMT_BOOL, FLG_MODIFY }, }; int display_field_tab_len = sizeof(display_field_tab)/ @@ -59,10 +66,89 @@ display_get_values(fd) if (field_by_value(&dpytype)->flags & FLG_GET) if (ioctl(fd, WSDISPLAYIO_GTYPE, &dpytype) < 0) err(1, "WSDISPLAYIO_GTYPE"); + if (field_by_value(&burnon)->flags & FLG_GET || + field_by_value(&burnoff)->flags & FLG_GET || + field_by_value(&vblank)->flags & FLG_GET || + field_by_value(&kbdact)->flags & FLG_GET || + field_by_value(&msact )->flags & FLG_GET || + field_by_value(&outact)->flags & FLG_GET) { + + struct wsdisplay_burner burners; + + if (ioctl(fd, WSDISPLAYIO_GBURNER, &burners) < 0) + err(1, "WSDISPLAYIO_GBURNER"); + + if (field_by_value(&burnon)->flags & FLG_GET) + burnon = burners.on; + + if (field_by_value(&burnoff)->flags & FLG_GET) + burnoff = burners.off; + + if (field_by_value(&vblank)->flags & FLG_GET) + vblank = burners.flags & WSDISPLAY_BURN_VBLANK; + + if (field_by_value(&kbdact)->flags & FLG_GET) + kbdact = burners.flags & WSDISPLAY_BURN_KBD; + + if (field_by_value(&msact )->flags & FLG_GET) + msact = burners.flags & WSDISPLAY_BURN_MOUSE; + + if (field_by_value(&outact)->flags & FLG_GET) + outact = burners.flags & WSDISPLAY_BURN_OUTPUT; + } } void display_put_values(fd) int fd; { + if (field_by_value(&burnon)->flags & FLG_SET || + field_by_value(&burnoff)->flags & FLG_SET || + field_by_value(&vblank)->flags & FLG_SET || + field_by_value(&kbdact)->flags & FLG_SET || + field_by_value(&msact )->flags & FLG_SET || + field_by_value(&outact)->flags & FLG_SET) { + + struct wsdisplay_burner burners; + + if (ioctl(fd, WSDISPLAYIO_GBURNER, &burners) < 0) + err(1, "WSDISPLAYIO_GBURNER"); + + if (field_by_value(&burnon)->flags & FLG_SET) + burners.on = burnon; + + if (field_by_value(&burnoff)->flags & FLG_SET) + burners.off = burnoff; + + if (field_by_value(&vblank)->flags & FLG_SET) { + if (vblank) + burners.flags |= WSDISPLAY_BURN_VBLANK; + else + burners.flags &= ~WSDISPLAY_BURN_VBLANK; + } + + if (field_by_value(&kbdact)->flags & FLG_SET) { + if (kbdact) + burners.flags |= WSDISPLAY_BURN_KBD; + else + burners.flags &= ~WSDISPLAY_BURN_KBD; + } + + if (field_by_value(&msact )->flags & FLG_SET) { + if (msact) + burners.flags |= WSDISPLAY_BURN_MOUSE; + else + burners.flags &= ~WSDISPLAY_BURN_MOUSE; + } + + if (field_by_value(&outact)->flags & FLG_SET) { + if (outact) + burners.flags |= WSDISPLAY_BURN_OUTPUT; + else + burners.flags &= ~WSDISPLAY_BURN_OUTPUT; + } + + if (ioctl(fd, WSDISPLAYIO_SBURNER, &burners) < 0) + err(1, "WSDISPLAYIO_SBURNER"); + } } diff --git a/sbin/wsconsctl/util.c b/sbin/wsconsctl/util.c index 83d3e95b21a..ea0435efae2 100644 --- a/sbin/wsconsctl/util.c +++ b/sbin/wsconsctl/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.3 2001/03/03 08:53:46 maja Exp $ */ +/* $OpenBSD: util.c,v 1.4 2001/05/08 22:31:09 mickey Exp $ */ /* $NetBSD: util.c,v 1.8 2000/03/14 08:11:53 sato Exp $ */ /*- @@ -195,6 +195,9 @@ pr_field(f, sep) case FMT_UINT: printf("%u", *((u_int *) f->valp)); break; + case FMT_BOOL: + printf("%s", *((u_int *) f->valp)? "on" : "off"); + break; case FMT_KBDTYPE: p = int2name(*((u_int *) f->valp), 1, kbtype_tab, TABLEN(kbtype_tab)); @@ -255,6 +258,12 @@ rd_field(f, val, merge) else *((u_int *) f->valp) = u; break; + case FMT_BOOL: + if (*val != 'o' || (val[1] != 'n' && + (val[1] != 'f' || val[2] != 'f'))) + errx(1, "%s: invalid value (on/off)", val); + *((u_int *) f->valp) = val[1] == 'n'? 1 : 0; + break; case FMT_KBDENC: p = strchr(val, '.'); if (p != NULL) diff --git a/sbin/wsconsctl/wsconsctl.h b/sbin/wsconsctl/wsconsctl.h index 092f60d0ce5..fc8568b7995 100644 --- a/sbin/wsconsctl/wsconsctl.h +++ b/sbin/wsconsctl/wsconsctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsconsctl.h,v 1.1 2000/07/01 23:52:45 mickey Exp $ */ +/* $OpenBSD: wsconsctl.h,v 1.2 2001/05/08 22:31:09 mickey Exp $ */ /* $NetBSD: wsconsctl.h 1.1 1998/12/28 14:01:17 hannken Exp $ */ /*- @@ -43,6 +43,7 @@ struct field { char *name; void *valp; #define FMT_UINT 1 /* unsigned integer */ +#define FMT_BOOL 2 /* boolean on/off */ #define FMT_KBDTYPE 101 /* keyboard type */ #define FMT_MSTYPE 102 /* mouse type */ #define FMT_DPYTYPE 103 /* display type */ |