Remove devmenu. Devconf never grew up.
This commit is contained in:
parent
716768e73c
commit
a4abdce378
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=18082
@ -1,10 +0,0 @@
|
||||
# $Id: Makefile,v 1.1 1995/04/13 21:10:56 wollman Exp $
|
||||
|
||||
PROG= devmenu
|
||||
SRCS= devmenu.c devfilter.c ifmenu.c
|
||||
MAN1= devmenu.1
|
||||
LDADD+= -ldialog -lncurses -lmytinfo
|
||||
DPADD+= ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO}
|
||||
CFLAGS+= -I/sys
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,198 +0,0 @@
|
||||
/*
|
||||
* Copyright 1995 Massachusetts Institute of Technology
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby
|
||||
* granted, provided that both the above copyright notice and this
|
||||
* permission notice appear in all copies, that both the above
|
||||
* copyright notice and this permission notice appear in all
|
||||
* supporting documentation, and that the name of M.I.T. not be used
|
||||
* in advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission. M.I.T. makes
|
||||
* no representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied
|
||||
* warranty.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
|
||||
* ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
|
||||
* SHALL M.I.T. 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/devconf.h>
|
||||
#include <sys/proc.h>
|
||||
#include <vm/vm.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <err.h>
|
||||
#include <sysexits.h>
|
||||
|
||||
#include "devmenu.h"
|
||||
|
||||
char *
|
||||
devmenu_toname(const struct devconf *dev)
|
||||
{
|
||||
static char buf[2*MAXDEVNAME];
|
||||
snprintf(buf, sizeof buf, "%s%d", dev->dc_name, dev->dc_unit);
|
||||
return buf;
|
||||
}
|
||||
|
||||
int
|
||||
devmenu_filter(const struct devconf *dev, char **userlist)
|
||||
{
|
||||
int i;
|
||||
char *name;
|
||||
|
||||
if (!userlist)
|
||||
return 1;
|
||||
|
||||
name = devmenu_toname(dev);
|
||||
|
||||
for (i = 0; userlist[i]; i++) {
|
||||
if (strcmp(name, userlist[i]) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct devconf **
|
||||
devmenu_alldevs(void)
|
||||
{
|
||||
int mib[3];
|
||||
size_t size;
|
||||
int ndevs, i, ndx;
|
||||
struct devconf **rv;
|
||||
|
||||
size = sizeof ndevs;
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_DEVCONF;
|
||||
mib[2] = DEVCONF_NUMBER;
|
||||
|
||||
if (sysctl(mib, 3, &ndevs, &size, 0, 0) < 0) {
|
||||
err(EX_OSERR, "sysctl failed reading hw.devconf.number");
|
||||
}
|
||||
|
||||
rv = malloc((ndevs + 1) * sizeof *rv);
|
||||
if (!rv) {
|
||||
err(EX_UNAVAILABLE, "malloc(%lu)",
|
||||
(unsigned long)(ndevs * sizeof *rv));
|
||||
}
|
||||
|
||||
for (ndx = 0, i = 1; i <= ndevs; i++) {
|
||||
mib[2] = i;
|
||||
if (sysctl(mib, 3, 0, &size, 0, 0) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
rv[ndx] = malloc(size);
|
||||
if (!rv[ndx]) {
|
||||
err(EX_UNAVAILABLE, "malloc(%lu)",
|
||||
(unsigned long)size);
|
||||
}
|
||||
|
||||
if (sysctl(mib, 3, rv[ndx], &size, 0, 0) < 0) {
|
||||
err(EX_OSERR, "sysctl reading hw.devconf.%d", i);
|
||||
}
|
||||
|
||||
ndx++;
|
||||
}
|
||||
|
||||
rv[ndx] = 0;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
devmenu_freedevs(struct devconf ***devpp)
|
||||
{
|
||||
struct devconf **devp = *devpp;
|
||||
int i;
|
||||
|
||||
for (i = 0; devp[i]; i++) {
|
||||
free(devp[i]);
|
||||
}
|
||||
|
||||
free(devp);
|
||||
*devpp = 0;
|
||||
}
|
||||
|
||||
const char *
|
||||
devmenu_common(const char *title, const char *hfile, char **devnames,
|
||||
const char *prompt, const char *none, enum dc_class class,
|
||||
int states)
|
||||
{
|
||||
struct devconf **devs;
|
||||
int s;
|
||||
unsigned char **items = 0;
|
||||
int nitems = 0;
|
||||
int itemindex = 0;
|
||||
char *name;
|
||||
int i;
|
||||
static char resbuf[2*MAXDEVNAME];
|
||||
|
||||
if (hfile) {
|
||||
use_helpfile((char *)hfile);
|
||||
}
|
||||
devs = devmenu_alldevs();
|
||||
|
||||
for (i = 0; devs[i]; i++) {
|
||||
if (states && !((1 << devs[i]->dc_state) & states))
|
||||
continue;
|
||||
if (class && !(devs[i]->dc_class & class))
|
||||
continue;
|
||||
if (devmenu_filter(devs[i], devnames)) {
|
||||
++nitems;
|
||||
items = realloc(items, 2 * nitems * sizeof *items);
|
||||
if (!items) {
|
||||
err(EX_UNAVAILABLE, "malloc(%lu)",
|
||||
(unsigned long)(2 * nitems * sizeof *items));
|
||||
}
|
||||
|
||||
name = devmenu_toname(devs[i]);
|
||||
|
||||
items[itemindex] = strdup(name);
|
||||
if (!items[itemindex]) {
|
||||
err(EX_UNAVAILABLE, "strdup-malloc(%lu)",
|
||||
(unsigned long)(strlen(name) + 1));
|
||||
}
|
||||
|
||||
items[itemindex + 1] = devs[i]->dc_descr;
|
||||
itemindex += 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (!nitems) {
|
||||
dialog_msgbox((char *)title, none, -1, -1, 1);
|
||||
return "none";
|
||||
}
|
||||
|
||||
name = resbuf;
|
||||
|
||||
if(dialog_menu((char *)title, prompt, 24, 78, 18, nitems, items,
|
||||
resbuf, 0, 0) != 0) {
|
||||
name = "none";
|
||||
}
|
||||
|
||||
for (i = 0; i < 2 * nitems; i += 2) {
|
||||
free(items[i]);
|
||||
}
|
||||
|
||||
free(items);
|
||||
|
||||
devmenu_freedevs(&devs);
|
||||
return name;
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
.\"
|
||||
.\" Copyright 1995 Massachusetts Institute of Technology
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and distribute this software and
|
||||
.\" its documentation for any purpose and without fee is hereby
|
||||
.\" granted, provided that both the above copyright notice and this
|
||||
.\" permission notice appear in all copies, that both the above
|
||||
.\" copyright notice and this permission notice appear in all
|
||||
.\" supporting documentation, and that the name of M.I.T. not be used
|
||||
.\" in advertising or publicity pertaining to distribution of the
|
||||
.\" software without specific, written prior permission. M.I.T. makes
|
||||
.\" no representations about the suitability of this software for any
|
||||
.\" purpose. It is provided "as is" without express or implied
|
||||
.\" warranty.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
|
||||
.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
|
||||
.\" SHALL M.I.T. 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.
|
||||
.\"
|
||||
.\" $Id: devmenu.1,v 1.1 1995/04/13 21:10:58 wollman Exp $
|
||||
.Dd April 14, 1995
|
||||
.Dt DEVMENU 1
|
||||
.Os FreeBSD 2.1
|
||||
.Sh NAME
|
||||
.Nm devmenu
|
||||
.Nd present a menu of available devices
|
||||
.Sh SYNOPSIS
|
||||
.Nm devmenu
|
||||
.Op Fl c Ar class
|
||||
.Op Fl f Ar outfile
|
||||
.Op Fl h Ar helpfile
|
||||
.Op Fl s Ar state
|
||||
.Op Fl t Ar title
|
||||
.Op Fl nid
|
||||
.Op Ar name ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
program uses the
|
||||
.Xr dialog 3
|
||||
library to present a menu of available devices meeting some set of
|
||||
criteria. The list of devices is obtained using the
|
||||
.Xr sysctl 3
|
||||
device configuration database
|
||||
.Pq Dq devconf ,
|
||||
and intersected with the list of
|
||||
.No Ar name Ns s
|
||||
if one was specified on the command line. The following command-line
|
||||
flags are supported:
|
||||
.Bl -tag -width mhmhelpfile
|
||||
.It Fl c Ar class
|
||||
specifies a class of devices to further restrict the available
|
||||
choices. Multiple
|
||||
.Fl c
|
||||
options can be specified, in which case the union of the specified
|
||||
classes is used. The following classes are currently supported:
|
||||
.Pp
|
||||
.Bl -tag -compact -width parallel
|
||||
.It Li cpu
|
||||
a processor
|
||||
.It Li bus
|
||||
a system bus, or a peripheral bus
|
||||
.It Li disk
|
||||
a read-write disk drive
|
||||
.It Li rodisk
|
||||
a read-only disk drive (e.g., CD-ROM)
|
||||
.It Li display
|
||||
a display device (usually there is only one)
|
||||
.It Li serial
|
||||
a serial port or multiport controller
|
||||
.It Li parallel
|
||||
a parallel printer port
|
||||
.It Li netif
|
||||
a network interface
|
||||
.It Li misc
|
||||
everything else
|
||||
.El
|
||||
.Pp
|
||||
.It Fl s Ar state
|
||||
specifies a required state or set of states to further restrict the
|
||||
list of devices. States are specified using the following letters:
|
||||
.Pp
|
||||
.Bl -tag -compact -width "! or ~"
|
||||
.It Li \&! or Li \&~
|
||||
at the beginning of a string requests the complement of the specified
|
||||
states.
|
||||
.It Li \&?
|
||||
requests devices with state
|
||||
.Dv DC_UNKNOWN .
|
||||
.It Li \&u
|
||||
requests devices with state
|
||||
.Dv DC_UNCONFIGURED .
|
||||
.It Li \&i
|
||||
requests devices with state
|
||||
.Dv DC_IDLE .
|
||||
.It Li \&b
|
||||
requests devices with state
|
||||
.Dv DC_BUSY .
|
||||
.El
|
||||
.Pp
|
||||
Multiple
|
||||
.Fl s
|
||||
options can be specified, in which case the union of all the requested
|
||||
states is taken.
|
||||
.It Fl f Ar outfile
|
||||
specifies the name a file where the name of the selected device is
|
||||
written. If no file is specified, the name is written on the standard
|
||||
output.
|
||||
.It Fl h Ar helpfile
|
||||
can be used to specify the name of a file to be displayed when the
|
||||
user presses the `?' key.
|
||||
.It Fl t Ar title
|
||||
specifies the title of the window passed to the
|
||||
.Xr dialog 3
|
||||
library when creating the menu.
|
||||
.El
|
||||
.Pp
|
||||
In addition, there are three flags to request special menus with
|
||||
unique prompt text and possibly pseudo-devices (but this is not yet
|
||||
implemented). These are:
|
||||
.Bl -tag -width xxx
|
||||
.It Fl n
|
||||
requests a menu of network interfaces
|
||||
.It Fl i
|
||||
requests a menu of possible installation media (i.e., disks, CD-ROMs,
|
||||
and tapes)
|
||||
.It Fl d
|
||||
requests a menu of disks
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr sysctl 3 ,
|
||||
.Xr lsdev 8
|
||||
.Sh AUTHOR
|
||||
The
|
||||
.Nm
|
||||
program was written by Garrett A. Wollman at the MIT Laboratory for
|
||||
Computer Science.
|
||||
.Sh HISTORY
|
||||
A
|
||||
.Nm
|
||||
command first appeared in
|
||||
.Tn FreeBSD
|
||||
2.1.
|
@ -1,253 +0,0 @@
|
||||
/*
|
||||
* Copyright 1995 Massachusetts Institute of Technology
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby
|
||||
* granted, provided that both the above copyright notice and this
|
||||
* permission notice appear in all copies, that both the above
|
||||
* copyright notice and this permission notice appear in all
|
||||
* supporting documentation, and that the name of M.I.T. not be used
|
||||
* in advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission. M.I.T. makes
|
||||
* no representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied
|
||||
* warranty.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
|
||||
* ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
|
||||
* SHALL M.I.T. 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* devmenu - present a menu of installed devices of a specified
|
||||
* class or classes
|
||||
*
|
||||
* Garrett A. Wollman, April 1995
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: devmenu.c,v 1.2 1995/04/14 18:33:43 wollman Exp $";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/devconf.h>
|
||||
#include <sysexits.h>
|
||||
#include <err.h>
|
||||
#include <dialog.h>
|
||||
|
||||
#include "devmenu.h"
|
||||
|
||||
static enum dc_class interpret_class(char *str);
|
||||
static int interpret_state(char *str);
|
||||
static void dm_err_exit(int);
|
||||
static int err_writefn(void *cookie, const char *val, int nchars);
|
||||
static void usage(const char *);
|
||||
|
||||
static FILE *errfp;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
enum dc_class class = 0;
|
||||
enum mode { GENERIC, NETIF, INSTALL, DISK } mode = GENERIC;
|
||||
const char *title = 0, *hfile = 0;
|
||||
char **devnames = 0;
|
||||
int c;
|
||||
int states = 0;
|
||||
const char *fn = 0;
|
||||
const char *sel = "none";
|
||||
|
||||
while ((c = getopt(argc, argv, "c:s:t:h:nidf:")) != EOF) {
|
||||
switch(c) {
|
||||
case 'c':
|
||||
class |= interpret_class(optarg);
|
||||
break;
|
||||
case 's':
|
||||
states |= interpret_state(optarg);
|
||||
break;
|
||||
case 't':
|
||||
title = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
hfile = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
mode = NETIF;
|
||||
break;
|
||||
case 'i':
|
||||
mode = INSTALL;
|
||||
break;
|
||||
case 'd':
|
||||
mode = DISK;
|
||||
break;
|
||||
case 'f':
|
||||
fn = optarg;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return EX_USAGE;
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc) {
|
||||
devnames = &argv[optind];
|
||||
}
|
||||
|
||||
errfp = fwopen(0, err_writefn);
|
||||
if (!errfp) {
|
||||
err(EX_UNAVAILABLE, "fwopen");
|
||||
}
|
||||
|
||||
setvbuf(errfp, (char *)0, _IOLBF, (size_t)0);
|
||||
|
||||
init_dialog();
|
||||
err_set_exit(dm_err_exit);
|
||||
err_set_file(errfp);
|
||||
|
||||
switch(mode) {
|
||||
case NETIF:
|
||||
sel = devmenu_netif(title, hfile, devnames, states);
|
||||
break;
|
||||
case INSTALL:
|
||||
sel = devmenu_common(title, hfile, devnames,
|
||||
"Select an installation device",
|
||||
"No installation devices found",
|
||||
DC_CLS_DISK | DC_CLS_RDISK | DC_CLS_TAPE,
|
||||
states);
|
||||
break;
|
||||
case DISK:
|
||||
sel = devmenu_common(title, hfile, devnames,
|
||||
"Select a disk",
|
||||
"No disks found",
|
||||
DC_CLS_DISK,
|
||||
states);
|
||||
break;
|
||||
case GENERIC:
|
||||
sel = devmenu_common(title, hfile, devnames,
|
||||
"Select a device",
|
||||
"No devices found",
|
||||
class,
|
||||
states);
|
||||
break;
|
||||
}
|
||||
err_set_file(0);
|
||||
fclose(errfp);
|
||||
end_dialog();
|
||||
err_set_exit(0);
|
||||
if (fn) {
|
||||
errfp = fopen(fn, "w");
|
||||
if (!errfp) {
|
||||
err(EX_OSERR, "fopen(%s)", fn);
|
||||
}
|
||||
fprintf(errfp, "%s\n", sel);
|
||||
fclose(errfp);
|
||||
} else {
|
||||
printf("%s\n", sel);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *classes[] = DC_CLASSNAMES;
|
||||
#define NCLASSES ((sizeof classes)/(sizeof classes[0]))
|
||||
|
||||
static enum dc_class
|
||||
interpret_class(char *str)
|
||||
{
|
||||
int i;
|
||||
enum dc_class rv;
|
||||
|
||||
for(i = 1; i < NCLASSES; i++) {
|
||||
if(! strcmp(classes[i], str)) {
|
||||
rv = (1 << (i - 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == NCLASSES) {
|
||||
err(EX_USAGE, "unknown class `%s'", str);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int
|
||||
interpret_state(char *str)
|
||||
{
|
||||
int rv = 0;
|
||||
int invert = 0;
|
||||
|
||||
if (*str == '!' || *str == '~') {
|
||||
invert = 1;
|
||||
str++;
|
||||
}
|
||||
|
||||
for (; *str; str++) {
|
||||
switch(*str) {
|
||||
case 'u':
|
||||
case 'U':
|
||||
rv |= 1 << DC_UNCONFIGURED;
|
||||
break;
|
||||
case '?':
|
||||
rv |= 1 << DC_UNKNOWN;
|
||||
break;
|
||||
case 'i':
|
||||
case 'I':
|
||||
rv |= 1 << DC_IDLE;
|
||||
break;
|
||||
case 'b':
|
||||
case 'B':
|
||||
rv |= 1 << DC_BUSY;
|
||||
break;
|
||||
default:
|
||||
err(EX_USAGE, "unknown state `%c'", *str);
|
||||
}
|
||||
}
|
||||
|
||||
return (invert ? ~rv : rv);
|
||||
}
|
||||
|
||||
static void
|
||||
dm_err_exit(int rval)
|
||||
{
|
||||
fflush(errfp);
|
||||
fclose(errfp);
|
||||
end_dialog();
|
||||
exit(rval);
|
||||
}
|
||||
|
||||
static int
|
||||
err_writefn(void *cookie, const char *val, int nchars)
|
||||
{
|
||||
char buf[nchars + 1];
|
||||
|
||||
strncpy(buf, val, nchars);
|
||||
buf[nchars] = '\0';
|
||||
|
||||
dialog_msgbox("Error", buf, -1, -1, 1);
|
||||
return nchars;
|
||||
}
|
||||
|
||||
static void
|
||||
usage(const char *argv0)
|
||||
{
|
||||
fprintf(stderr, "%s: usage:\n"
|
||||
"%s [-c class] [-s state] [-t title] [-h hfile] [-f outfile]"
|
||||
"[-n] [-i] [-d]\n", argv0, argv0);
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 1995 Massachusetts Institute of Technology
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby
|
||||
* granted, provided that both the above copyright notice and this
|
||||
* permission notice appear in all copies, that both the above
|
||||
* copyright notice and this permission notice appear in all
|
||||
* supporting documentation, and that the name of M.I.T. not be used
|
||||
* in advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission. M.I.T. makes
|
||||
* no representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied
|
||||
* warranty.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
|
||||
* ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
|
||||
* SHALL M.I.T. 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.
|
||||
*
|
||||
* $Id: devmenu.h,v 1.2 1995/04/14 18:33:44 wollman Exp $
|
||||
*/
|
||||
|
||||
/* NB: must include sys/devconf.h before this file */
|
||||
|
||||
/* Args are: title, help file, device name list, states */
|
||||
extern const char *devmenu_netif(const char *, const char *, char **, int);
|
||||
|
||||
extern char *devmenu_toname(const struct devconf *);
|
||||
|
||||
/* Args are: device, user's list of devices */
|
||||
extern int devmenu_filter(const struct devconf *, char **);
|
||||
|
||||
/* Returns an array of pointers to all the devconf devices in the system */
|
||||
extern struct devconf **devmenu_alldevs(void);
|
||||
|
||||
/* Frees the array allocated above */
|
||||
extern void devmenu_freedevs(struct devconf ***);
|
||||
|
||||
/* Args are: title, help file, name list, prompt, no-devices, class, states */
|
||||
extern const char *devmenu_common(const char *, const char *, char **,
|
||||
const char *, const char *, enum dc_class,
|
||||
int);
|
||||
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 1995 Massachusetts Institute of Technology
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby
|
||||
* granted, provided that both the above copyright notice and this
|
||||
* permission notice appear in all copies, that both the above
|
||||
* copyright notice and this permission notice appear in all
|
||||
* supporting documentation, and that the name of M.I.T. not be used
|
||||
* in advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission. M.I.T. makes
|
||||
* no representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied
|
||||
* warranty.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
|
||||
* ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
|
||||
* SHALL M.I.T. 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ifmenu - present a menu of network interfaces
|
||||
*
|
||||
* Garrett A. Wollman, April 1995
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/devconf.h>
|
||||
#include "devmenu.h"
|
||||
|
||||
/*
|
||||
* This is provided in a separate file so that, in the future, non-physical
|
||||
* network interfaces might be added as well.
|
||||
*/
|
||||
const char *
|
||||
devmenu_netif(const char *title, const char *hfile, char **devnames,
|
||||
int states)
|
||||
{
|
||||
return devmenu_common(title, hfile, devnames,
|
||||
"Select a network interface",
|
||||
"No network interfaces available",
|
||||
DC_CLS_NETIF, states);
|
||||
}
|
Loading…
Reference in New Issue
Block a user