Changeset View
Changeset View
Standalone View
Standalone View
contrib/top/display.c
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
/* buffer of proc information lines for display updating */ | /* buffer of proc information lines for display updating */ | ||||
char *screenbuf = NULL; | char *screenbuf = NULL; | ||||
static char **procstate_names; | static char **procstate_names; | ||||
static char **cpustate_names; | static char **cpustate_names; | ||||
static char **memory_names; | static char **memory_names; | ||||
static char **arc_names; | static char **arc_names; | ||||
static char **carc_names; | |||||
static char **swap_names; | static char **swap_names; | ||||
static int num_procstates; | static int num_procstates; | ||||
static int num_cpustates; | static int num_cpustates; | ||||
static int num_memory; | static int num_memory; | ||||
static int num_swap; | static int num_swap; | ||||
static int *lprocstates; | static int *lprocstates; | ||||
Show All 20 Lines | |||||
int x_procstate = 0; | int x_procstate = 0; | ||||
int y_procstate = 1; | int y_procstate = 1; | ||||
int x_brkdn = 15; | int x_brkdn = 15; | ||||
int y_brkdn = 1; | int y_brkdn = 1; | ||||
int x_mem = 5; | int x_mem = 5; | ||||
int y_mem = 3; | int y_mem = 3; | ||||
int x_arc = 5; | int x_arc = 5; | ||||
int y_arc = 4; | int y_arc = 4; | ||||
int x_carc = 16; | |||||
int y_carc = 5; | |||||
int x_swap = 6; | int x_swap = 6; | ||||
int y_swap = 4; | int y_swap = 4; | ||||
int y_message = 5; | int y_message = 5; | ||||
int x_header = 0; | int x_header = 0; | ||||
int y_header = 6; | int y_header = 6; | ||||
int x_idlecursor = 0; | int x_idlecursor = 0; | ||||
int y_idlecursor = 5; | int y_idlecursor = 5; | ||||
int y_procs = 7; | int y_procs = 7; | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | struct statics *statics; | ||||
lcpustates = (int *)malloc(num_cpustates * sizeof(int) * statics->ncpus); | lcpustates = (int *)malloc(num_cpustates * sizeof(int) * statics->ncpus); | ||||
cpustate_columns = (int *)malloc(num_cpustates * sizeof(int)); | cpustate_columns = (int *)malloc(num_cpustates * sizeof(int)); | ||||
memory_names = statics->memory_names; | memory_names = statics->memory_names; | ||||
num_memory = string_count(memory_names); | num_memory = string_count(memory_names); | ||||
lmemory = (int *)malloc(num_memory * sizeof(int)); | lmemory = (int *)malloc(num_memory * sizeof(int)); | ||||
arc_names = statics->arc_names; | arc_names = statics->arc_names; | ||||
carc_names = statics->carc_names; | |||||
/* calculate starting columns where needed */ | /* calculate starting columns where needed */ | ||||
cpustate_total_length = 0; | cpustate_total_length = 0; | ||||
pp = cpustate_names; | pp = cpustate_names; | ||||
ip = cpustate_columns; | ip = cpustate_columns; | ||||
while (*pp != NULL) | while (*pp != NULL) | ||||
{ | { | ||||
*ip++ = cpustate_total_length; | *ip++ = cpustate_total_length; | ||||
▲ Show 20 Lines • Show All 446 Lines • ▼ Show 20 Lines | int *stats; | ||||
if (arc_names == NULL) | if (arc_names == NULL) | ||||
return; | return; | ||||
/* format the new line */ | /* format the new line */ | ||||
summary_format(new, stats, arc_names); | summary_format(new, stats, arc_names); | ||||
line_update(arc_buffer, new, x_arc, y_arc); | line_update(arc_buffer, new, x_arc, y_arc); | ||||
} | } | ||||
/* | /* | ||||
* *_carc(stats) - print "Compressed ARC: " followed by the summary string | |||||
* | |||||
* Assumptions: cursor is on "lastline" | |||||
* for i_carc ONLY: cursor is on the previous line | |||||
*/ | |||||
char carc_buffer[MAX_COLS]; | |||||
void | |||||
i_carc(stats) | |||||
int *stats; | |||||
{ | |||||
if (carc_names == NULL) | |||||
return; | |||||
fputs("\nCompressed ARC: ", stdout); | |||||
lastline++; | |||||
/* format and print the memory summary */ | |||||
summary_format(carc_buffer, stats, carc_names); | |||||
fputs(carc_buffer, stdout); | |||||
} | |||||
void | |||||
u_carc(stats) | |||||
int *stats; | |||||
{ | |||||
static char new[MAX_COLS]; | |||||
if (carc_names == NULL) | |||||
return; | |||||
/* format the new line */ | |||||
summary_format(new, stats, carc_names); | |||||
line_update(carc_buffer, new, x_carc, y_carc); | |||||
} | |||||
/* | |||||
* *_swap(stats) - print "Swap: " followed by the swap summary string | * *_swap(stats) - print "Swap: " followed by the swap summary string | ||||
* | * | ||||
* Assumptions: cursor is on "lastline" | * Assumptions: cursor is on "lastline" | ||||
* for i_swap ONLY: cursor is on the previous line | * for i_swap ONLY: cursor is on the previous line | ||||
*/ | */ | ||||
char swap_buffer[MAX_COLS]; | char swap_buffer[MAX_COLS]; | ||||
▲ Show 20 Lines • Show All 472 Lines • ▼ Show 20 Lines | |||||
int *numbers; | int *numbers; | ||||
register char **names; | register char **names; | ||||
{ | { | ||||
register char *p; | register char *p; | ||||
register int num; | register int num; | ||||
register char *thisname; | register char *thisname; | ||||
register int useM = No; | register int useM = No; | ||||
char rbuf[6]; | |||||
/* format each number followed by its string */ | /* format each number followed by its string */ | ||||
p = str; | p = str; | ||||
while ((thisname = *names++) != NULL) | while ((thisname = *names++) != NULL) | ||||
{ | { | ||||
/* get the number to format */ | /* get the number to format */ | ||||
num = *numbers++; | num = *numbers++; | ||||
/* display only non-zero numbers */ | /* display only non-zero numbers */ | ||||
if (num > 0) | if (num > 0) | ||||
{ | { | ||||
/* is this number in kilobytes? */ | /* is this number in kilobytes? */ | ||||
if (thisname[0] == 'K') | if (thisname[0] == 'K') | ||||
{ | { | ||||
/* yes: format it as a memory value */ | /* yes: format it as a memory value */ | ||||
p = strecpy(p, format_k(num)); | p = strecpy(p, format_k(num)); | ||||
/* skip over the K, since it was included by format_k */ | /* skip over the K, since it was included by format_k */ | ||||
p = strecpy(p, thisname+1); | p = strecpy(p, thisname+1); | ||||
} | |||||
/* is this number a ratio? */ | |||||
else if (thisname[0] == ':') | |||||
{ | |||||
(void) snprintf(rbuf, sizeof(rbuf), "%.2f", | |||||
(float)*(numbers - 2) / (float)num); | |||||
p = strecpy(p, rbuf); | |||||
p = strecpy(p, thisname); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
p = strecpy(p, itoa(num)); | p = strecpy(p, itoa(num)); | ||||
p = strecpy(p, thisname); | p = strecpy(p, thisname); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 196 Lines • Show Last 20 Lines |