diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-18 08:53:40 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-18 08:53:40 +0000 |
commit | d6583bb2a13f329cf0332ef2570eb8bb8fc0e39c (patch) | |
tree | ece253b876159b39c620e62b6c9b1174642e070e /usr.sbin/iteconfig |
initial import of NetBSD tree
Diffstat (limited to 'usr.sbin/iteconfig')
-rw-r--r-- | usr.sbin/iteconfig/Makefile | 8 | ||||
-rw-r--r-- | usr.sbin/iteconfig/iteconfig.c | 286 | ||||
-rw-r--r-- | usr.sbin/iteconfig/iteconfig_amiga.8 | 160 | ||||
-rw-r--r-- | usr.sbin/iteconfig/iteconfig_atari.8 | 160 | ||||
-rw-r--r-- | usr.sbin/iteconfig/pathnames.h | 35 |
5 files changed, 649 insertions, 0 deletions
diff --git a/usr.sbin/iteconfig/Makefile b/usr.sbin/iteconfig/Makefile new file mode 100644 index 00000000000..51e194c90d9 --- /dev/null +++ b/usr.sbin/iteconfig/Makefile @@ -0,0 +1,8 @@ +# $NetBSD: Makefile,v 1.3 1995/05/12 21:04:26 leo Exp $ + +PROG=iteconfig +MAN= iteconfig_${MACHINE}.8 +MLINKS= iteconfig_${MACHINE}.8 iteconfig.8 +CFLAGS+=-I${.CURDIR}/../../sys/arch -D${MACHINE} + +.include <bsd.prog.mk> diff --git a/usr.sbin/iteconfig/iteconfig.c b/usr.sbin/iteconfig/iteconfig.c new file mode 100644 index 00000000000..1d5238e44ed --- /dev/null +++ b/usr.sbin/iteconfig/iteconfig.c @@ -0,0 +1,286 @@ +/* $NetBSD: iteconfig.c,v 1.4 1995/05/12 21:04:29 leo Exp $ */ +/* + * Copyright (c) 1994 Christian E. Hopps + * All rights reserved. + * + * 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 Christian E. Hopps + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <sys/types.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include <sys/queue.h> + +#if !defined(amiga) && !defined(atari) +#error "This source is not suitable for this architecture!" +#endif + +#if defined(amiga) +#include <amiga/dev/grfabs_reg.h> +#include <amiga/dev/viewioctl.h> +#include <amiga/dev/iteioctl.h> +#endif /* defined(amiga) */ + +#if defined(atari) +#include <atari/dev/grfabs_reg.h> +#include <atari/dev/viewioctl.h> +#include <atari/dev/iteioctl.h> +#endif /* defined(atari) */ + +#include <err.h> +#include <errno.h> +#include <fcntl.h> +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <termios.h> +#include <unistd.h> + +#include "pathnames.h" + +void printcmap __P((colormap_t *, int)); +void usage __P((void)); +void xioctl __P((int, int, void *)); +colormap_t *xgetcmap __P((int, int)); +long xstrtol __P((char *)); +int initialize __P((char *, struct itewinsize *, struct itebell *, + struct itewinsize *, struct itebell *)); + +int +main(argc, argv) + int argc; + char **argv; +{ + struct itewinsize is, newis; + struct itebell ib, newib; + struct winsize ws; + colormap_t *cm; + char *file = _PATH_CONSOLE; + int ch, fd, i, iflag, max_colors, did_reset; + long val; + + iflag = 0; + did_reset = 0; + + fd = initialize(_PATH_CONSOLE, &is, &ib, &newis, &newib); + + while ((ch = getopt(argc, argv, "D:H:P:T:V:W:X:Y:d:f:h:ip:t:v:w:x:y:")) + != EOF) { + switch (ch) { + case 'D': /* undocumented backward compat */ + case 'd': + newis.depth = xstrtol(optarg); + break; + case 'f': + if (did_reset) + break; + if (fd != -1) + close(fd); + file = optarg; + fd = initialize(optarg, &is, &ib, &newis, &newib); + did_reset = optreset = optind = 1; + break; + case 'H': /* undocumented backward compat */ + case 'h': + newis.height = xstrtol(optarg); + break; + case 'i': + iflag = 1; + break; + case 'p': + newib.pitch = xstrtol(optarg); + break; + case 't': + newib.msec = xstrtol(optarg); + break; + case 'V': /* undocumented backward compat */ + case 'v': + newib.volume = xstrtol(optarg); + break; + case 'W': /* undocumented backward compat */ + case 'w': + newis.width = xstrtol(optarg); + break; + case 'X': /* undocumented backward compat */ + case 'x': + newis.x = xstrtol(optarg); + break; + case 'Y': /* undocumented backward compat */ + case 'y': + newis.y = xstrtol(optarg); + break; + case '?': + default: + usage(); + /* NOTREACHED */ + } + } + argc -= optind; + argv += optind; + if(fd == -1) + err(1, "open \"%s\"", file); + + if (memcmp(&newis, &is, sizeof(is))) { + xioctl(fd, ITEIOCSWINSZ, &newis); + xioctl(fd, ITEIOCGWINSZ, &is); + } + if (memcmp(&newib, &ib, sizeof(ib))) { + xioctl(fd, ITEIOCSBELL, &newib); + xioctl(fd, ITEIOCGBELL, &ib); + } + + /* + * get, set and get colors again + */ + i = 0; + max_colors = 1 << is.depth; + cm = xgetcmap(fd, max_colors); + while (argc--) { + val = xstrtol(*argv++); + if (i >= max_colors) { + warnx("warning: too many colors"); + break; + } + cm->entry[i] = val; + i++; + } + xioctl(fd, VIOCSCMAP, cm); + free(cm); + cm = xgetcmap(fd, max_colors); + + /* do tty stuff to get it to register the changes. */ + xioctl(fd, TIOCGWINSZ, &ws); + + if (iflag) { + printf("tty size: rows %d cols %d\n", ws.ws_row, ws.ws_col); + printf("ite size: w: %d h: %d d: %d [x: %d y: %d]\n", + is.width, is.height, is.depth, is.x, is.y); + printf("ite bell: vol: %d millisec: %d pitch: %d\n", + ib.volume, ib.msec, ib.pitch); + printcmap(cm, ws.ws_col); + } + close(fd); + exit(0); +} + +void +xioctl(fd, cmd, addr) + int fd, cmd; + void *addr; +{ + if (ioctl(fd, cmd, addr) == -1) + err(1, "ioctl"); +} + +long +xstrtol(s) + char *s; +{ + long rv; + + rv = strtol(s, NULL, 0); + if (errno == ERANGE && (rv == LONG_MIN || rv == LONG_MAX)) + err(1, "bad format: \"%s\"", s); + return(rv); +} + +colormap_t * +xgetcmap(fd, ncolors) + int fd; + int ncolors; +{ + colormap_t *cm; + + cm = malloc(sizeof(colormap_t) + ncolors * sizeof(u_long)); + if (cm == NULL) + err(1, "malloc"); + cm->first = 0; + cm->size = ncolors; + cm->entry = (u_long *) & cm[1]; + xioctl(fd, VIOCGCMAP, cm); + return(cm); +} + +void +printcmap(cm, ncols) + colormap_t *cm; + int ncols; +{ + int i, nel; + + switch (cm->type) { + case CM_MONO: + printf("monochrome"); + return; + case CM_COLOR: + printf("color levels: red: %d green: %d blue: %d", + cm->red_mask + 1, cm->green_mask + 1, cm->blue_mask + 1); + break; + case CM_GREYSCALE: + printf("greyscale levels: %d", cm->grey_mask + 1); + break; + } + printf("\n"); + + nel = ncols / 11 - 1; + for (i = 0; i < cm->size; i++) { + printf("0x%08lx ", cm->entry[i]); + if ((i + 1) % nel == 0) + printf("\n"); + } + if ((i + 1) % nel) + printf("\n"); +} + +int +initialize(file, is, ib, newis, newib) + char *file; + struct itewinsize *is, *newis; + struct itebell *ib, *newib; +{ + int fd; + + fd = open(file, O_RDONLY | O_NONBLOCK); + if (fd == -1) + return(-1); + + xioctl(fd, ITEIOCGWINSZ, is); + xioctl(fd, ITEIOCGBELL, ib); + + memcpy(newis, is, sizeof(*is)); + memcpy(newib, ib, sizeof(*ib)); + return(fd); +} + +void +usage() +{ + fprintf(stderr, "%s\n\t\t%s\n", + "usage: iteconfig [-i] [-v volume] [-p period] [-t count]", + "[-w width] [-h height] [-d depth] [-x off] [-y off] [color ...]"); + exit(1); +} diff --git a/usr.sbin/iteconfig/iteconfig_amiga.8 b/usr.sbin/iteconfig/iteconfig_amiga.8 new file mode 100644 index 00000000000..3e2375e7895 --- /dev/null +++ b/usr.sbin/iteconfig/iteconfig_amiga.8 @@ -0,0 +1,160 @@ +.\" $NetBSD: iteconfig_amiga.8,v 1.1 1995/05/12 21:04:30 leo Exp $ +.\" +.\" Copyright (c) 1994 Christian E. Hopps +.\" All rights reserved. +.\" +.\" 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 Christian E. Hopps. +.\" 3. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. +.\" +.\" +.Dd February 3, 1994 +.Dt ITECONFIG 8 amiga +.Os +.Sh NAME +.Nm iteconfig +.Nd modify console attributes at run time +.Sh SYNOPSIS +.Nm iteconfig +.Op Fl i +.Op Fl f Ar file +.Op Fl v Ar volume +.Op Fl p Ar pitch +.Op Fl t Ar msec +.Op Fl w Ar width +.Op Fl h Ar height +.Op Fl d Ar depth +.Op Fl x Ar offset +.Op Fl y Ar offset +.Op Ar color ... +.Sh DESCRIPTION +.Nm Iteconfig +is used to modify or examine the attributes of the +.Tn Amiga's +console bell and bitmapped console display. +The console bell's volume, pitch, and count may be +specified, as well as +the bitmapped display's width, height, horizontal and +vertical offset, pixel depth, and color map. +.Pp +The following flags are interpreted by +.Nm iteconfig : +.Bl -tag -width indent +.It Fl i +After processing all other arguments, +print information about the console's state. +.It Fl f +Open and use the terminal named by +.Ar file +rather than the default console +.Nm "/dev/ttye0". +.It Fl v +Set the volume of the console bell to +.Ar volume , +which must be between 0 and 63, inclusive. +.It Fl p +Set the pitch of the console bell to +.Ar pitch , +which must be between 10 and 1399. +.It Fl t +Set the duration of the beep to +.Ar msec +milliseconds which must be between 1 and 5000 (5 seconds). +.It Fl w +Set the width of the console display to +.Ar width +pixel columns. +.Ar Width +must be a positive integer. +.It Fl h +Set the height of the console display to +.Ar height +pixel rows. +.Ar Height +must be a positive integer. +.It Fl d +Set the number of bitplanes the console view should use to +.Ar depth . +For example, if +.Ar depth +is 3 then 8 colors will be used. +.It Fl x +Set the horizontal offset of the console view on the monitor to +.Ar offset +pixel columns. The horizontal offset may be a positive or a +negative integer, positive being an offset to the right, negative +to the left. +.It Fl y +Set the vertical offset of the console view on the monitor to +.Ar offset +pixel rows. The vertical offset may be a positive or a negative +integer, positive being an offset down, negative up. +.El +.Pp +Any additional arguments will be interpreted as colors and will +be used to supply the color values for the console view's +color map, starting with the first entry in the map. (See the +.Sx COLOR SPECIFICATION +section of this manual page for information on how to specify +colors.) +If more colors are supplied than are usable by the console +view, a warning is printed and the extra colors are ignored. +.Sh COLOR SPECIFICATION +Colors are hexidecimal numbers which have one of the following +formats: +.Bl -tag -width "0xRRGGBB" +.It Ar 0xRRGGBB +.Ar RR , +.Ar GG , +and +.Ar BB +are taken to be eight-bit values specifying the +intensities of the red, green and blue components, respectively, +of the color to be used. For example, +.Li 0xff0000 +is bright red, +.Li 0xffffff +is white, and +.Li 0x008080 +is dark cyan. +.It Ar 0xGG +.Ar GG +is taken to be an eight-bit value specifying the intensity +of grey to be used. A value of +.Li 0x00 +is black, a value of +.Li 0xff +is white, and a value of +.Li 0x80 +is a grey +approximately half way in between. +.It Ar 0xM +.Ar M +is taken to be the one-bit monochrome value to be used. +A value of +.Li 0x1 +is black, and a value of +.Li 0x0 +is white. +.El diff --git a/usr.sbin/iteconfig/iteconfig_atari.8 b/usr.sbin/iteconfig/iteconfig_atari.8 new file mode 100644 index 00000000000..196c48aa6de --- /dev/null +++ b/usr.sbin/iteconfig/iteconfig_atari.8 @@ -0,0 +1,160 @@ +.\" $NetBSD: iteconfig_atari.8,v 1.1 1995/05/12 21:04:31 leo Exp $ +.\" +.\" Copyright (c) 1994 Christian E. Hopps +.\" All rights reserved. +.\" +.\" 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 Christian E. Hopps. +.\" 3. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. +.\" +.\" +.Dd April 15, 1995 +.Dt ITECONFIG 8 atari +.Os +.Sh NAME +.Nm iteconfig +.Nd modify console attributes at run time +.Sh SYNOPSIS +.Nm iteconfig +.Op Fl i +.Op Fl f Ar file +.Op Fl v Ar volume +.Op Fl p Ar pitch +.Op Fl t Ar msec +.Op Fl w Ar width +.Op Fl h Ar height +.Op Fl d Ar depth +.Op Fl x Ar offset +.Op Fl y Ar offset +.Op Ar color ... +.Sh DESCRIPTION +.Nm Iteconfig +is used to modify or examine the attributes of the +.Tn Atari's +console bell and bitmapped console display. +The console bell's volume, pitch, and count may be +specified, as well as +the bitmapped display's width, height, horizontal and +vertical offset, pixel depth, and color map. +.Pp +The following flags are interpreted by +.Nm iteconfig : +.Bl -tag -width indent +.It Fl i +After processing all other arguments, +print information about the console's state. +.It Fl f +Open and use the terminal named by +.Ar file +rather than the default console +.Nm "/dev/ttye0". +.It Fl v +Set the volume of the console bell to +.Ar volume , +which must be between 0 and 63, inclusive. +.It Fl p +Set the pitch of the console bell to +.Ar pitch , +which must be between 10 and 1399. +.It Fl t +Set the duration of the beep to +.Ar msec +milliseconds which must be between 1 and 5000 (5 seconds). +.It Fl w +Set the width of the console display to +.Ar width +pixel columns. +.Ar Width +must be a positive integer. +.It Fl h +Set the height of the console display to +.Ar height +pixel rows. +.Ar Height +must be a positive integer. +.It Fl d +Set the number of bitplanes the console view should use to +.Ar depth . +For example, if +.Ar depth +is 3 then 8 colors will be used. +.It Fl x +Set the horizontal offset of the console view on the monitor to +.Ar offset +pixel columns. The horizontal offset may be a positive or a +negative integer, positive being an offset to the right, negative +to the left. +.It Fl y +Set the vertical offset of the console view on the monitor to +.Ar offset +pixel rows. The vertical offset may be a positive or a negative +integer, positive being an offset down, negative up. +.El +.Pp +Any additional arguments will be interpreted as colors and will +be used to supply the color values for the console view's +color map, starting with the first entry in the map. (See the +.Sx COLOR SPECIFICATION +section of this manual page for information on how to specify +colors.) +If more colors are supplied than are usable by the console +view, a warning is printed and the extra colors are ignored. +.Sh COLOR SPECIFICATION +Colors are hexidecimal numbers which have one of the following +formats: +.Bl -tag -width "0xRRGGBB" +.It Ar 0xRRGGBB +.Ar RR , +.Ar GG , +and +.Ar BB +are taken to be eight-bit values specifying the +intensities of the red, green and blue components, respectively, +of the color to be used. For example, +.Li 0xff0000 +is bright red, +.Li 0xffffff +is white, and +.Li 0x008080 +is dark cyan. +.It Ar 0xGG +.Ar GG +is taken to be an eight-bit value specifying the intensity +of grey to be used. A value of +.Li 0x00 +is black, a value of +.Li 0xff +is white, and a value of +.Li 0x80 +is a grey +approximately half way in between. +.It Ar 0xM +.Ar M +is taken to be the one-bit monochrome value to be used. +A value of +.Li 0x1 +is black, and a value of +.Li 0x0 +is white. +.El diff --git a/usr.sbin/iteconfig/pathnames.h b/usr.sbin/iteconfig/pathnames.h new file mode 100644 index 00000000000..bbea95190dd --- /dev/null +++ b/usr.sbin/iteconfig/pathnames.h @@ -0,0 +1,35 @@ +/* $NetBSD: pathnames.h,v 1.3 1995/05/12 21:04:32 leo Exp $ */ +/* + * Copyright (c) 1994 Christopher G. Demetriou + * All rights reserved. + * + * 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 Christopher G. Demetriou. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + * + */ + +#if defined(amiga) || defined(atari) +#define _PATH_CONSOLE "/dev/ttye0" +#endif |