summaryrefslogtreecommitdiffstats
path: root/usr.sbin/stallion/stlstats
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-10-20 12:51:34 +0000
committercharnier <charnier@FreeBSD.org>1997-10-20 12:51:34 +0000
commit951a274309f7a8b2305064a5896ee2c1b69b43cc (patch)
tree597d0478a6c2feac2bc916efef305c41d3163882 /usr.sbin/stallion/stlstats
parenta0d3c902e16c2f14e985a8409372432dab98d2fc (diff)
downloadFreeBSD-src-951a274309f7a8b2305064a5896ee2c1b69b43cc.zip
FreeBSD-src-951a274309f7a8b2305064a5896ee2c1b69b43cc.tar.gz
Use err(3). Remove progname.
Diffstat (limited to 'usr.sbin/stallion/stlstats')
-rw-r--r--usr.sbin/stallion/stlstats/stlstats.820
-rw-r--r--usr.sbin/stallion/stlstats/stlstats.c88
2 files changed, 44 insertions, 64 deletions
diff --git a/usr.sbin/stallion/stlstats/stlstats.8 b/usr.sbin/stallion/stlstats/stlstats.8
index b2b925e..05dec3c 100644
--- a/usr.sbin/stallion/stlstats/stlstats.8
+++ b/usr.sbin/stallion/stlstats/stlstats.8
@@ -42,11 +42,11 @@
.Op Fl p Ar port-number
.Op Fl d Ar port-device
.Sh DESCRIPTION
-.Nm stlstats
+.Nm Stlstats
is used to display statistical information about the ports on Stallion
Technologies multiport serial boards.
.Pp
-.Nm stlstats
+.Nm Stlstats
normally runs as a full screen menu driven application.
A help line is displayed at the bottom of each screen with the valid
input keys for this screen.
@@ -91,7 +91,7 @@ modem signal transitions and
current RS-232 signal states.
.Pp
The options are:
-.Bl -tag -width xxxxxxx
+.Bl -tag -width indent
.It Fl h
Output usage information.
.It Fl V
@@ -100,21 +100,24 @@ Output version information.
Output only the board type information.
This output is useful for scripts or other programs that need to know
a little bit about the board (for example an automated download script).
-.Nm stlstats
+.Nm Stlstats
will not enter full screen interactive mode.
.It Fl c Ar control-device
Specify the board control device through which to gather port statistics.
-The default is /dev/staliomem0.
+The default is
+.Pa /dev/staliomem0 .
.It Fl b Ar board-number
Specify the board number to display first.
The default is to display board 0.
.It Fl p Ar port-number
Specify the port number to display first.
-.Nm stlstats
+.Nm Stlstats
will go straight into the port display screen (bypassing board display)
when this option is used.
.It Fl d Ar port-device
-Specify the port special device file (the /dev/ttyXXX file) to
+Specify the port special device file (the
+.Pa /dev/ttyXXX
+file) to
display first.
The board screen is bypassed and the port statistics screen is shown
immediately on start up.
@@ -128,4 +131,5 @@ driver control device used for statistics collection
.Xr stli 4 ,
.Xr stlload 8
.Sh HISTORY
-This program was originally developed by Greg Ungerer (gerg@stallion.com).
+This program was originally developed by
+.An Greg Ungerer Aq gerg@stallion.com .
diff --git a/usr.sbin/stallion/stlstats/stlstats.c b/usr.sbin/stallion/stlstats/stlstats.c
index 7c52636..d4d6941 100644
--- a/usr.sbin/stallion/stlstats/stlstats.c
+++ b/usr.sbin/stallion/stlstats/stlstats.c
@@ -32,19 +32,23 @@
* 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: stlstats.c,v 1.4 1997/02/22 16:13:50 peter Exp $
*/
/*****************************************************************************/
-#include <stdio.h>
-#include <errno.h>
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
+#include <err.h>
#include <fcntl.h>
-#include <unistd.h>
+#include <ncurses.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <time.h>
-#include <ncurses.h>
+#include <unistd.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
@@ -56,7 +60,6 @@
char *version = "1.0.0";
char *defdevice = "/dev/staliomem0";
-char *progname;
char *ctrldevice;
int ctrlfd;
int displaybrdnr = 0;
@@ -77,7 +80,7 @@ char *line = "
/*
* Declare internal function prototypes here.
*/
-void usage(void);
+static void usage(void);
void useportdevice(char *devname);
void localexit(int nr);
void menuport();
@@ -91,15 +94,11 @@ void clearallstats();
/*****************************************************************************/
-void usage()
+static void usage()
{
- fprintf(stderr, "Usage: %s [-hVbpdc]\n\n", progname);
- fprintf(stderr, " -h print this information\n");
- fprintf(stderr, " -V show version information and exit\n");
- fprintf(stderr, " -b display board\n");
- fprintf(stderr, " -p display panel\n");
- fprintf(stderr, " -d display port device stats\n");
- fprintf(stderr, " -c specify control device to use\n");
+ fprintf(stderr, "%s\n%s\n",
+ "usage: stlstats [-hVi] [-c control-device] [-b board-number]",
+ " [-p port-number] [-d port-device]");
exit(0);
}
@@ -109,28 +108,19 @@ void useportdevice(char *devname)
{
struct stat statinfo;
int portnr, portcnt;
- int i, fd;
+ int i;
- if (stat(devname, &statinfo) < 0) {
- fprintf(stderr, "%s: port device %s does not exist\n",
- progname, devname);
- exit(1);
- }
- if ((statinfo.st_mode & S_IFMT) != S_IFCHR) {
- fprintf(stderr, "%s: port device %s is not a char device\n",
- progname, devname);
- exit(1);
- }
+ if (stat(devname, &statinfo) < 0)
+ errx(1, "port device %s does not exist", devname);
+ if ((statinfo.st_mode & S_IFMT) != S_IFCHR)
+ errx(1, "port device %s is not a char device", devname);
displaybrdnr = (statinfo.st_rdev & 0x00700000) >> 20;
portnr = (statinfo.st_rdev & 0x1f) |
((statinfo.st_rdev & 0x00010000) >> 11);
getbrdstats();
- if (brdstats.ioaddr == 0) {
- fprintf(stderr, "%s: device %s does not exist\n", progname,
- devname);
- exit(1);
- }
+ if (brdstats.ioaddr == 0)
+ errx(1, "device %s does not exist", devname);
for (portcnt = 0, i = 0; (i < brdstats.nrpanels); i++) {
if ((portnr >= portcnt) &&
@@ -138,11 +128,8 @@ void useportdevice(char *devname)
break;
portcnt += brdstats.panels[i].nrports;
}
- if (i >= brdstats.nrpanels) {
- fprintf(stderr, "%s: device %s does not exist\n", progname,
- devname);
- exit(1);
- }
+ if (i >= brdstats.nrpanels)
+ errx(1, "device %s does not exist", devname);
displaypanelnr = i;
displayportnr = portnr - portcnt;
if (displayportnr >= 16)
@@ -213,8 +200,7 @@ void getallstats()
stats[i].panel = displaypanelnr;
stats[i].port = i;
if (ioctl(ctrlfd, COM_GETPORTSTATS, &stats[i]) < 0) {
- fprintf(stderr, "\n\r\nERROR: ioctl(COM_GETPORTSTATS) "
- "failed, errno=%d\n\r\n", errno);
+ warn("ioctl(COM_GETPORTSTATS) failed");
localexit(1);
}
}
@@ -518,14 +504,13 @@ void main(int argc, char *argv[])
char *portdev;
optind = 0;
- progname = argv[0];
ctrldevice = defdevice;
useport = 0;
while ((c = getopt(argc, argv, "hvVb:p:d:c:")) != -1) {
switch (c) {
case 'V':
- printf("%s version %s\n", progname, version);
+ printf("stlstats version %s\n", version);
exit(0);
break;
case 'h':
@@ -554,21 +539,12 @@ void main(int argc, char *argv[])
/*
* Check that the control device exits and is a character device.
*/
- if (stat(ctrldevice, &statinfo) < 0) {
- fprintf(stderr, "%s: control device %s does not exist\n",
- progname, ctrldevice);
- exit(1);
- }
- if ((statinfo.st_mode & S_IFMT) != S_IFCHR) {
- fprintf(stderr, "%s: control device %s is not a char device\n",
- progname, ctrldevice);
- exit(1);
- }
- if ((ctrlfd = open(ctrldevice, O_RDWR)) < 0) {
- fprintf(stderr, "%s: open of %s failed, errno=%d\n", progname,
- ctrldevice, errno);
- exit(1);
- }
+ if (stat(ctrldevice, &statinfo) < 0)
+ errx(1, "control device %s does not exist", ctrldevice);
+ if ((statinfo.st_mode & S_IFMT) != S_IFCHR)
+ errx(1, "control device %s is not a char device", ctrldevice);
+ if ((ctrlfd = open(ctrldevice, O_RDWR)) < 0)
+ errx(1, "open of %s failed", ctrldevice);
/*
* Validate the panel number supplied by user. We do this now since we
OpenPOWER on IntegriCloud