From: sources@anomaly.sbs.risc.net
Subject: v01i123 - u386mon v3.40, SCO UNIX Performance Monitor - Part 03/06
Reply-To: sources@anomaly.sbs.risc.net
Organization: The Rhode Island Internet Systems Cooperative Network
Date: Mon, 14 Sep 1992 14:18:29 GMT
Followup-To: biz.sco.general


#!/bin/sh
# this is part.03 (part 3 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file det_proc.c continued
#
if test ! -r shar3_seq_.tmp; then
	echo "Please unpack part 1 first!"
	exit 1
fi
(read Scheck
 if test "$Scheck" != 3; then
	echo "Please unpack part $Scheck next!"
	exit 1
 else
	exit 0
 fi
) < shar3_seq_.tmp || exit 1
echo "x - Continuing file det_proc.c"
sed 's/^X//' << 'SHAR_EOF' >> det_proc.c &&
X	if(nprocs > max_procs_to_display)
X	{
X		nprocs = 0;
X		omitted_one = 0;
X		for(iproc = 0; iproc < v.v_proc; iproc++)
X		{
X			tproc = pprocs[iproc];
X			if(tproc->p_pid == 32767)	/* previously eliminated? */
X				continue;
X			else if(get_user(tproc,&user))
X			{
X				if( !strcmp(cptr = user.u_comm,"csh") ||
X					!strcmp(cptr,"sh")		||
X					!strcmp(cptr,"ksh")		||
X					!strcmp(cptr,"bash")	||
X					!strcmp(cptr,"cron")	||
X					!strcmp(cptr,"errdemon")||
X					!strcmp(cptr,"lpsched") ||
X					!strcmp(cptr,"logger")	||
X					!strcmp(cptr,"getty")	||
X					!strcmp(cptr,"uugetty")		)
X				{
X					tproc->p_pid = 32767;
X					omitted_one = 1;
X					continue;
X				}
X			}
X			nprocs++;
X		}
X		if(omitted_one)
X		{
X			if(omitted[0])
X				strcat(omitted,"/");
X			strcat(omitted,"shell/getty");
X		}
X	}
X
X/* if still too many procs, whittle swapped */
X	if(nprocs > max_procs_to_display)
X	{
X		nprocs = 0;
X		omitted_one = 0;
X		for(iproc = 0; iproc < v.v_proc; iproc++)
X		{
X			tproc = pprocs[iproc];
X			if(tproc->p_pid == 32767)	/* previously eliminated? */
X				continue;
X			else if(!(tproc->p_flag & SLOAD) && (tproc->p_stat != SRUN))
X			{
X				tproc->p_pid = 32767;
X				omitted_one = 1;
X				continue;
X			}
X			nprocs++;
X		}
X		if(omitted_one)
X		{
X			if(omitted[0])
X				strcat(omitted,"/");
X			strcat(omitted,"swapped");
X		}
X	}
X
X/* If still too many procs, get rid of processes not using the CPU
X   This hilites the processes that are actually doing something
X   if you have a lot */
X
X	if(nprocs > max_procs_to_display)
X	{
X		nprocs = 0;
X		omitted_one = 0;
X		for(iproc = 0; iproc < v.v_proc; iproc++)
X		{
X			tproc = pprocs[iproc];
X			if(tproc->p_pid == 32767)	/* previously eliminated? */
X				continue;
X			else if(!tproc->p_cpu)
X			{
X				tproc->p_pid = 32767;
X				omitted_one = 1;
X				continue;
X			}
X			nprocs++;
X		}
X		if(omitted_one)
X		{
X			if(omitted[0])
X				strcat(omitted,"/");
X			strcat(omitted,"no cpu");
X		}
X	}
X
X
X/* if still too many procs, whittle hard */
X	if(nprocs > max_procs_to_display)
X	{
X		nprocs = 0;
X		omitted_one = 0;
X		for(iproc = 0; iproc < v.v_proc; iproc++)
X		{
X			tproc = pprocs[iproc];
X			if(tproc->p_pid == 32767)	/* previously eliminated? */
X				continue;
X			else if(tproc->p_stat == SSLEEP)
X			{
X				tproc->p_pid = 32767;
X				omitted_one = 1;
X				continue;
X			}
X			nprocs++;
X		}
X		if(omitted_one)
X		{
X			if(omitted[0])
X				strcat(omitted,"/");
X			strcat(omitted,"sleeping");
X		}
X	}
X
X/* if still too many procs, truncate */
X	if(nprocs > max_procs_to_display)
X	{
X		nprocs = max_procs_to_display;
X		disp_msg(cpMED,"display size too small for all processes");
X		omitted[0] = 0;
X	}
X	if(omitted[0])
X	{
X		strcat(omitted," procs omitted");
X		disp_msg(cpLIT,omitted);
X	}
X
X/* sort new procs array */
X	(void)qsort((char *)pprocs,(unsigned)v.v_proc,
X		sizeof(struct proc *),ppproc_pid_compare);
X
X	if(initial)
X	{
X		(void)memcpy((char *)oldprocs,(char *)procs,
X			v.v_proc * sizeof(struct proc));
X		noldprocs = nprocs;
X		(void)memcpy((char *)poldprocs,(char *)pprocs,
X			noldprocs * sizeof(struct proc *));
X	}
X
X}	/* end of read_and_sort_procs */
X
X/*+-------------------------------------------------------------------------
X	read_utmp()
X--------------------------------------------------------------------------*/
Xvoid
Xread_utmp()
X{
Xint utmpfd;
Xregister struct utmp *tutmp = utmps;
X
X	nutmps = 0;
X	if((utmpfd = open("/etc/utmp",O_RDONLY,755)) < 0)
X		leave_text("/etc/utmp open error",255);
X
X	while(read(utmpfd,(char *)(tutmp++),sizeof(struct utmp)) > 0)
X	{
X		/* ensure null termination
X		 * (clobbers 1st byte of ut_line, but we don't use it)
X		 */
X		tutmp->ut_id[sizeof(tutmp->ut_id)] = 0;
X		if(++nutmps == MAX_UTMP)
X			leave_text("too many utmp entries for me to handle",1);
X	}
X	(void)close(utmpfd);
X}	/* end of read_utmp */
X
X/*+-------------------------------------------------------------------------
X	find_utmp_for_pgrp(pgrp)
X--------------------------------------------------------------------------*/
Xstruct utmp *
Xfind_utmp_for_pgrp(pgrp)
Xint pgrp;
X{
Xstruct utmp *tutmp = utmps;
Xregister int count = nutmps;
X
X	while(count--)
X	{
X		if(tutmp->ut_pid == pgrp)
X			return(tutmp);
X		tutmp++;
X	}
X	return((struct utmp *)0);
X}	/* end of find_utmp_for_pgrp */
X
X/*+-------------------------------------------------------------------------
X	pgrp_to_ttyname(pgrp)
X--------------------------------------------------------------------------*/
Xchar *
Xpgrp_to_ttyname(pgrp)
Xint pgrp;
X{
Xregister itmp;
Xstruct utmp *tutmp;
X
X	if(!(tutmp = find_utmp_for_pgrp(pgrp)))
X	{
X		read_utmp();
X		tutmp = find_utmp_for_pgrp(pgrp);
X	}
X	if(!tutmp)
X		return("??");
X	else
X	{
X		itmp = strlen(tutmp->ut_id);
X		return(&tutmp->ut_id[(itmp >= 2) ? (itmp - 2) : 0]);
X	}
X}	/* end of pgrp_to_ttyname */
X
X/*+-------------------------------------------------------------------------
X	get_user(tproc,tuser) - read user struct for pid
Xreturn 1 if successful, else 0 if not available
X--------------------------------------------------------------------------*/
Xint
Xget_user(tproc,tuser)
Xstruct proc *tproc;
Xstruct user *tuser;
X{
X#if defined(RDUBLK)	/* see sysi86.h #include above */
X	/* this system call is not returning 0 on success ?!? */
X	return(!!sysi86(RDUBLK,tproc->p_pid,(char *)tuser,sizeof(*tuser)));
X#else /* RDUBLK */
X	register caddr_t uptr = (caddr_t)tuser;
X	register int ubrdcount = sizeof(struct user);
X	int ipde;
X	paddr_t mptr;
X
X#if !defined(ISC_1) && !defined(mips)
X	if(tproc->p_flag & SULOAD)
X	{
X		for(ipde = 0;
X#if defined(SVR31)
X			ipde < USIZE;
X#else
X			ipde < tproc->p_usize;
X#endif
X			ipde++)
X		{
X			if(!tproc->p_ubptbl[ipde].pgm.pg_pres)	/* if not resident */
X				return(0);
X			mptr = tproc->p_ubptbl[ipde].pgm.pg_pfn * NBPP;
X			mread(uptr,(daddr_t)mptr,min(ubrdcount,NBPP));
X			uptr += NBPP;
X			if((ubrdcount -= NBPP) <= 0)
X				break;
X		}
X	}
X	else
X	{
X#if defined(SVR31)
X		mptr = tproc->p_ubdbd [0].dbd_blkno * NBPSCTR;
X#else
X		mptr = tproc->p_ubdbd.dbd_blkno * NBPSCTR;
X#endif
X		sread(uptr,mptr,ubrdcount);
X	}
X#else /* ISC_1: a compromise first-attempt */
X	for(ipde = 0; ipde < USIZE; ipde++)
X	{
X		if(!tproc->p_ubptbl[ipde].pgm.pg_pres)	/* if not resident */
X			return(0);
X		mptr = tproc->p_ubptbl[ipde].pgm.pg_pfn * NBPP;
X		mread(uptr,(daddr_t)mptr,min(ubrdcount,NBPP));
X		uptr += NBPP;
X		if((ubrdcount -= NBPP) <= 0)
X			break;
X	}
X#endif /* ISC_1 */
X
X	/*
X	 * we can get crap from swap if things change after we get
X	 * an address to read from, so validate user as best we can
X	 */
X	return( (tuser->u_ruid == tproc->p_uid) ||
X			(tuser->u_ruid == tproc->p_suid));
X
X#endif /* RDUBLK */
X}	/* end of get_user */
X
X/*+-------------------------------------------------------------------------
Xuid to username conversion; thanks for the idea to William LeFebvre
X--------------------------------------------------------------------------*/
X#define UID_NAME_HASH_SIZE	127	/* prime */
X#define HASH_EMPTY			32767
X#define HASHIT(i)			((i) % UID_NAME_HASH_SIZE)
X
Xstruct uid_name_hash_entry {
X	ushort uid;
X	char name[10];
X};
X
Xstruct uid_name_hash_entry uid_name_table[UID_NAME_HASH_SIZE];
Xint uid_count = 0;
X
X/*+-------------------------------------------------------------------------
X	init_uid_name_hash()
X--------------------------------------------------------------------------*/
Xvoid
Xinit_uid_name_hash()
X{
Xregister int ihash = 0;
Xregister struct uid_name_hash_entry *hashent = uid_name_table;
X
X	while(ihash++ < UID_NAME_HASH_SIZE)
X	{
X		hashent->uid = HASH_EMPTY;
X		hashent++;
X	}
X}	/* end of init_uid_name_hash */
X
X/*+-------------------------------------------------------------------------
X	uid_name_enter(uid,name)
X--------------------------------------------------------------------------*/
Xint
Xuid_name_enter(uid,name)
Xregister ushort uid;
Xregister char *name;
X{
Xregister ushort table_uid;
Xregister int hashval;
X
X	if(++uid_count >= UID_NAME_HASH_SIZE - 1)
X		leave_text("too many user names for me to handle",1);
X
X	hashval = HASHIT(uid);
X	while((table_uid = uid_name_table[hashval].uid) != HASH_EMPTY)
X	{
X		if(table_uid == uid)
X			return(hashval);
X		hashval = (hashval + 1) % UID_NAME_HASH_SIZE;
X	}
X
X	uid_name_table[hashval].uid = uid;
X	(void)strncpy(uid_name_table[hashval].name,name,
X		sizeof(uid_name_table[0].name));
X
X	return(hashval);
X
X}	/* end of uid_name_enter */
X
X/*+-------------------------------------------------------------------------
X	getpwent_and_enter(uid)
X--------------------------------------------------------------------------*/
Xgetpwent_and_enter(uid)
Xregister ushort uid;
X{
Xregister int hashval;
Xregister struct passwd *pwd;
Xchar errant[10];
Xstruct passwd *getpwuid();
X
X	pwd = getpwuid(uid);
X	endpwent();
X	if(pwd)
X	{
X		hashval = uid_name_enter(pwd->pw_uid,pwd->pw_name);
X		return(hashval);
X	}
X	(void)sprintf(errant,"%u",uid);
X	return(uid_name_enter(uid,errant));
X}	/* end of getpwent_and_enter */
X
X/*+-------------------------------------------------------------------------
X	uid_to_name(uid)
X--------------------------------------------------------------------------*/
Xchar *
Xuid_to_name(uid)
Xregister ushort uid;
X{
Xregister int uid_hash;
Xregister ushort table_uid;
X
X	uid_hash = HASHIT(uid);
X	while((table_uid = uid_name_table[uid_hash].uid) != uid)
X	{
X		if(table_uid == HASH_EMPTY)
X		{
X			/* not in hash table */
X			uid_hash = getpwent_and_enter(uid);
X			break;		/* out of while */
X		}
X		uid_hash = (uid_hash + 1) % UID_NAME_HASH_SIZE;
X	}
X	return(uid_name_table[uid_hash].name);
X}	/* end of uid_to_name */
X
X/*+-----------------------------------------------------------------------
X	char *get_cpu_time_str(ticks)
X  6-char static string address is returned
X------------------------------------------------------------------------*/
Xchar *
Xget_cpu_time_str(ticks)
Xtime_t ticks;
X{
Xstatic char timestr[10];
Xtime_t mm,ss;
Xextern int hz;
X
X	ticks /= hz;
X	mm = ticks / 60L;
X	ticks -= mm * 60L;
X	ss = ticks;
X
X	if(mm > 9999)
X		(void)strcpy(timestr,">9999m");
X	else if(mm > 999)
X		(void)sprintf(timestr,"%5ldm",mm);
X	else
X		(void)sprintf(timestr,"%3lu:%02lu",mm,ss);
X
X	return(timestr);
X
X}	/* end of get_cpu_time_str */
X
X#define PROC_Y		1
X#define PROC_X		0
X#define UID_X		2
X#define PID_X		12
X#define CPU_X		18
X#define PRI_X		22
X#define NICE_X		26
X#define UTIME_X		29
X#define STIME_X		36
X#define SIZE_X		43
X#define TTY_X		48
X#define CMD_X		52
X
X/*+-------------------------------------------------------------------------
X	display_proc_stat(win,iproc,initial)
X00000000001111111111222222222233333333334444444444555555555566666666667777777777
X01234567890123456789012345678901234567890123456789012345678901234567890123456789
XS     USER   PID  CPU PRI NI  UCPU   SCPU  SIZE TTY CMD
X#!########X ##### ### ### ## ###### ###### #### ### ########
X--------------------------------------------------------------------------*/
Xvoid
Xdisplay_proc_stat(win,iproc,initial)
XWINDOW *win;
Xregister int iproc;
Xregister int initial;
X{
Xregister int positioned = 0;
Xregister struct proc *tproc = pprocs[iproc];
Xstruct proc          *oproc = poldprocs[iproc];
Xint got_user;
Xstatic char *p_stat_str = " sRzdipx";	/* dependent on values of SSLEEP etc */
Xchar buf[20];
X
X	use_cp(win,cpINFO);
X	if((tproc->p_stat == SRUN) && !(tproc->p_flag & SLOAD))
X		use_cp(win,cpHIGH);
X	else if(tproc->p_stat == SRUN)
X		use_cp(win,cpMED);
X	if(tproc->p_pid != tproc->p_pid)
X		initial = 1;
X
X	wmove(win,PROC_Y + iproc,PROC_X);
X	waddch(win,(chtype)p_stat_str[tproc->p_stat]);
X	waddch(win,(tproc->p_flag & SLOAD) ? (chtype)' ' : (chtype)'S');
X	positioned = 1;
X
X	if(initial)
X	{
X		if(!positioned)
X			wmove(win,PROC_Y + iproc,PROC_X + UID_X);
X		(void)sprintf(buf,"%8s",uid_to_name(tproc->p_uid));
X		waddstr(win,buf);
X		waddch(win,(tproc->p_uid != tproc->p_suid) ? '#' : ' ');
X		waddch(win,' ');
X		positioned = 1;
X	}
X	else
X		positioned = 0;
X
X	if(initial)
X	{
X		if(!positioned)
X			wmove(win,PROC_Y + iproc,PROC_X + PID_X);
X		(void)sprintf(buf,"%5d ",tproc->p_pid);
X		waddstr(win,buf);
X		positioned = 1;
X	}
X	else
X		positioned = 0;
X
X	if(initial || (tproc->p_cpu != oproc->p_cpu))
X	{
X		if(!positioned)
X			wmove(win,PROC_Y + iproc,PROC_X + CPU_X);
X		(void)sprintf(buf,"%3u ",tproc->p_cpu);
X		waddstr(win,buf);
X		positioned = 1;
X	}
X	else
X		positioned = 0;
X
X	if(initial || (tproc->p_pri != oproc->p_pri))
X	{
X		if(!positioned)
X			wmove(win,PROC_Y + iproc,PROC_X + PRI_X);
X		(void)sprintf(buf,"%3u ",tproc->p_pri);
X		waddstr(win,buf);
X		positioned = 1;
X	}
X	else
X		positioned = 0;
X
X	if(initial || (tproc->p_nice != oproc->p_nice))
X	{
X		if(!positioned)
X			wmove(win,PROC_Y + iproc,PROC_X + NICE_X);
X		(void)sprintf(buf,"%2d ",tproc->p_nice);
X		waddstr(win,buf);
X		positioned = 1;
X	}
X	else
X		positioned = 0;
X
X/* since not saving user area, always update fields from it */
X	if(!positioned)
X		wmove(win,PROC_Y + iproc,PROC_X + UTIME_X);
X	if(got_user = get_user(tproc,&user))
X	{
X		waddstr(win,get_cpu_time_str(user.u_utime));
X		waddch(win,' ');
X		waddstr(win,get_cpu_time_str(user.u_stime));
X		waddch(win,' ');
X/*
X * process size:
X *
X * There are ways that seem right to a man, but the end of them is death.
X * u_tsize and friends are not clicks, but in bytes.
X * I thought this would have been:
X *		(ctob((u_long)user.u_tsize + user.u_dsize + user.u_ssize)) / 1024);
X * At least this makes numbers agree with /bin/ps, although I cannot
X * figure out why there is one extra page charged by ps (user is 2 pages).
X *
X *
X * This was evidentally wrong in SCO UNIX 3.2.0 and fixed in 3.2.1.
X * If you get lots of processes who size is reported as 4, define
X * USIZE_FIXED
X */
X		(void)sprintf(buf,"%4lu ",
X#if !defined(M_UNIX) /* !SCO */
X	/*
X    ** For ISC:
X	** Reports exactly the same value as ps.  The values in the user
X	** area seem totally bogus (u_tsize is always 0, from observation)
X	** so this size, the program swap size, seems the best measure.
X	** Without USIZE_FIXED, on ISC2.02/Dell UNIX 1.1 I get zeroes.
X	** With USIZE_FIXED I get values, but they're way out (e.g. vpix
X	** and cron shown as the same size....).
X	*/
X			(u_long)tproc->p_size
X#else /* SCO */
X#if defined(USIZE_FIXED)	/* SCO UNIX 3.2.1 (and later?) */
X			(ctob((u_long)user.u_tsize + user.u_dsize + user.u_ssize)) / 1024
X#else				/* SCO UNIX 3.2.0 */
X			(((u_long)user.u_tsize + 511) / 1024) +
X			(((u_long)user.u_dsize + 511) / 1024) +
X			(((u_long)user.u_ssize + 511) / 1024) +
X			(((u_long)((user.u_tsize)?1:0) * NBPP) / 1024)
X#endif
X#endif /* SCO */
X		);
X		waddstr(win,buf);
X	}
X	else
X		waddstr(win,"------ ------ ---- ");
X
X/*
X	positioned = 1;
X	if(!positioned)
X		wmove(win,PROC_Y + iproc,PROC_X + TTY_X);
X*/
X	(void)sprintf(buf,"%3.3s ",pgrp_to_ttyname(tproc->p_pgrp));
X	waddstr(win,buf);
X	positioned = 1;
X
X/*
X	if(!positioned)
X		wmove(win,PROC_Y + iproc,PROC_X + CMD_X);
X*/
X	if(got_user)
X	{
X	register char *cptr = user.u_psargs;
X	int y,x,maxx = getmaxx(win);
X		getyx(win,y,x);
X		while(*cptr && (x < maxx))
X		{
X			*cptr &= 0x7F;
X			if(*cptr < 0x20)
X				*cptr = 0x20;
X			waddch(win,*cptr);
X			cptr++,x++;
X		}
X	}
X	else
X	{
X		switch(tproc->p_stat)
X		{
X			case SZOMB:
X				waddstr(win,"<zombie>");
X				break;
X			case SXBRK:
X				waddstr(win,"<xbreak>");
X				break;
X			case SIDL:
X				waddstr(win,"<in creation>");
X				break;
X			default:
X				waddstr(win,"<swapping>");
X		}
X	}
X
X	wclrtoeol(win);
X
X}	/* end of display_proc_stat */
X
X/*+-------------------------------------------------------------------------
X	display_proc_stats(win,initial)
X--------------------------------------------------------------------------*/
Xvoid
Xdisplay_proc_stats(win,initial)
XWINDOW *win;
Xint initial;
X{
Xregister int iproc;
Xint y,x;
X
X	touchwin (win);
X	if(initial)
X	{
X		use_cp(win,cpBANNER);
X		wmove(win,0,0);
X		waddstr(win,
X			"S     USER   PID  CPU PRI NI  UCPU   SCPU  SIZE TTY CMD");
X		getyx(win,y,x);
X		while(x < getmaxx(win))
X			waddch(win,(chtype)' '),x++;
X	}
X	mypid = getpid();
X	max_procs_to_display = getmaxy(win) - PROC_Y;
X	read_and_sort_procs(initial);
X	max_procs_to_display = min(nprocs,max_procs_to_display);
X	for(iproc = 0; iproc < max_procs_to_display; iproc++)
X		display_proc_stat(win,iproc,1);
X	wclrtobot(win);
X}	/* end of display_proc_stats */
X
X/*+-------------------------------------------------------------------------
X	det_proc_init()
X--------------------------------------------------------------------------*/
Xdet_proc_init()
X{
X	init_uid_name_hash();	/* see det_proc.c */
X}	/* end of det_proc_init */
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of det_proc.c */
SHAR_EOF
echo "File det_proc.c is complete" &&
# ============= det_sio.c ==============
echo "x - extracting det_sio.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > det_sio.c &&
X/*+-------------------------------------------------------------------------
X	det_sio.c - UNIX V/386 system monitor serial I/O detail
X	...!{gatech,emory}!n4hgf!wht
X
X  Defined functions:
X	B_to_baud_rate(code)
X	cflag_to_baud_d_p_s(cflag)
X	grok_sio_tty()
X	display_siofull_init(win,tly,tlx,show_flag)
X	display_siofull_update(win,tly,tlx,tsio)
X	display_siosum_update(win,y,tsio)
X	tty_slot_compare(sio1,sio2)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:08-01-1991-23:34-wht@n4hgf-release 3.40 source control point */
X/*:05-09-1991-03:35-wht@n4hgf-gcc gives good warning */
X/*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */
X/*:08-07-1990-14:24-wht@n4hgf-nba@sysware.dk SVR31 updates */
X/*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */
X/*:07-28-1990-18:06-wht@n4hgf-2.10 release */
X/*:06-27-1990-17:33-wht@n4hgf-fix bug during 24-line display */
X/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */
X/*:06-26-1990-03:17-wht@n4hgf-creation */
X
X#include "config.h"
X#if defined(M_UNIX) /* SCO */
X#define M_TERMINFO
X#include <curses.h>
X#undef reg     /* per nba@sysware.dk */
X#ifdef NATIVE_PANELS
X# include <panel.h>
X#else
X# include "libpanel.h"
X#endif
X#include <string.h>
X#include <nlist.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <sys/ascii.h>
X#undef NGROUPS_MAX
X#undef NULL
X#include <sys/param.h>
X#include <sys/tty.h>
X
X#include "nlsym.h"
X#include "libkmem.h"
X#include "libmem.h"
X#include "libswap.h"
X#include "libnlsym.h"
X#include "u386mon.h"
X
Xextern int errno;
Xextern int sys_nerr;
Xextern char *sys_errlist[];
X
X#define SIO_NTTY 16	/* for now */
Xstruct tty sio[SIO_NTTY];
X
X#define t_slot	t_delct
X
Xint nsio;	/* number of sios open */
X
Xtypedef struct slabel
X{
X	int y,x;
X	char *label;
X} SLABEL;
X
XSLABEL tty_slabels[] =
X{
X    {  0,  0, "iflag:" },
X    {  2,  0, "oflag:" },
X    {  3,  0, "cflag:" },
X    {  4,  0, "lflag:" },
X    {  5,  7, "INTR QUIT ERASE KILL EOF/VMIN  EOL/VTIME EOL2 SWTCH" },
X    {  6,  0, "cc:" },
X    {  7,  0, "state:" },
X    {  -1,-1, (char *)0}
X};
X
Xtypedef struct bitfld
X{
X	int y,x;
X	char *label;
X	int flag_num;
X	int mask;
X} BITFLD;
X
X#define IFLAG 1
X#define OFLAG 2
X#define LFLAG 3
X#define CFLAG 4
X#define STATE 5
X
XBITFLD ttybitflds[] =
X{
X    {  0,  7, "IGNBRK", IFLAG, IGNBRK },
X    {  0, 15, "BRKINT", IFLAG, BRKINT },
X    {  0, 23, "IGNPAR", IFLAG, IGNPAR },
X    {  0, 31, "PARMRK", IFLAG, PARMRK },
X    {  0, 39, "INPCK",  IFLAG, INPCK },
X    {  0, 46, "ISTRIP", IFLAG, ISTRIP },
X    {  0, 53, "INLCR",  IFLAG, INLCR },
X    {  0, 60, "IGNCR",  IFLAG, IGNCR },
X    {  0, 68, "ICRNL",  IFLAG, ICRNL },
X    {  1,  7, "IUCLC",  IFLAG, IUCLC },
X    {  1, 15, "IXON",   IFLAG, IXON },
X    {  1, 23, "IXOFF",  IFLAG, IXOFF },
X    {  1, 31, "IXANY",  IFLAG, IXANY },
X    {  2,  7, "OPOST",  OFLAG, OPOST },
X    {  2, 15, "OLCUC",  OFLAG, OLCUC },
X    {  2, 23, "ONLCR",  OFLAG, ONLCR },
X    {  2, 31, "OCRNL",  OFLAG, OCRNL },
X    {  2, 39, "ONOCR",  OFLAG, ONOCR },
X    {  2, 46, "ONLRET", OFLAG, ONLRET },
X    {  2, 53, "OFDEL",  OFLAG, OFDEL },
X    {  3, 23, "CREAD",  CFLAG, CREAD },
X    {  3, 31, "HUPCL",  CFLAG, HUPCL },
X    {  3, 39, "CLOCAL", CFLAG, CLOCAL },
X#ifdef RTSFLOW
X    {  3, 46, "RTSFLO", CFLAG, RTSFLOW },
X#endif
X#ifdef CTSFLOW
X    {  3, 53, "CTSFLO", CFLAG, CTSFLOW },
X#endif
X    {  4,  7, "ISIG",   LFLAG, ISIG },
X    {  4, 15, "ICANON", LFLAG, ICANON },
X    {  4, 23, "XCASE",  LFLAG, XCASE },
X    {  4, 31, "ECHO",   LFLAG, ECHO },
X    {  4, 39, "ECHOE",  LFLAG, ECHOE },
X    {  4, 46, "ECHOK",  LFLAG, ECHOK },
X    {  4, 53, "ECHONL", LFLAG, ECHONL },
X    {  4, 60, "NOFLSH", LFLAG, NOFLSH },
X    {  4, 68, "XCLUDE", LFLAG, XCLUDE },
X	{  7,  7, "TO",     STATE, TIMEOUT },
X	{  7, 10, "WO",     STATE, WOPEN },
X	{  7, 13, "O",      STATE, ISOPEN },
X	{  7, 15, "TB",     STATE, TBLOCK },
X	{  7, 18, "CD",     STATE, CARR_ON },
X	{  7, 21, "BY",     STATE, BUSY },
X	{  7, 24, "OSLP",   STATE, OASLP },
X	{  7, 29, "ISLP",   STATE, IASLP },
X	{  7, 34, "STOP",   STATE, TTSTOP },
X	{  7, 39, "EXT",    STATE, EXTPROC },
X	{  7, 43, "TACT",   STATE, TACT },
X	{  7, 48, "ESC",    STATE, CLESC },
X	{  7, 52, "RTO",    STATE, RTO },
X	{  7, 56, "IOW",    STATE, TTIOW },
X	{  7, 60, "XON",    STATE, TTXON },
X	{  7, 64, "XOFF",   STATE, TTXOFF },
X    {  -1,-1, (char *)0,    -1,    -1 }
X};
X
Xtypedef struct valyx
X{
X	int y,x;
X} VALYX;
X
XVALYX ttyvalyx[] =
X{
X#define Fc_intr       0
X	{  6,  8 },
X#define Fcc_quit      1
X	{  6, 13 },
X#define Fcc_erase     2
X	{  6, 18 },
X#define Fcc_kill      3
X	{  6, 24 },
X#define Fcc_eof       4
X	{  6, 30 },
X#define Fcc_eol       5
X	{  6, 40 },
X#define Fcc_eol2      6
X	{  6, 49 },
X#define Fcc_swtch     7
X	{  6, 54 },
X#define Fbaud_b_p_s   8
X	{  3,  7 }
X};
X
Xtypedef struct b_to_br
X{
X	char *baud_rate;
X	int B_code;
X} B_TO_BR;
X
XB_TO_BR speeds[] = 	/* ordered to put less common rates later in table */
X{					/* and the vagaries of baud rates above 9600 "handled" */
X	" 2400",	B2400,
X	" 1200",	B1200,
X	" 9600",	B9600,
X#if defined(B19200)
X	"19200",	B19200,
X#endif
X#if defined(B38400)
X	"38400",	B38400,
X#endif
X	" 4800",	B4800,
X	"  300",	B300,
X	"  110",	B110,
X	"  600",	B600,
X	"   75",	B75,
X	"   50",	B50,
X	"  HUP",	B0,
X	" EXTA",	EXTA,
X	" EXTB",	EXTB,
X
X	(char *)0,0
X};
X
X/*+-------------------------------------------------------------------------
X	tty_slot_compare(sio1,sio2)
X--------------------------------------------------------------------------*/
Xint
Xtty_slot_compare(sio1,sio2)
Xstruct tty *sio1;
Xstruct tty *sio2;
X{
X	return(sio1->t_slot - sio2->t_slot);
X}	/* end of tty_slot_compare */
X
X/*+-------------------------------------------------------------------------
X	grok_sio_tty()
X--------------------------------------------------------------------------*/
Xvoid
Xgrok_sio_tty()
X{
Xregister isio;
Xregister struct tty *tsio;
X
X	nsio = 0;
X	kread((caddr_t)sio,sio_ttyaddr,sizeof(struct tty) * SIO_NTTY);
X	for(isio = 0; isio < SIO_NTTY; isio++)
X	{
X		tsio = &sio[isio];
X		if(tsio->t_state & (WOPEN | ISOPEN))
X		{
X			tsio->t_slot = (ushort)isio;
X			nsio++;
X			continue;
X		}
X		tsio->t_slot = 127;
X	}
X	(void)qsort((char *)sio,(unsigned)SIO_NTTY,
X		sizeof(struct tty),tty_slot_compare);
X
X}	/* end of grok_sio_tty */
X
X/*+-------------------------------------------------------------------------
X	B_to_baud_rate(code) - convert CBAUD B_ code to baud rate string
X--------------------------------------------------------------------------*/
Xchar *
XB_to_baud_rate(code)
X{
Xregister int n;
X
X	for(n=0; speeds[n].baud_rate; n++)
X		if(speeds[n].B_code == code)
X			return(speeds[n].baud_rate);
X	return("-----");
X}	/* end of B_to_baud_rate */
X
X/*+-------------------------------------------------------------------------
X	cflag_to_baud_d_p_s(cflag)
X--------------------------------------------------------------------------*/
Xchar *
Xcflag_to_baud_d_p_s(cflag)
Xint cflag;
X{
Xregister char *cptr;
Xstatic char rtnstr[16];
X
X	strcpy(rtnstr,B_to_baud_rate(cflag & CBAUD));
X	cptr = rtnstr + strlen(rtnstr);
X	*cptr++ = '-';
X	switch(cflag & CSIZE)
X	{
X		case CS5: *cptr++ = '5'; break;
X		case CS6: *cptr++ = '6'; break;
X		case CS7: *cptr++ = '7'; break;
X		case CS8: *cptr++ = '8'; break;
X	}
X	*cptr++ = '-';
X	*cptr++ = (cflag & PARENB) ? ((cflag & PARODD) ? 'O' : 'E') : 'N';
X	*cptr++ = '-';
X	*cptr++ = (cflag & CSTOPB) ? '2' : '1';
X	*cptr = 0;
X	return(rtnstr);
X
X}	/* end of cflag_to_baud_d_p_s */
X
X/*+-----------------------------------------------------------------------
X	display_siofull_update(win,tly,tlx,tsio)
X
X000000000011111111112222222222333333333344444444445555555555666666666677777
X012345678901234567890123456789012345678901234567890123456789012345678901234
Xiflag: IGNBRK  BRKINT  IGNPAR  PARMRK  INPCK  ISTRIP INLCR  IGNCR   ICRNL
X       IUCLC   IXON    IXOFF   IXANY
Xoflag: OPOST   OLCUC   ONLCR   OCRNL   ONOCR  ONLRET OFDEL
Xcflag: 09600-8-N-1     CREAD   HUPCL   CLOCAL
Xlflag: ISIG    ICANON  XCASE   ECHO    ECHOE  ECHOK  ECHONL NOFLSH  XCLUDE
X       INTR QUIT ERASE KILL EOF/VMIN  EOL/VTIME EOL2 SWTCH 
Xcc:     03   1c   08    15    01        00       00   00   
X
X------------------------------------------------------------------------*/
Xvoid
Xdisplay_siofull_update(win,tly,tlx,tsio)
XWINDOW *win;
Xint tly;
Xint tlx;
Xstruct tty *tsio;
X{
Xregister flag;
Xregister i_cc;
XBITFLD *bfptr = ttybitflds;
XVALYX *vptr = ttyvalyx;
X
X	use_cp(win,cpLOW);
X	while(bfptr->y >= 0)
X	{
X		switch(bfptr->flag_num)
X		{
X			case IFLAG: flag = tsio->t_iflag; break;
X			case OFLAG: flag = tsio->t_oflag; break;
X			case LFLAG: flag = tsio->t_lflag; break;
X			case CFLAG: flag = tsio->t_cflag; break;
X			case STATE: flag = tsio->t_state; break;
X		}
X		flag &= bfptr->mask;
X		wmove(win,bfptr->y + tly,bfptr->x + tlx);
X		if(flag)
X			use_cp(win,cpREVERSE);
X		waddstr(win,bfptr->label);
X		if(flag)
X			use_cp(win,cpLOW);
X		bfptr++;
X	}
X	for(i_cc = 0; i_cc < NCC; i_cc++)
X	{
X		wmove(win,vptr->y + tly,vptr->x + tlx);
X		wprintw(win,"%02x",tsio->t_cc[i_cc]);
X		vptr++;
X	}
X
X	vptr = &ttyvalyx[Fbaud_b_p_s];
X	clear_area(win,vptr->y + tly,vptr->x + tlx,12);
X	waddstr(win,cflag_to_baud_d_p_s(tsio->t_cflag));
X
X}	/* end of display_siofull_update */
X
X/*+-------------------------------------------------------------------------
X	display_siofull_init(win,tly,tlx,show_flag)
X--------------------------------------------------------------------------*/
Xvoid
Xdisplay_siofull_init(win,tly,tlx,show_flag)
XWINDOW *win;
Xint tly;
Xint tlx;
Xint show_flag;
X{
Xregister y;
XSLABEL *sptr = tty_slabels;
X
X	use_cp(win,cpLIT);
X	for(y = 0; y < 7; y++)
X		clear_area(win,y,0,getmaxy(win));
X	if(show_flag)
X	{
X		while(sptr->y >= 0)
X		{
X			wmove(win,sptr->y + tly,sptr->x + tlx);
X			waddstr(win,sptr->label);
X			sptr++;
X		}
X	}
X
X}	/* end of display_siofull_init */
X
X/*+-------------------------------------------------------------------------
X	display_siosum_update(win,y,tsio)
X--------------------------------------------------------------------------*/
Xvoid
Xdisplay_siosum_update(win,y,tsio)
Xregister WINDOW *win;
Xint y;
Xregister struct tty *tsio;
X{
Xregister unsigned int itmp;
Xregister opened = tsio->t_state & (ISOPEN | WOPEN);
Xchar s8[8];
X
X#define TX 1
X#define RX 6
X#define CX 11
X#define OX 16
X#define SX 23
X#define FX 30
X
X	wmove(win,y,TX);
X#ifdef M_UNIX
X	waddch(win,(tsio->t_slot < 8) ? '1' : '2');
X	waddch(win,(tsio->t_slot % 8) + 'a');
X#else
X	wprintw(win,"%02d",tsio->slot);
X#endif
X
X	if(!opened)
X	{
X		use_cp(win,cpINFO);
X		clear_area(win,y,TX,COLS - TX);
X		waddstr(win,"closed");
X		return;
X	}
X
X	wmove(win,y,RX);
X	if((itmp = (unsigned)tsio->t_rawq.c_cc) > 999)
X		itmp = 999;
X	if(itmp > 10)
X		use_cp(win,cpHIGH);
X	else if(itmp > 3)
X		use_cp(win,cpMED);
X	else
X		use_cp(win,cpLOW);
X	wprintw(win,"%3d",itmp);
X
X	if((itmp = (unsigned)tsio->t_canq.c_cc) > 999)
X		itmp = 999;
X	if(itmp > 20)
X		use_cp(win,cpHIGH);
X	else if(itmp > 10)
X		use_cp(win,cpMED);
X	else
X		use_cp(win,cpLOW);
X	wmove(win,y,CX);
X	wprintw(win,"%3d",itmp);
X
X	if((itmp = (unsigned)tsio->t_outq.c_cc + tsio->t_tbuf.c_count) > 99999)
X		itmp = 99999;
X	if(itmp > 75)
X		use_cp(win,cpHIGH);
X	else if(itmp > 20)
X		use_cp(win,cpMED);
X	else
X		use_cp(win,cpLOW);
X	wmove(win,y,OX);
X	wprintw(win,"%5d",itmp);
X
X	use_cp(win,cpINFO);
X	wmove(win,y,SX);
X	waddstr(win,B_to_baud_rate(tsio->t_cflag & CBAUD));
X
X	strcpy(s8,".....");
X	if(tsio->t_state & WOPEN)
X		s8[0] = 'W';
X	else if(tsio->t_state & ISOPEN)
X		s8[0] = 'O';
X	if(tsio->t_state & CARR_ON)
X		s8[1] = 'C';
X	if(tsio->t_state & BUSY)
X		s8[2] = 'B';
X	if(tsio->t_state & TTSTOP)
X		s8[3] = 'S';
X	if(tsio->t_state & TIMEOUT)
X		s8[4] = 'D';
X	wmove(win,y,FX);
X	waddstr(win,s8);
X
X	wprintw(win,"%7o",tsio->t_iflag);
X	wprintw(win,"%7o",tsio->t_oflag);
X	wprintw(win,"%7o",tsio->t_cflag);
X	wprintw(win,"%7o",tsio->t_lflag);
X	if(tsio->t_pgrp)
X		wprintw(win,"%6d",tsio->t_pgrp);
X	else
X		waddstr(win,"      ");
X
X}	/* end of display_siosum_update */
X
X/*+-------------------------------------------------------------------------
X	display_sio_summary(win,initial)
X--------------------------------------------------------------------------*/
Xdisplay_sio_summary(win,initial)
Xregister WINDOW *win;
Xint initial;
X{
Xregister int isio;
Xint max_displayable_sios = getmaxy(win) - 2;
Xstatic char *header  = 
X" tty  raw  can    out  speed  state  iflag  oflag  cflag  lflag  pgrp";
Xstatic char *legend =
X"W=wait for open  O=open C=carrier on  B=output busy  S=stopped  T=timeout";
Xstatic couldnt_display_all = 0;
X
X	if(initial)
X	{
X		use_cp(win,cpBANNER);
X		clear_area(win,0,0,getmaxx(win));
X		waddstr(win,header);
X		use_cp(win,cpLIT);
X		clear_area(win,getmaxy(win)-1,0,getmaxx(win));
X		waddstr(win,legend);
X		couldnt_display_all = 1;
X	}
X	grok_sio_tty();
X	for(isio = 0; (isio < nsio); isio++)
X	{
X		if(isio > max_displayable_sios)
X		{
X			wmove(win,getmaxy(win)-2);
X			use_cp(win,cpMED);
X			waddstr(win,"cannot display all active serial ports");
X			couldnt_display_all = 1;
X			return;
X		}
X		display_siosum_update(win,isio + 1,&sio[isio]);
X	}
X
X	for(; isio < getmaxy(win)-2; isio++);
X		clear_area(win,isio + 1,0,getmaxx(win));
X
X	if(couldnt_display_all)
X	{
X		use_cp(win,cpINFO);
X		clear_area(win,getmaxy(win)-2,0,getmaxx(win));
X		couldnt_display_all = 0;
X	}
X
X}	/* end of display_sio_summary */
X
X#endif /* M_UNIX / SCO */
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of det_sio.c */
SHAR_EOF
# ============= det_stream.c ==============
echo "x - extracting det_stream.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > det_stream.c &&
X/*+-------------------------------------------------------------------------
X	det_stream.c - UNIX V/386 system monitor stream usage detail
X	martin@hppcmart.grenoble.hp.com
X
X00000000001111111111222222222233333333334444444444555555555566666666667777777777
X01234567890123456789012345678901234567890123456789012345678901234567890123456789
XResource             Config Alloc Fail -- (% of resource used) -----------------
X#################### ###### ##### #### ######################################### 
X  Defined functions:
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:08-01-1991-23:34-wht@n4hgf-release 3.40 source control point */
X/*:05-15-1991-17:22-wht@n4hgf-2.3 patches for SVR31 from nba@sysware.dk */
X/*:02-07-1991-13:30-martin@hppcmart-creation */
X
X#define M_TERMINFO
X
X#include <curses.h>
X#ifdef NATIVE_PANELS
X# include <panel.h>
X#else
X# include "libpanel.h"
X#endif
X#include <string.h>
X#include <nlist.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X/*
X#include <sys/ascii.h>
X*/
X#include <sys/var.h>
X#undef NGROUPS_MAX
X#undef NULL
X#include <sys/param.h>
X#include <sys/stream.h>
X#include <sys/strstat.h>
X
X#include "nlsym.h"
X#include "libkmem.h"
X#include "libmem.h"
X#include "libswap.h"
X#include "libnlsym.h"
X#include "u386mon.h"
X
Xextern struct var v;
Xunsigned stream_size[NCLASS+4];
Xushort rbsize[NCLASS];
Xstruct strstat strst;
X
X#define _NDX_STREAMS	0
X#define _NDX_QUEUES		1
X#define _NDX_MESSAGES	2
X#define	_NDX_NBLK		3
X#define _NDX_NBLK4		4
X#define _NDX_NBLK16		5
X#define _NDX_NBLK64		6
X#define _NDX_NBLK128	7
X#define _NDX_NBLK256	8
X#define _NDX_NBLK512	9
X#define _NDX_NBLK1024	10
X#define _NDX_NBLK2048	11
X#define _NDX_NBLK4096	12
X
X/*+----------------------------------------------------------------------------
X	init_stream()
X-----------------------------------------------------------------------------*/
Xvoid
Xinit_stream()
X{
X	int nmblock, i;
X
X	kread((caddr_t) rbsize, rbsizeaddr, sizeof(ushort) * NCLASS);
X	stream_size[_NDX_STREAMS]=v.v_nstream;
X	stream_size[_NDX_QUEUES]=v.v_nqueue;
X	kread((caddr_t) &nmblock, nmblockaddr, sizeof(int));
X	stream_size[_NDX_MESSAGES]=nmblock;
X	stream_size[_NDX_NBLK4]=v.v_nblk4;	
X	stream_size[_NDX_NBLK16]=v.v_nblk16;	
X	stream_size[_NDX_NBLK64]=v.v_nblk64;	
X	stream_size[_NDX_NBLK128]=v.v_nblk128;	
X	stream_size[_NDX_NBLK256]=v.v_nblk256;	
X	stream_size[_NDX_NBLK512]=v.v_nblk512;	
X	stream_size[_NDX_NBLK1024]=v.v_nblk1024;	
X	stream_size[_NDX_NBLK2048]=v.v_nblk2048;	
X	stream_size[_NDX_NBLK4096]=v.v_nblk4096;	
X	stream_size[_NDX_NBLK]=0;
X    for(i=_NDX_NBLK4; i<=_NDX_NBLK4096; i++)
X		stream_size[_NDX_NBLK]+=stream_size[i];
X}
X
X/*+----------------------------------------------------------------------------
X	draw_streamscale_literals(win, y, x);
X
X00000000001111111111222222222233333333334444444444555555555566666666667777777777
X01234567890123456789012345678901234567890123456789012345678901234567890123456789
XResource             Config Alloc Fail -- (% of resource used) -----------------
XStreams              ###### ##### #### #########################################
XQueues
XMessage blocks
XData blocks
XData block size ####
X-----------------------------------------------------------------------------*/
X
Xvoid
Xdraw_streamscale_literals(win, y, x)
XWINDOW *win;
Xint y, x;
X
X{
X	static char *header = 
X"Resource            Config Alloc  Fail -- (% of resource used) ";
X	int x2, i;
X
X	wmove(win, y, x);
X	use_cp(win, cpBANNER);
X	waddstr(win, header);
X	getyx(win,y,x2);
X	while (x2++ <= COLS)
X		waddch(win, (chtype)'-');
X	use_cp(win,cpLIT);
X	clear_area(win,getmaxy(win)-1,0,getmaxx(win));
X	mvwaddstr(win, y + 1, x, "Streams");
X	mvwaddstr(win, y + 2, x, "Queues");
X	mvwaddstr(win, y + 3, x, "Message blocks");
X	mvwaddstr(win, y + 4, x, "Data blocks");
X	for (i=0; i<NCLASS; i++)
X		mvwprintw(win, (y+i+5), x, "Data block size %4lu", rbsize[i]);
X} 
X
X/*+----------------------------------------------------------------------------
X	update_streamscale(win, y, x, width);
X
X00000000001111111111222222222233333333334444444444555555555566666666667777777777
X01234567890123456789012345678901234567890123456789012345678901234567890123456789
XConf  Alloc Fail  -- (% of resource used) -----------------
X##### ##### ##### #########################################
X-----------------------------------------------------------------------------*/
X#define _STREAM_CO	0
X#define _STREAM_AL	6
X#define _STREAM_FA	12
X#define _STREAM_SX	18
X
Xvoid
Xupdate_streamscale(win, y, x, width)
XWINDOW *win;
Xint y, x;
Xint width;
X
X{
X	int percent_used, percent_max;
X	int i, itmp, max;
X	alcdat	*strdat;
X
X	kread((caddr_t)&strst, strstaddr, sizeof(struct strstat));
X	strdat=(alcdat *)&strst;
X	for (i=0; i<NCLASS+4; i++) {
X		percent_used=stream_size[i] ? (strdat->use*100/stream_size[i]) : 0;
X		percent_max=stream_size[i] ? (strdat->max*100/stream_size[i]) : 0;
X		use_cp(win, cpINFO);
X		mvwprintw(win, y+i, _STREAM_CO+x, "%5i", stream_size[i]);
X		mvwprintw(win, y+i, _STREAM_AL+x, "%5i", strdat->use);
X		if (strdat->fail)
X			use_cp(win, cpHIGH);
X		else
X			use_cp(win, cpINFO);
X		mvwprintw(win, y+i, _STREAM_FA+x, "%5i", strdat->fail);
X		wmove(win, y+i, _STREAM_SX+x);
X
X		if (percent_used < 70)
X			use_cp(win, cpLOW);
X		else if (percent_used < 90)
X			use_cp(win, cpMED);
X		else
X			use_cp(win, cpHIGH);
X
X		itmp=(width * percent_used) / 100;
X		max=(width * percent_max) / 100;
X		while (-1) {
X			itmp--;max--;
X			if (max<1) {
X				use_cp(win, cpHIGH);
X				waddch(win, (chtype)'M');
X				break;
X			}
X			if (itmp>-1)
X				waddch(win, (chtype)'-');
X			else
X				waddch(win, (chtype)' ');
X		}
X
X		wclrtoeol(win);
X		strdat++;
X	}
X}
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of det_stream.c */
SHAR_EOF
# ============= det_table.c ==============
echo "x - extracting det_table.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > det_table.c &&
X/*+-------------------------------------------------------------------------
X	det_table.c - UNIX V/386 system monitor table usage detail
X	martin@hppcmart.grenoble.hp.com
X
X00000000001111111111222222222233333333334444444444555555555566666666667777777777
X01234567890123456789012345678901234567890123456789012345678901234567890123456789
XResource             Config Alloc Fail -- (% of resource used) -----------------
X#################### ###### ##### #### ######################################### 
X  Defined functions:
Xfiles_in_use()
Xinodes_in_use()
Xupdate_table_line(win, y, x, width, num_item, max_item, conf_item, percent_item)
Xinit_table()
Xdraw_table_literals(win,y,x)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:08-01-1991-23:34-wht@n4hgf-release 3.40 source control point */
X/*:05-15-1991-17:22-wht@n4hgf-2.3 patches for SVR31 from nba@sysware.dk */
X/*:02-07-1991-13:30-martin@hppcmart-creation */
X
X#define M_TERMINFO
X
X#include <curses.h>
X#ifdef NATIVE_PANELS
X# include <panel.h>
X#else
X# include "libpanel.h"
X#endif
X#include <string.h>
X#include <nlist.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X/*
X#include <sys/ascii.h>
X*/
X#include <sys/var.h>
X#undef NGROUPS_MAX
X#undef NULL
X#include <sys/param.h>
X#include <sys/inode.h>
X#include <sys/file.h>
X#include <sys/fcntl.h>
X#include <sys/flock.h>
X#include <sys/immu.h>
X#include <sys/region.h>
X#include <sys/callo.h>
X
X#include "nlsym.h"
X#include "libkmem.h"
X#include "libmem.h"
X#include "libswap.h"
X#include "libnlsym.h"
X#include "u386mon.h"
X
Xextern struct var v;
Xstruct file *fpbase;
Xstruct inode *ipbase;
Xstruct flckinfo flckinfo;
Xstruct region *rgbase;
Xstruct callo *callbase;
Xint max_files=0;
Xint max_inodes=0;
Xint max_locks=0;
Xint max_regions=0;
Xint max_callouts=0;
X
X/*+-------------------------------------------------------------------------
X	files_in_use()
X
X	Returns the number of files in use or -1 if the free list
X	pointers were munged when read which happens every now and then.
X--------------------------------------------------------------------------*/
Xstatic int
Xfiles_in_use()
X{
X	struct file *fp, *fflist;
X	register int cnt=0;
X	unsigned int ndx;
X
X	kread((caddr_t) fpbase, fileaddr, sizeof(struct file)*v.v_file);
X	kread((caddr_t) &fflist, ffreelistaddr, sizeof(struct file *));
X	fp=fpbase + (fflist - (struct file *)fileaddr);
X	while (1) {
X		cnt++;
X		if (fp->f_next == 0) break;
X		ndx=fp->f_next - (struct file *)fileaddr;
X		if ((ndx >= v.v_file) || (ndx < 0) || (cnt > v.v_file)) return(-1);
X		fp=fpbase + ndx;
X			
X	}
X	return(v.v_file-cnt);
X}
X
X/*+-------------------------------------------------------------------------
X	inodes_in_use()
X
X	Returns the number of inodes used or -1 if the free list
X	pointers were munged when read which happens every now and then.
X--------------------------------------------------------------------------*/
X
Xstatic int
Xinodes_in_use()
X{
X	struct inode *ip, *iflistend;
X	struct ifreelist iflist;
X	register int cnt=0;
X	int ndx;
X
X	kread((caddr_t) ipbase, inodeaddr, sizeof(struct inode)*v.v_inode);
X	kread((caddr_t) &iflist, ifreelistaddr, sizeof(struct ifreelist));
X	ip=ipbase + (iflist.av_forw - (struct inode *)inodeaddr);
X	iflistend=ipbase + (iflist.av_back - (struct inode *)inodeaddr);
X	while (1) {
X		cnt++;
X		if (ip==iflistend) break;
X		ndx=ip->av_forw - (struct inode *)inodeaddr;
X		if ((ndx >= v.v_inode) || (ndx < 0) || (cnt > v.v_inode)) return(-1);
X		ip=ipbase + ndx;
X	}
X	return(v.v_inode-cnt);
X}
X
X/*+-------------------------------------------------------------------------
X	regions_in_use()
X
X	Returns the number of regions used or -1 if the free list
X	pointers were munged when read which happens every now and then.
X--------------------------------------------------------------------------*/
X
Xstatic int
Xregions_in_use()
X{
X	struct region *rg, ractive;
X	register int cnt=0;
X	int ndx;
X
X	kread((caddr_t) rgbase, regionaddr, sizeof(struct region)*v.v_region);
X	kread((caddr_t) &ractive, ractiveaddr, sizeof(struct region));
X	rg=rgbase + (ractive.r_forw - (struct region *)regionaddr);
X	while (1) {
X		cnt++;
X		if (rg->r_forw==(struct region *)ractiveaddr) break;
X		ndx=rg->r_forw - (struct region *)regionaddr;
X		if ((ndx >= v.v_region) || (ndx < 0) || (cnt > v.v_region)) return(-1);
X		rg=rgbase + ndx;
X	}
X	return(cnt);
X}
X
X/*+-------------------------------------------------------------------------
X	callouts_in_use()
X
X	Returns the number of callouts used.
X--------------------------------------------------------------------------*/
X
Xstatic int
Xcallouts_in_use()
X{
X	struct callo *call;
X	register int cnt=0;
X	register int ndx=0;
X
X	kread((caddr_t) callbase, calloutaddr, sizeof(struct callo)*v.v_call);
X	call=callbase;
X	while (ndx<v.v_call) {
X		ndx++; call++;
X				/* This is a guess - I'm checking it with SCO */
X		if (call->c_id>0) cnt++;
X	}
X	return(cnt);
X}
X
X
X
X/*+-------------------------------------------------------------------------
X	update_table_line(win)
X00000000001111111111222222222233333333334444444444555555555566666666667777777777
X01234567890123456789012345678901234567890123456789012345678901234567890123456789
Xtual total %used ------------------------------------------------
X####  ####   ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
X--------------------------------------------------------------------------*/
X
X#define _TABLESCALE_AC	0
X#define _TABLESCALE_TO	6
X#define _TABLESCALE_PE	13
X#define _TABLESCALE_SX	17
X
Xstatic void
Xupdate_table_line(win, y, x, width, num_item, max_item, conf_item, percent_item)
XWINDOW *win;
Xint y;
Xint x;
Xint width;
Xint num_item;
Xint max_item;
Xint conf_item;
Xint percent_item;
X
X{
X	int itmp, max;
X
X	if (num_item<0) {
X
X		wmove(win, y, x + _TABLESCALE_AC);
X		use_cp(win, cpHIGH);
X		waddstr(win, "OVER");
X
X	} else {
X
X		wmove(win,y, x + _TABLESCALE_AC);
X		use_cp(win,cpINFO);
X		wprintw(win,"%4ld",num_item);
X
X		wmove(win,y, x + _TABLESCALE_TO);
X		use_cp(win,cpINFO);
X		wprintw(win,"%4ld",conf_item);
X
X		wmove(win,y, x + _TABLESCALE_PE);
X		if(percent_item < 70)
X			use_cp(win,cpLOW);
X		else if(percent_item < 90)
X			use_cp(win,cpMED);
X		else
X			use_cp(win,cpHIGH);
X		wprintw(win,"%3ld", percent_item);
X
X		wmove(win,y, x + _TABLESCALE_SX);
X
X		itmp = (width * percent_item) / 100;
X		max = (width * max_item) / 100;
X		while(-1) {
X			itmp--; max--;
X			if (max<1) {
X				use_cp(win,cpHIGH);
X				waddch(win,(chtype)'M');
X				break;
X			}
X			if (itmp>-1)
X				waddch(win,(chtype)'-');
X			else
X				waddch(win,(chtype)' ');
X		}
X		wclrtoeol(win);
X	}
X}
X			
X
X
X/*+-------------------------------------------------------------------------
X	init_table()
X
X--------------------------------------------------------------------------*/
X
Xvoid
Xinit_table()
X
X{
X	if (!(fpbase = (struct file *) malloc(sizeof(struct file)*v.v_file)))
X		leave_text("cannot alloc memory for file table",1);
X	if (!(ipbase = (struct inode *) malloc(sizeof(struct inode)*v.v_inode)))
X		leave_text("cannot alloc memory for inode table",1);
X	if (!(rgbase = (struct region *) malloc(sizeof(struct region)*v.v_region)))
X		leave_text("cannot alloc memory for region table",1);
X	if (!(callbase = (struct callo *) malloc(sizeof(struct callo)*v.v_call)))
X		leave_text("cannot alloc memory for region table",1);
X}
X
X/*+-------------------------------------------------------------------------
X	update_table(win,y,x,width)
X
X--------------------------------------------------------------------------*/
X
Xvoid
Xupdate_table(win,y,x,width)
XWINDOW *win;
Xint y;
Xint x;
Xregister width;
X{
X	int num_files;
X	int num_inodes;
X	int num_regions;
X	int num_callouts;
X	int percent_files;
X	int percent_inodes;
X	int percent_locks;
X	int percent_regions;
X	int percent_callouts;
X
X	num_files=files_in_use();
X	num_inodes=inodes_in_use();
X	num_regions=regions_in_use();
X	num_callouts=callouts_in_use();
X	kread((caddr_t)&flckinfo, flckinfoaddr, sizeof(struct flckinfo));
X	num_callouts=callouts_in_use();
X
X	percent_files=(num_files * 100 / v.v_file);
X	percent_inodes=(num_inodes * 100 / v.v_inode);
X	percent_regions=(num_regions * 100 / v.v_region);
X	percent_locks=flckinfo.recs ? (flckinfo.reccnt * 100 / flckinfo.recs) : 0;
X	percent_callouts=( num_callouts * 100 / v.v_call);
X	if(percent_files > max_files) max_files=percent_files;
X	if(percent_inodes > max_inodes) max_inodes=percent_inodes;
X	if(percent_locks > max_locks) max_locks=percent_locks;
X	if(percent_regions > max_regions) max_regions=percent_regions;
X	if(percent_callouts > max_callouts) max_callouts=percent_callouts;
X
X	update_table_line(win, y, x, width,
X			num_files, max_files, v.v_file, percent_files);
X	update_table_line(win, y + 1, x, width,
X			num_inodes, max_inodes, v.v_inode, percent_inodes);
X	update_table_line(win, y + 2, x, width,
X			flckinfo.reccnt, max_locks, flckinfo.recs, percent_locks);
X	update_table_line(win, y + 3, x, width,
X			num_regions, max_regions, v.v_region, percent_regions);
X	update_table_line(win, y + 4, x, width,
X			num_callouts, max_callouts, v.v_call, percent_callouts);
X	return;
X}	/* end of update_table */
X
X
X/*+-------------------------------------------------------------------------
X	draw_table_literals(win)
X00000000001111111111222222222233333333334444444444555555555566666666667777777777
X01234567890123456789012345678901234567890123456789012345678901234567890123456789
XResource     actual total %used ------------------------------------------------
X############   ####  ####   ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
X--------------------------------------------------------------------------*/
Xvoid
Xdraw_table_literals(win,y,x)
XWINDOW *win;
Xint y;
Xint x;
X{
Xint x2 = x;
X
X	wmove(win,y,x);
X	use_cp(win,cpBANNER);
X	waddstr(win,"Resource     actual total %used ");
X	getyx(win,y,x2);
X	while(x2 < COLS)
X		waddch(win,(chtype)'-'),x2++;
X	use_cp(win,cpLIT);
X	wmove(win,y + 1,x);
X  	waddstr(win,"File table ");
X	wmove(win,y + 2,x);
X  	waddstr(win,"Inode table");
X	wmove(win,y + 3,x);
X	waddstr(win,"Lock table ");
X	wmove(win,y + 4,x);
X	waddstr(win,"Region table ");
X	wmove(win,y + 5,x);
X	waddstr(win,"Callout table ");
X
X}	/* end of draw_table_literals */
SHAR_EOF
# ============= det_wd.c ==============
echo "x - extracting det_wd.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > det_wd.c &&
X#ifdef SCO322
X/*+-------------------------------------------------------------------------
X	det_wd.c - UNIX V/386 system monitor WD disk controller usage detail
X	martin@hppcmart.grenoble.hp.com
X
X00000000001111111111222222222233333333334444444444555555555566666666667777777777
X01234567890123456789012345678901234567890123456789012345678901234567890123456789
XDevice  Av Q  r+w/s Blks/s -- (% Utilization) ----------------------------------
X######  ##### ##### #####  ##################################################### 
X  Defined functions:
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:08-01-1991-23:34-wht@n4hgf-release 3.40 source control point */
X/*:02-07-1991-13:30-martin@hppcmart-creation */
X
X#define M_TERMINFO
X
X#include <curses.h>
X#include <panel.h>
X#include <string.h>
X#include <nlist.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <sys/ascii.h>
X#include <sys/var.h>
X#undef NGROUPS_MAX
X#undef NULL
X#include <sys/param.h>
X#include <sys/elog.h>
X
X#include "nlsym.h"
X#include "libkmem.h"
X#include "libmem.h"
X#include "libswap.h"
X#include "libnlsym.h"
X#include "u386mon.h"
X
Xextern struct var v;
X
X/* WD Driver */
X#define NCTLR		2
X#define NWD			2
X#define NWDTOTAL	NCTLR*NWD
X/* Floppy drives */
X#define NDRIVES		4
X	
Xstatic int max_util[NWDTOTAL+NDRIVES];
Xstatic struct 	iotime	ia[NWDTOTAL+NDRIVES],ialast[NWDTOTAL+NDRIVES];
Xstatic time_t 	timelast,now;
X/*+----------------------------------------------------------------------------
X	init_wd();
X	Get initial drive stats.
X-----------------------------------------------------------------------------*/
Xvoid
Xinit_wd()
X{
X	register i;
X
X	(void)time(&timelast);
X	for(i=0;i<(NWDTOTAL+NDRIVES);i++)
X		max_util[i]=0;
X	kread((caddr_t) ialast,wd1010statsaddr,sizeof(struct iotime) * NCTLR * NWD);
X	kread((caddr_t) &ialast[NWDTOTAL],flstatsaddr,sizeof(struct iotime) * NDRIVES);
X}
X
X/*+----------------------------------------------------------------------------
X	draw_wd_literals(win, y, x);
X
X00000000001111111111222222222233333333334444444444555555555566666666667777777777
X01234567890123456789012345678901234567890123456789012345678901234567890123456789
XDevice  Jobs/s r+w/s Blks/s -- (% Utilization) ---------------------------------
X######   ##### ##### #####  ####################################################
X%wd##
X%fd##
X-----------------------------------------------------------------------------*/
X
Xvoid
Xdraw_wd_literals(win,y,x)
XWINDOW *win;
Xint y,x;
X
X{
X	static char *header = 
X"Device  Jobs/s r+w/s Blks/s -- (% Utilization) ";
X	int x2,ctlr,drive;
X
X	wmove(win,y,x);
X	use_cp(win,cpBANNER);
X	waddstr(win,header);
X	getyx(win,y,x2);
X	while(x2++ <= COLS)
X		waddch(win,(chtype)'-');
X	use_cp(win,cpLIT);
X	clear_area(win,getmaxy(win)-1,0,getmaxx(win));
X	for(ctlr=0; ctlr<NCTLR; ctlr++) {
X		for(drive=0; drive<NWD; drive++) {
X			mvwprintw(win,(y+(ctlr*NWD)+drive+1),x,"wd%1d%1d",ctlr,drive);
X		}
X	}
X	getyx(win,y,x2);
X	for(drive=0; drive<NDRIVES; drive++)
X		mvwprintw(win,(y+drive+1),x,"fd%1d",drive);
X} 
X
X/*+----------------------------------------------------------------------------
X	update_wd(win, y, x, width);
X
X00000000001111111111222222222233333333334444444444555555555566666666667777777777
X01234567890123456789012345678901234567890123456789012345678901234567890123456789
Xobs/s r+w/s Blks/s -- (% Utilization) ---------------------------------
X##### ##### #####  ####################################################
X-----------------------------------------------------------------------------*/
X#define _WD_AQ	0
X#define _WD_RW	6
X#define _WD_BK	12
X#define _WD_UT	19
X
Xvoid
Xupdate_wd(win,y,x,width)
XWINDOW *win;
Xint y,x;
Xint width;
X
X{
X	register i;
X	time_t elapsed_secs;
X	int itmp;
X	int percent_used;
X/*
X	int max;
X*/
X
X	(void)time(&now);
X	elapsed_secs=now-timelast;
X	kread((caddr_t) ia,wd1010statsaddr,sizeof(struct iotime) * NCTLR * NWD);
X	kread((caddr_t) &ia[NWDTOTAL],flstatsaddr,
X			sizeof(struct iotime) * NDRIVES);
X	for(i=0; i<(NWDTOTAL+NDRIVES);i++) {
X		use_cp(win,cpINFO);
X		mvwprintw(win,y+i,_WD_AQ+x,"%5i",
X			(ia[i].io_qc-ialast[i].io_qc));
X		mvwprintw(win,y+i,_WD_RW+x,"%5i",
X			(ia[i].io_cnt-ialast[i].io_cnt));
X		itmp = ia[i].io_bcnt-ialast[i].io_bcnt;
X		mvwprintw(win,y+i,_WD_BK+x,"%5i",
X			(itmp > 99999) ? 99999 : itmp);	/* protect transient overflow */
X		wmove(win,y+i,_WD_UT+x);
X		percent_used=(ia[i].io_act-ialast[i].io_act);
X		wprintw(win,"%5i",(percent_used > 99999) ? 99999 : percent_used);
X/*
X		max_util[i]=max_util[i]<percent_used ? percent_used : max_util[i];
X		if(percent_used < 70)
X			use_cp(win, cpLOW);
X		else if (percent_used < 90)
X			use_cp(win, cpMED);
X		else
X			use_cp(win, cpHIGH);
X
X		itmp = (width * percent_used) / 100;
X		max = (width * max_util[i]) / 100;
X		while(-1) {
X			itmp--;max--;
X			if (max<1) {
X				use_cp(win, cpHIGH);
X				waddch(win, (chtype)'M');
X				break;
X			}
X			if (itmp>-1)
X				waddch(win, (chtype)'-');
X			else
X				waddch(win, (chtype)' ');
X		}
X
X		wclrtoeol(win);
X*/
X	}
X	memcpy((char *)ialast,(char *)ia,
X		sizeof(struct iotime) * (NWDTOTAL + NDRIVES));
X	timelast=now;
X}
X#endif
SHAR_EOF
# ============= detail.c ==============
echo "x - extracting detail.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > detail.c &&
X/*+-------------------------------------------------------------------------
X	detail.c - UNIX 386 system monitor detail window
X
X  Defined functions:
X	detail_init()
X	detail_panel_cmd(cmd)
X	detail_panel_update()
X	detpanel_destroy()
X	detpanel_extra_init()
X	detpanel_extra_update()
X	detpanel_ps_init(full43)
X	detpanel_ps_update()
X	detpanel_sio_init()
X	detpanel_sio_update()
X	detpanel_streams_init()
X	detpanel_streams_update()
X	detpanel_table_init()
X	detpanel_table_update()
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:08-01-1991-23:34-wht@n4hgf-release 3.40 source control point */
X/*:05-15-1991-17:22-wht@n4hgf-2.3 patches for SVR31 from nba@sysware.dk */
X/*:04-16-1991-16:51-martin@hppcmart-Fix display problems */
X/*:04-16-1991-02:24-martin@hppcmart-additions for SCO 3.2.2 */
X/*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */
X/*:08-07-1990-14:24-wht@n4hgf-nba@sysware.dk SVR31 updates */
X/*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */
X/*:07-28-1990-18:06-wht@n4hgf-2.10 release */
X/*:07-10-1990-14:53-root@n4hgf-clear msg line on detail cmd - fix 24-line bug */
X/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */
X/*:06-25-1990-17:34-wht@n4hgf-add detail extra for 25 line tubes */
X/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */
X/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */
X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */
X/*:06-15-1990-18:32-wht@n4hgf-creation */
X
X#include "config.h"
X#define M_TERMINFO
X#include <curses.h>
X#undef timeout /* conflict in curses.h and bootinfo.h per trb@ima.ima.isc.com */
X#undef reg     /* per nba@sysware.dk */
X#ifdef NATIVE_PANELS
X# include <panel.h>
X#else
X# include "libpanel.h"
X#endif
X#include <signal.h>
X#include <string.h>
X#include <fcntl.h>
X#include <nlist.h>
X#include <errno.h>
X#include <time.h>
X#include <pwd.h>
X#include <sys/types.h>
X#include <utmp.h>
X#include <sys/utsname.h>
X#include <sys/stat.h>
X#undef NGROUPS_MAX
X#undef NULL
X#include <sys/param.h>
X#include <sys/tuneable.h>
X#include <sys/sysinfo.h>
X#include <sys/sysmacros.h>
X#include <sys/immu.h>
X#include <sys/region.h>
X#if defined(mips)
X#include <sys/sbd.h>
X#endif
X#include <sys/proc.h>
X#include <sys/var.h>
X
X#include "nlsym.h"
X#include "libkmem.h"
X#include "libnlsym.h"
X#include "u386mon.h"
X
X#define DPT_NONE		0
X#define DPT_PS			1
X#define DPT_PS_LONG		2
X#define DPT_EXTRA		3
X#define DPT_SIO			4
X#define DPT_STREAMS		5
X#define DPT_TABLE		6
X#define DPT_WD			7
X
XPANEL *mkpanel();
X
Xextern PANEL *pscr;
Xextern WINDOW *wscr;
X
XPANEL *pdet;
XWINDOW *wdet = (WINDOW *)0;
Xu_char detpanel_type = DPT_NONE;
Xint detpanel_length;
Xint detpanel_cols;
X
X/*+-------------------------------------------------------------------------
X	detpanel_ps_init(full43)
X--------------------------------------------------------------------------*/
Xvoid
Xdetpanel_ps_init(full43)
Xint full43;
X{
X/*
X#define DETAIL_PS_COLS ((LINES >= 43) ? EXTRA4_TLX - 1 : PER_SEC4_TLX)
Xdetpanel_cols = DETAIL_PS_COLS;
X*/
X
X#define DETAIL_PS_TLY ((LINES >= 43) ? ((full43)?PER_SEC_TLY:PER_SEC_TLY+14)\
X                                     : PER_SEC_TLY)
X
X#define DETAIL_PS_LENGTH		(MSG_TLY - DETAIL_PS_TLY)
X
X	detpanel_length = DETAIL_PS_LENGTH;
X	detpanel_cols = COLS;
X	if(!(pdet = mkpanel(detpanel_length,detpanel_cols,DETAIL_PS_TLY,0,"ps")))
X	{
X		leave_text("cannot make detail panel",1);
X	}
X	show_panel(pdet);
X	top_panel(pdet);
X	wdet = panel_window(pdet);
X	display_proc_stats(wdet,1);
X
X}	/* end of detpanel_ps_init */
X
X/*+-------------------------------------------------------------------------
X	detpanel_ps_update()
X--------------------------------------------------------------------------*/
Xvoid
Xdetpanel_ps_update()
X{
X	display_proc_stats(wdet,0);
X}	/* end of detpanel_ps_update */
X
X/*+-------------------------------------------------------------------------
X	detpanel_extra_init()
X--------------------------------------------------------------------------*/
Xvoid
Xdetpanel_extra_init()
X{
X#define DETAIL_EXTRA_TLY		PER_SEC_TLY
X#define DETAIL_EXTRA_LENGTH		(CMD_TLY - DETAIL_EXTRA_TLY)
X
X	detpanel_length = DETAIL_EXTRA_LENGTH;
X	detpanel_cols = COLS;
X	if(!(pdet = mkpanel(detpanel_length,detpanel_cols,DETAIL_EXTRA_TLY,0,"ex")))
X	{
X		leave_text("cannot make detail panel",1);
X	}
X	show_panel(pdet);
X	top_panel(pdet);
X	wdet = panel_window(pdet);
X	display_var(wdet,0,EXTRA1_TLX);
X#if defined(HAS_BOOTINFO)
X	display_bootinfo(wdet,0,EXTRA2_TLX);
X#endif
X	display_tune(wdet,0,EXTRA3_TLX);
X	display_proc(wdet,0,EXTRA4_TLX);
X
X}	/* end of detpanel_extra_init */
X
X/*+-------------------------------------------------------------------------
X	detpanel_extra_update()
X--------------------------------------------------------------------------*/
Xvoid
Xdetpanel_extra_update()
X{
X	display_proc(wdet,0,EXTRA4_TLX);
X}	/* end of detpanel_extra_update */
X
X/*+-------------------------------------------------------------------------
X	detpanel_streams_init()
X	SCO only streams stats
X--------------------------------------------------------------------------*/
X#if defined(M_UNIX) || defined(SVR31)
Xvoid
Xdetpanel_streams_init()
X{
X#define DETAIL_STREAMS_TLY ((LINES >= 43) ? (PER_SEC_TLY+14) : PER_SEC_TLY)
X#define DETAIL_STREAMS_LENGTH		(CMD_TLY - DETAIL_STREAMS_TLY)
X
X	detpanel_length = DETAIL_STREAMS_LENGTH;
X	detpanel_cols = COLS;
X	if(!(pdet = mkpanel(detpanel_length,detpanel_cols,
X		DETAIL_STREAMS_TLY,0,"str")))
X	{
X		leave_text("cannot make detail panel",1);
X	}
X	show_panel(pdet);
X	top_panel(pdet);
X	wdet = panel_window(pdet);
X	draw_streamscale_literals(wdet, 0, 0);
X	update_streamscale(wdet, 1, 21, 79-39);
X}	/* end of detpanel_streams_init */
X
X/*+-------------------------------------------------------------------------
X	detpanel_streams_update()
X--------------------------------------------------------------------------*/
X
Xvoid
Xdetpanel_streams_update()
X{
X	update_streamscale(wdet, 1, 21, 79-39);
X}	/* end of detpanel_streams_update */
X#endif
X
X/*+-------------------------------------------------------------------------
X	detpanel_wd_init()
X	SCO 3.2.2 only WD Disk stats
X--------------------------------------------------------------------------*/
X#if defined(M_UNIX) && defined(SCO322)
Xvoid
Xdetpanel_wd_init()
X{
X#define DETAIL_WD_TLY ((LINES >= 43) ? (PER_SEC_TLY + 14) : PER_SEC_TLY)
X#define DETAIL_WD_LENGTH		(CMD_TLY - DETAIL_WD_TLY)
X
X	detpanel_length = DETAIL_WD_LENGTH;
X	detpanel_cols = COLS;
X	if(!(pdet = mkpanel(detpanel_length,detpanel_cols,DETAIL_WD_TLY,0,"str")))
X	{
X		leave_text("cannot make detail panel",1);
X	}
X	show_panel(pdet);
X	top_panel(pdet);
X	wdet = panel_window(pdet);
X	draw_wd_literals(wdet, 0, 0);
X	update_wd(wdet, 1, 9, 79-28);
X}	/* end of detpanel_wd_init */
X#endif
X/*+-------------------------------------------------------------------------
X	detpanel_wd_update()
X--------------------------------------------------------------------------*/
X#if defined(M_UNIX) && defined(SCO322)
Xvoid
Xdetpanel_wd_update()
X{
X	update_wd(wdet, 1, 9, 79-28);
X}	/* end of detpanel_wd_update */
X#endif
X
X/*+-------------------------------------------------------------------------
X	detpanel_table_init()
X	SCO only table stats
X--------------------------------------------------------------------------*/
X#if defined(M_UNIX) || defined(SVR31)
Xvoid
Xdetpanel_table_init()
X{
X#define DETAIL_TABLE_TLY ((LINES >= 43) ? (PER_SEC_TLY+14) : PER_SEC_TLY)
X#define DETAIL_TABLE_LENGTH		(CMD_TLY - DETAIL_TABLE_TLY)
X
X	detpanel_length = DETAIL_TABLE_LENGTH;
X	detpanel_cols = COLS;
X	if(!(pdet = mkpanel(detpanel_length,detpanel_cols,DETAIL_TABLE_TLY,0,"tab")))
X	{
X		leave_text("cannot make detail panel",1);
X	}
X	show_panel(pdet);
X	top_panel(pdet);
X	wdet = panel_window(pdet);
X	draw_table_literals(wdet, 0, 0);
X	update_table(wdet, 1, 15, 79-32);
X}	/* end of detpanel_table_init */
X
X/*+-------------------------------------------------------------------------
X	detpanel_table_update()
X--------------------------------------------------------------------------*/
X
Xvoid
Xdetpanel_table_update()
X{
X	update_table(wdet, 1, 15, 79-32);
X}	/* end of detpanel_table_update */
X#endif
X
X
X/*+-------------------------------------------------------------------------
X	detpanel_sio_init() - SCO only serial I/O display
X--------------------------------------------------------------------------*/
X#if defined(M_UNIX)
Xvoid
Xdetpanel_sio_init()
X{
X#define DETAIL_SIO_TLY ((LINES >= 43) ? (PER_SEC_TLY+14) : PER_SEC_TLY)
X#define DETAIL_SIO_LENGTH		(CMD_TLY - DETAIL_SIO_TLY)
X
X	detpanel_length = DETAIL_SIO_LENGTH;
X	detpanel_cols = COLS;
X	if(!(pdet = mkpanel(detpanel_length,detpanel_cols,DETAIL_SIO_TLY,0,"sio")))
X	{
X		leave_text("cannot make detail panel",1);
X	}
X	show_panel(pdet);
X	top_panel(pdet);
X	wdet = panel_window(pdet);
X	display_sio_summary(wdet,1);
X}	/* end of detpanel_sio_init */
X#endif
X
X/*+-------------------------------------------------------------------------
X	detpanel_sio_update()
X--------------------------------------------------------------------------*/
X#if defined(M_UNIX)
Xvoid
Xdetpanel_sio_update()
X{
X	display_sio_summary(wdet,0);
X}	/* end of detpanel_sio_update */
X#endif
X
X/*+-------------------------------------------------------------------------
X	detpanel_destroy()
X--------------------------------------------------------------------------*/
Xvoid
Xdetpanel_destroy()
X{
X	hide_panel(pdet);
X	delwin(wdet);
X	wdet = (WINDOW *)0;
X	del_panel(pdet);
X	top_panel(pscr);
X	disp_msg(cpINFO,"");
X	detpanel_type = DPT_NONE;
X}	/* end of detpanel_destroy */
X
X/*+-------------------------------------------------------------------------
X	detail_panel_cmd(cmd)
X
X  command: m main screen
X           p proc status
X--------------------------------------------------------------------------*/
Xvoid
Xdetail_panel_cmd(cmd)
Xchtype cmd;
X{
X	disp_msg(cpINFO,"");
X	switch(cmd)
X	{
X		case 'm':
X			if(detpanel_type != DPT_NONE)
X				detpanel_destroy();
X			break;
X
X		case 'P':
X			if(detpanel_type == DPT_PS_LONG)
X				break;
X			if(detpanel_type != DPT_NONE)
X				detpanel_destroy();
X			detpanel_ps_init(1);
X			detpanel_type = DPT_PS_LONG;
X			break;
X
X		case 'p':
X			if(detpanel_type == DPT_PS)
X				break;
X			if(detpanel_type != DPT_NONE)
X				detpanel_destroy();
X			detpanel_ps_init(0);
X			detpanel_type = DPT_PS;
X			break;
X
X		case 'e':
X			if(LINES >= 43)
X				break;
X			if(detpanel_type == DPT_EXTRA)
X				break;
X			if(detpanel_type != DPT_NONE)
X				detpanel_destroy();
X			detpanel_extra_init();
X			detpanel_type = DPT_EXTRA;
X			break;
X
X#if defined(M_UNIX) || defined(SVR31)
X		case 'n':
X			if(detpanel_type == DPT_STREAMS)
X				break;
X			if(detpanel_type != DPT_NONE)
X				detpanel_destroy();
X			detpanel_streams_init();
X			detpanel_type = DPT_STREAMS;
X			break;
X		case 't':
X			if(detpanel_type == DPT_TABLE)
X				break;
X			if(detpanel_type != DPT_NONE)
X				detpanel_destroy();
X			detpanel_table_init();
X			detpanel_type = DPT_TABLE;
X			break;
X#endif
SHAR_EOF
echo "End of  part 3"
echo "File detail.c is continued in part 4"
echo "4" > shar3_seq_.tmp
exit 0
Newsgroups: biz.sco.sources