/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <strings.h>
#include <curses.h>
#include <signal.h>
#include <fcntl.h>
#include <locale.h>
extern void total_display(void);
extern void display_cache(void);
extern void wrefresh_file(WINDOW *, int);
extern int is_dirty(void);
extern int dual_stats(void);
void checkbuf(int);
void setup_ranges(char *);
void prheading(int);
extern int zero_nic(void);
#ifdef m88k
#else /* !m88k */
static int Usec_started = 0;
extern int higher(int);
extern int is_dirty();
extern int dual_stats();
extern void total_display();
extern void display_cache();
extern void wrefresh_file(WINDOW *, int);
void setup_ranges(char *);
void prheading(int);
void checkbuf(int);
void quit(int);
void leave(int);
int sdbc_max_devices = 0;
static void
{
if (!Usec_started) {
Usec_started = 1;
}
}
static unsigned int
{
if (!Usec_started)
USEC_START();
}
#endif /* m88k */
int toggle_total_sw = 0;
int kmemfd;
int lasttime = 0;
int Elapsed_Time = 0;
static char *range;
static int had_r_option = 0;
extern int range_num;
extern int screen;
extern int dual_screen;
int *on_off;
int *dual_on_off;
int *updates_prev;
double *rate_prev;
int *samples;
typedef struct {
} range_t;
#ifdef lint
int
#else
int
#endif
{
errmessage = NULL;
if (errmessage == NULL)
"[-d delay_time] [-l logfile] [-r range]");
0, 0, 0, 0, &ustats) == SPCS_S_ERROR) {
if (ustats) { /* if SPCS_S_ERROR */
}
exit(1);
}
exit(1);
}
*range = '\0';
prev = c;
switch (c) {
case 'd':
while (*ch != '\0') {
errflg++;
ch++;
}
break;
case 'l':
break;
case 'r':
while (*ch != '\0') {
(*ch != ':'))
errflg++;
ch++;
}
if (errflg)
break;
* sizeof (char));
if (had_r_option)
had_r_option = 1;
break;
case 'z':
if (SDBC_IOCTL(SDBC_ZAP_STATS, 0, 0, 0, 0, 0,
&ustats) == SPCS_S_ERROR) {
if (ustats) {
}
}
break;
case 'D':
dflag = 1;
break;
case 'M':
mirror_sw = 1;
break;
case 'h':
case '?':
default :
errflg++;
break;
}
}
if (errflg) {
exit(1);
} else if (!prev) {
if (argc > 1) {
exit(1);
}
}
if (dflag) {
}
/*
* A few curses routines to setup screen and tty interface
*/
(void) initscr();
(void) cbreak();
(void) noecho();
(void) nonl();
(void) erase();
(void) clear();
(void) refresh();
/*
* Set signal handle
*/
USEC_INIT();
/*
* Wait one second before reading the new values
*/
(void) sleep(1);
/*CONSTCOND*/
while (1) {
/*
* If less that 1 second, force it to one second
*/
period = 1;
/*
*/
Elapsed_Time += period;
/*
* Display new statistics
*/
if (mirror_sw) {
if (dual_stats() < 0)
mirror_sw = 0;
} else if (toggle_total_sw)
else
(void) move(0, 0);
(void) refresh();
for (;;) {
&tout) <= 0)
break;
break;
}
checkbuf(c);
}
(void) erase();
}
return (0);
#pragma error_messages(default, E_STATEMENT_NOT_REACHED)
}
void
checkbuf(int c)
{
switch (c) {
case 'b' : /* ctrl b or b -- scroll backward */
case 2 :
{
if (mirror_sw == 1) {
if (dual_screen > 0)
dual_screen--;
break;
}
if (screen > 0)
screen--;
break;
}
case 'f' : /* ctrl f or f -- scroll forward */
case 6 :
{
if (mirror_sw == 1) {
dual_screen++;
break;
}
screen++;
break;
}
case 't':
case 'T':
if (mirror_sw == 1)
mirror_sw = 0;
toggle_total_sw ^= 1;
break;
case '-':
case KEY_DOWN:
if (delay > 1) {
--delay;
} else {
(void) beep();
}
break;
case '+':
case KEY_UP:
delay++;
break;
case 'C':
case 0xc:
break;
case 'B':
if (bold_flg) {
bold_flg = 0;
} else {
bold_flg = 1;
}
break;
case 'R':
if (rev_flag) {
rev_flag = 0;
} else {
rev_flag = 1;
}
break;
case 'z':
if (SDBC_IOCTL(SDBC_ZAP_STATS, 0, 0, 0, 0, 0,
&ustats) == SPCS_S_ERROR) {
if (ustats) {
}
}
break;
case 'm':
case 'M':
(void) clear();
break;
}
}
void
{
/*
* Print sample count in upper left corner
*/
/*
* Get time and print it in upper right corner
*/
}
/*ARGSUSED*/
void
{
/* clear(); */
(void) refresh();
quit(0);
}
void
{
(void) resetterm();
(void) endwin();
}
void
{
int ndx;
char chr1;
int got_colon = 0;
int after_got_colon = 0;
int got_comma = 0;
int after_got_comma = 0;
int number = 0;
int prev_num = 0;
return;
} else {
ndx = 0;
got_comma = 0;
got_colon = 0;
switch (chr1) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
break;
case ':':
got_colon = 1;
break;
case ',':
got_comma = 1;
break;
default: /* ignore any unknown characters */
break;
} /* switch */
if (got_comma && after_got_colon) {
after_got_colon = 0;
got_comma = 0;
if (number >= sdbc_max_devices)
if (range_num == 99) break;
range_num++;
number = 0;
} else if (got_colon && after_got_comma) {
got_colon = 0;
after_got_colon = 1;
after_got_comma = 0;
if (number >= sdbc_max_devices)
number = 0;
} else if (got_colon) {
got_colon = 0;
after_got_colon = 1;
if (number >= sdbc_max_devices)
number = 0;
}
} else if (got_comma) {
got_comma = 0;
after_got_comma = 1;
after_got_colon = 0;
if (number >= sdbc_max_devices)
if (range_num == 99) break;
range_num++;
}
number = 0;
} /* if */
} /* while */
if (number >= sdbc_max_devices)
if (after_got_colon) {
} else {
range_num--;
else {
}
}
}
}