Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin Add a simple program for listing, adding, and remov...
details: https://anonhg.NetBSD.org/src/rev/72f899799197
branches: trunk
changeset: 516025:72f899799197
user: augustss <augustss%NetBSD.org@localhost>
date: Sat Oct 13 20:05:42 2001 +0000
description:
Add a simple program for listing, adding, and removing wsmux devices.
It's not a much used utility, but when you need it it's a pain to
be without.
diffstat:
usr.sbin/Makefile | 4 +-
usr.sbin/wsmuxctl/Makefile | 7 +
usr.sbin/wsmuxctl/wsmuxctl.8 | 42 +++++++++++
usr.sbin/wsmuxctl/wsmuxctl.c | 157 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 208 insertions(+), 2 deletions(-)
diffs (236 lines):
diff -r c42c63b6b0ce -r 72f899799197 usr.sbin/Makefile
--- a/usr.sbin/Makefile Sat Oct 13 20:03:38 2001 +0000
+++ b/usr.sbin/Makefile Sat Oct 13 20:05:42 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.160 2001/09/13 23:51:39 thorpej Exp $
+# $NetBSD: Makefile,v 1.161 2001/10/13 20:05:42 augustss Exp $
# from: @(#)Makefile 5.20 (Berkeley) 6/12/93
.include <bsd.own.mk>
@@ -18,7 +18,7 @@
sliplogin slstats spray sup sushi syslogd tadpolectl tcpdchk \
tcpdmatch tcpdump timed traceroute trpt trsp unlink \
usbdevs user videomode vipw vnconfig wiconfig wsconscfg \
- wsfontload ypbind yppoll ypserv ypset zdump zic
+ wsfontload wsmuxctl ypbind yppoll ypserv ypset zdump zic
# IPv6
SUBDIR+=faithd ifmcstat mld6query ndp \
diff -r c42c63b6b0ce -r 72f899799197 usr.sbin/wsmuxctl/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/wsmuxctl/Makefile Sat Oct 13 20:05:42 2001 +0000
@@ -0,0 +1,7 @@
+# $NetBSD: Makefile,v 1.1 2001/10/13 20:05:43 augustss Exp $
+
+PROG= wsmuxctl
+MAN= wsmuxctl.8
+SRCS= wsmuxctl.c
+
+.include <bsd.prog.mk>
diff -r c42c63b6b0ce -r 72f899799197 usr.sbin/wsmuxctl/wsmuxctl.8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/wsmuxctl/wsmuxctl.8 Sat Oct 13 20:05:42 2001 +0000
@@ -0,0 +1,42 @@
+.\" $NetBSD: wsmuxctl.8,v 1.1 2001/10/13 20:05:43 augustss Exp $
+.\"
+.Dd October 13, 2001
+.Os
+.Dt WMUXCTL 8
+.Sh NAME
+.Nm wsmuxctl
+.Nd configure wsmuxes
+.Sh SYNOPSIS
+.Nm ""
+.Op Fl a Ar dev
+.Fl f Ar ctldev
+.Op Fl l
+.Op Fl r Ar dev
+.Sh DESCRIPTION
+The
+.Nm
+allows to adding and removing devices to a
+.Xr wsmux 4 .
+.Pp
+Added and removed devices are specified by a name, not a path name.
+Simply use
+.Em wsmouseN ,
+.Em wskbdN ,
+or
+.Em wsmuxN
+where N is the number of the device.
+.Pp
+The options are:
+.Bl -tag -width xxxxxxxxx
+.It Fl a Ar dev
+Add the specified device to the mux.
+.It Fl f Ar ctldev
+Specify the control device of wsmux to operate on.
+.It Fl l
+List all devices connected to a mux.
+.It Fl r Ar dev
+Remove the specified device from the mux.
+.El
+.Pp
+.Sh SEE ALSO
+.Xr wsmux 4
diff -r c42c63b6b0ce -r 72f899799197 usr.sbin/wsmuxctl/wsmuxctl.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/wsmuxctl/wsmuxctl.c Sat Oct 13 20:05:42 2001 +0000
@@ -0,0 +1,157 @@
+/* $NetBSD: wsmuxctl.c,v 1.1 2001/10/13 20:05:43 augustss Exp $ */
+
+/*
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Author: Lennart Augustsson <augustss%carlstedt.se@localhost>
+ * Carlstedt Research & Technology
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <err.h>
+#include <errno.h>
+
+#include <dev/wscons/wsconsio.h>
+
+static void usage(void);
+int main(int, char**);
+
+const char *devnames[] = { "?", "wsmouse", "wskbd", "wsmux" };
+
+static void
+usage(void)
+{
+
+ fprintf(stderr, "Usage: %s [-a dev] -f wsmux [-l] [-r dev]\n",
+ getprogname());
+ exit(1);
+}
+
+static void
+parsedev(const char *dev, struct wsmux_device *mdev)
+{
+ if (sscanf(dev, "wsmouse%d", &mdev->idx) == 1) {
+ mdev->type = WSMUX_MOUSE;
+ return;
+ }
+ if (sscanf(dev, "wskbd%d", &mdev->idx) == 1) {
+ mdev->type = WSMUX_KBD;
+ return;
+ }
+ if (sscanf(dev, "wsmux%d", &mdev->idx) == 1) {
+ mdev->type = WSMUX_MUX;
+ return;
+ }
+ errx(1, "bad device: `%s', use wsmouse, wskdb, or wsmux\n", dev);
+}
+
+int
+main(int argc, char **argv)
+{
+ char *wsdev, *dev;
+ int wsfd, list, c, i, add, rem;
+ struct wsmux_device_list devs;
+ struct wsmux_device mdev;
+
+ wsdev = NULL;
+ dev = NULL;
+ add = 0;
+ rem = 0;
+ list = 0;
+
+ while ((c = getopt(argc, argv, "a:f:lr:")) != -1) {
+ switch (c) {
+ case 'a':
+ if (dev)
+ usage();
+ dev = optarg;
+ add++;
+ break;
+ case 'r':
+ if (dev)
+ usage();
+ dev = optarg;
+ rem++;
+ break;
+ case 'f':
+ wsdev = optarg;
+ break;
+ case 'l':
+ list++;
+ break;
+ case '?':
+ default:
+ usage();
+ break;
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (wsdev == NULL)
+ usage();
+
+ wsfd = open(wsdev, O_WRONLY, 0);
+ if (wsfd < 0)
+ err(2, "%s", wsdev);
+
+ if (list) {
+ if (add || rem)
+ usage();
+ if (ioctl(wsfd, WSMUX_LIST_DEVICES, &devs) < 0)
+ err(1, "WSMUX_LIST_DEVICES");
+ for (i = 0; i < devs.ndevices; i++)
+ printf("%s%d\n", devnames[devs.devices[i].type],
+ devs.devices[i].idx);
+ exit(0);
+ }
+
+ if (add) {
+ parsedev(dev, &mdev);
+ if (ioctl(wsfd, WSMUX_ADD_DEVICE, &mdev) < 0)
+ err(1, "WSMUX_ADD_DEVICE");
+ }
+
+ if (rem) {
+ parsedev(dev, &mdev);
+ if (ioctl(wsfd, WSMUX_REMOVE_DEVICE, &mdev) < 0)
+ err(1, "WSMUX_REMOVE_DEVICE");
+ }
+
+ close(wsfd);
+ return (0);
+}
Home |
Main Index |
Thread Index |
Old Index