Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-2-0]: src/sbin/wsconsctl Pull up revision 1.4 (requested by recht...
details: https://anonhg.NetBSD.org/src/rev/8c308ab5da5e
branches: netbsd-2-0
changeset: 561318:8c308ab5da5e
user: tron <tron%NetBSD.org@localhost>
date: Mon Jun 07 09:59:09 2004 +0000
description:
Pull up revision 1.4 (requested by recht in ticket #451):
If scrolling support is not compiled in the kernel, fail gracefully.
diffstat:
sbin/wsconsctl/display.c | 58 +++++++++++++++++++++++++++++++++--------------
1 files changed, 40 insertions(+), 18 deletions(-)
diffs (105 lines):
diff -r 6fa87cd15b80 -r 8c308ab5da5e sbin/wsconsctl/display.c
--- a/sbin/wsconsctl/display.c Mon Jun 07 09:57:37 2004 +0000
+++ b/sbin/wsconsctl/display.c Mon Jun 07 09:59:09 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: display.c,v 1.2.4.1 2004/06/07 09:44:07 tron Exp $ */
+/* $NetBSD: display.c,v 1.2.4.2 2004/06/07 09:59:09 tron Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -37,15 +37,21 @@
*/
#include <sys/ioctl.h>
+#include <sys/time.h>
+
#include <stdio.h>
-#include <sys/time.h>
+#include <string.h>
+#include <errno.h>
+#include <err.h>
+
#include <dev/wscons/wsconsio.h>
-#include <err.h>
+
#include "wsconsctl.h"
static int dpytype;
static struct wsdisplay_usefontdata font;
static struct wsdisplay_scroll_data scroll_l;
+static int havescroll = 1;
struct field display_field_tab[] = {
{ "type", &dpytype, FMT_DPYTYPE, FLG_RDONLY },
@@ -57,6 +63,19 @@
int display_field_tab_len = sizeof(display_field_tab)/
sizeof(display_field_tab[0]);
+static int
+init_values(void)
+{
+ scroll_l.which = 0;
+
+ if (field_by_value(&scroll_l.fastlines)->flags & FLG_GET)
+ scroll_l.which |= WSDISPLAY_SCROLL_DOFASTLINES;
+ if (field_by_value(&scroll_l.slowlines)->flags & FLG_GET)
+ scroll_l.which |= WSDISPLAY_SCROLL_DOSLOWLINES;
+
+ return scroll_l.which;
+
+}
void
display_get_values(fd)
int fd;
@@ -65,14 +84,15 @@
if (ioctl(fd, WSDISPLAYIO_GTYPE, &dpytype) < 0)
err(1, "WSDISPLAYIO_GTYPE");
- scroll_l.which = 0;
- if (field_by_value(&scroll_l.fastlines)->flags & FLG_GET)
- scroll_l.which |= WSDISPLAY_SCROLL_DOFASTLINES;
- if (field_by_value(&scroll_l.slowlines)->flags & FLG_GET)
- scroll_l.which |= WSDISPLAY_SCROLL_DOSLOWLINES;
- if (scroll_l.which != 0 &&
- ioctl(fd, WSDISPLAYIO_DGSCROLL, &scroll_l) < 0)
+ if (init_values() == 0 || havescroll == 0)
+ return;
+
+ if (ioctl(fd, WSDISPLAYIO_DGSCROLL, &scroll_l) < 0) {
+ if (errno != ENODEV)
err(1, "WSDISPLAYIO_GSCROLL");
+ else
+ havescroll = 0;
+ }
}
void
@@ -85,18 +105,20 @@
pr_field(field_by_value(&font.name), " -> ");
}
- scroll_l.which = 0;
- if (field_by_value(&scroll_l.fastlines)->flags & FLG_SET)
- scroll_l.which |= WSDISPLAY_SCROLL_DOFASTLINES;
- if (field_by_value(&scroll_l.slowlines)->flags & FLG_SET)
- scroll_l.which |= WSDISPLAY_SCROLL_DOSLOWLINES;
+ if (init_values() == 0 || havescroll == 0)
+ return;
if (scroll_l.which & WSDISPLAY_SCROLL_DOFASTLINES)
pr_field(field_by_value(&scroll_l.fastlines), " -> ");
if (scroll_l.which & WSDISPLAY_SCROLL_DOSLOWLINES)
pr_field(field_by_value(&scroll_l.slowlines), " -> ");
- if (scroll_l.which != 0 &&
- ioctl(fd, WSDISPLAYIO_DSSCROLL, &scroll_l) < 0)
- err (1, "WSDISPLAYIO_SSCROLL");
+ if (ioctl(fd, WSDISPLAYIO_DSSCROLL, &scroll_l) < 0) {
+ if (errno != ENODEV)
+ err (1, "WSDISPLAYIO_DSSCROLL");
+ else {
+ warnx("scrolling is not supported by this kernel");
+ havescroll = 0;
+ }
+ }
}
Home |
Main Index |
Thread Index |
Old Index