* Copyright (c) 1983 Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Edward Wang at The University of California, Berkeley.
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)lcmd2.c 3.23 (Berkeley) 6/17/90";
#include <sys/resource.h>
if ((w
= openiwin(16, "IO Statistics")) == 0) {
error("Can't open statistics window: %s.", wwerror());
wwprintf(w
, "ttflush\twrite\terror\tzero\tchar\n");
wwprintf(w
, "%d\t%d\t%d\t%d\t%d\n",
wwnflush
, wwnwr
, wwnwre
, wwnwrz
, wwnwrc
);
wwprintf(w
, "token\tuse\tbad\tsaving\ttotal\tbaud\n");
wwprintf(w
, "%d\t%d\t%d\t%d\t%d\t%d/%d (%.1f/%.1f)\n",
wwntokdef
, wwntokuse
, wwntokbad
, wwntoksave
, wwntokc
,
(int) ((float) wwbaud
* wwntokc
/
(wwntokc
- wwntoksave
)) :
wwnwrc
? (int) ((float) wwbaud
* (wwnwrc
+ wwntoksave
) /
(float) wwntokc
/ (wwntokc
- wwntoksave
) : 1.0,
wwnwrc
? (float) (wwnwrc
+ wwntoksave
) / wwnwrc
: 1.0);
wwprintf(w
, "wwwrite\tattempt\tchar\n");
wwprintf(w
, "%d\t%d\t%d\n",
wwnwwr
, wwnwwra
, wwnwwrc
);
wwprintf(w
, "wwupdat\tline\tmiss\tscan\tclreol\tclreos\tmiss\tline\n");
wwprintf(w
, "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
wwnupdate
, wwnupdline
, wwnupdmiss
, wwnupdscan
, wwnupdclreol
,
wwnupdclreos
, wwnupdclreosmiss
, wwnupdclreosline
);
wwprintf(w
, "select\terror\tzero\n");
wwprintf(w
, "%d\t%d\t%d\n",
wwnselect
, wwnselecte
, wwnselectz
);
wwprintf(w
, "read\terror\tzero\tchar\n");
wwprintf(w
, "%d\t%d\t%d\t%d\n",
wwnread
, wwnreade
, wwnreadz
, wwnreadc
);
wwprintf(w
, "ptyread\terror\tzero\tcontrol\tdata\tchar\n");
wwprintf(w
, "%d\t%d\t%d\t%d\t%d\t%d\n",
wwnwread
, wwnwreade
, wwnwreadz
,
wwnwreadp
, wwnwreadd
, wwnwreadc
);
struct lcmd_arg arg_time
[] = {
register struct value
*a
;
if ((w
= openiwin(8, "Timing and Resource Usage")) == 0) {
error("Can't open time window: %s.", wwerror());
(void) gettimeofday(&timeval
, (struct timezone
*)0);
timeval
.tv_sec
-= starttime
.tv_sec
;
if ((timeval
.tv_usec
-= starttime
.tv_usec
) < 0) {
timeval
.tv_usec
+= 1000000;
(void) getrusage(a
->v_type
== V_STR
&& str_match(a
->v_str
, "children", 1)
? RUSAGE_CHILDREN
: RUSAGE_SELF
, &rusage
);
wwprintf(w
, "%-15s %-15s %-15s\n",
"time", "utime", "stime");
wwprintf(w
, "%-15s ", strtime(&timeval
));
wwprintf(w
, "%-15s ", strtime(&rusage
.ru_utime
));
wwprintf(w
, "%-15s\n", strtime(&rusage
.ru_stime
));
wwprintf(w
, "%-15s %-15s %-15s %-15s\n",
"maxrss", "ixrss", "idrss", "isrss");
wwprintf(w
, "%-15ld %-15ld %-15ld %-15ld\n",
rusage
.ru_maxrss
, rusage
.ru_ixrss
,
rusage
.ru_idrss
, rusage
.ru_isrss
);
wwprintf(w
, "%-7s %-7s %-7s %-7s %-7s %-7s %-7s %-7s %-7s %-7s\n",
"minflt", "majflt", "nswap", "inblk", "oublk",
"msgsnd", "msgrcv", "nsigs", "nvcsw", "nivcsw");
wwprintf(w
, "%-7ld %-7ld %-7ld %-7ld %-7ld %-7ld %-7ld %-7ld %-7ld %-7ld\n",
rusage
.ru_minflt
, rusage
.ru_majflt
, rusage
.ru_nswap
,
rusage
.ru_inblock
, rusage
.ru_oublock
,
rusage
.ru_msgsnd
, rusage
.ru_msgrcv
, rusage
.ru_nsignals
,
rusage
.ru_nvcsw
, rusage
.ru_nivcsw
);
register struct timeval
*t
;
(void) sprintf(p
, "%ld:", t
->tv_sec
/ (60*60));
(void) sprintf(p
, fill
? "%02ld:" : "%ld:", t
->tv_sec
/ 60);
(void) sprintf(p
, fill
? "%02ld.%02d" : "%ld.%02ld",
t
->tv_sec
, t
->tv_usec
/ 10000);
register struct ww
*w
, *wp
;
for (n
= 0, i
= 0; i
< NWINDOW
; i
++)
if ((w
= openiwin(n
+ 2, "Windows")) == 0) {
error("Can't open listing window: %s.", wwerror());
for (i
= 0; i
< NWINDOW
; i
++) {
if ((wp
= window
[i
]) == 0)
wwprintf(w
, "%c %c %-13s %-.*s\n",
wp
== selwin
? '+' : (wp
== lastselwin
? '-' : ' '),
wp
->ww_state
== WWS_HASPROC
? "" : "(No process)",
wp
->ww_label
? wp
->ww_label
: "(No label)");
if ((w
= openiwin(wwnrow
- 3, "Variables")) == 0) {
error("Can't open variable window: %s.", wwerror());
if (var_walk(printvar
, (int)w
) >= 0)
wwprintf(w
, "%16s ", r
->r_name
);
switch (r
->r_val
.v_type
) {
wwprintf(w
, "%s\n", r
->r_val
.v_str
);
wwprintf(w
, "%d\n", r
->r_val
.v_num
);
struct lcmd_arg arg_def_shell
[] = {
{ "", 0, ARG_ANY
|ARG_LIST
},
register struct value
*vp
;
if (a
->v_type
== V_ERR
) {
if ((v
->v_str
= str_cpy(default_shellfile
)) != 0)
if (v
->v_str
= default_shellfile
) {
for (pp
= default_shell
+ 1; *pp
; pp
++) {
for (pp
= default_shell
, vp
= a
;
pp
< &default_shell
[sizeof default_shell
/sizeof *default_shell
-1];
if ((*pp
= vp
->v_type
== V_STR
?
str_cpy(vp
->v_str
) : str_itoa(vp
->v_num
)) == 0) {
/* just leave default_shell[] the way it is */
if (default_shellfile
= *default_shell
)
if (*default_shell
= rindex(default_shellfile
, '/'))
*default_shell
= default_shellfile
;
struct lcmd_arg arg_alias
[] = {
{ "", 0, ARG_STR
|ARG_LIST
},
if (a
->v_type
== V_ERR
) {
if ((w
= openiwin(wwnrow
- 3, "Aliases")) == 0) {
error("Can't open alias window: %s.", wwerror());
if (alias_walk(printalias
, (int)w
) >= 0)
register struct alias
*ap
= 0;
if (ap
= alias_lookup(a
->v_str
)) {
if ((v
->v_str
= str_cpy(ap
->a_buf
)) == 0) {
if (a
[1].v_type
== V_STR
) {
register struct value
*vp
;
for (n
= 0, vp
= a
+ 1; vp
->v_type
!= V_ERR
; vp
++, n
++)
for (p
= vp
->v_str
; *p
; p
++, n
++)
if ((str
= str_alloc(n
)) == 0) {
for (q
= str
, vp
= a
+ 1; vp
->v_type
!= V_ERR
;
for (p
= vp
->v_str
; *q
++ = *p
++;)
if ((ap
= alias_set(a
[0].v_str
, (char *)0)) == 0) {
register struct alias
*a
;
wwprintf(w
, "%16s %s\n", a
->a_name
, a
->a_buf
);
struct lcmd_arg arg_unalias
[] = {
if (a
->v_type
== ARG_STR
)
v
->v_num
= alias_unset(a
->v_str
);
struct lcmd_arg arg_echo
[] = {
{ "window", 1, ARG_NUM
},
{ "", 0, ARG_ANY
|ARG_LIST
},
register struct value
*a
;
if ((w
= vtowin(a
++, selwin
)) == 0)
while (a
->v_type
!= V_ERR
) {
if (a
->v_type
== V_NUM
) {
(void) sprintf(buf
, "%d", a
->v_num
);
(void) wwwrite(w
, buf
, strlen(buf
));
(void) wwwrite(w
, a
->v_str
, strlen(a
->v_str
));
if ((++a
)->v_type
!= V_ERR
)
(void) wwwrite(w
, " ", 1);
(void) wwwrite(w
, "\r\n", 2);