version 1.3, 1999/03/06 20:19:21 |
version 1.4, 1999/03/06 20:27:42 |
|
|
|
|
static char *cpustates_tag __P((void)); |
static char *cpustates_tag __P((void)); |
static int string_count __P((char **)); |
static int string_count __P((char **)); |
static void summary_format __P((char *, size_t, int *, char **)); |
static void summary_format __P((char *, int *, char **)); |
static void line_update __P((char *, char *, int, int)); |
static void line_update __P((char *, char *, int, int)); |
|
|
#define lineindex(l) ((l)*display_width) |
#define lineindex(l) ((l)*display_width) |
|
|
} |
} |
|
|
/* format and print the process state summary */ |
/* format and print the process state summary */ |
summary_format(procstates_buffer, sizeof(procstates_buffer), brkdn, |
summary_format(procstates_buffer, brkdn, procstate_names); |
procstate_names); |
|
fputs(procstates_buffer, stdout); |
fputs(procstates_buffer, stdout); |
|
|
/* save the numbers for next time */ |
/* save the numbers for next time */ |
|
|
if (memcmp(lprocstates, brkdn, num_procstates * sizeof(int)) != 0) |
if (memcmp(lprocstates, brkdn, num_procstates * sizeof(int)) != 0) |
{ |
{ |
/* format and update the line */ |
/* format and update the line */ |
summary_format(new, sizeof(new), brkdn, procstate_names); |
summary_format(new, brkdn, procstate_names); |
line_update(procstates_buffer, new, x_brkdn, y_brkdn); |
line_update(procstates_buffer, new, x_brkdn, y_brkdn); |
memcpy(lprocstates, brkdn, num_procstates * sizeof(int)); |
memcpy(lprocstates, brkdn, num_procstates * sizeof(int)); |
} |
} |
|
|
lastline++; |
lastline++; |
|
|
/* format and print the memory summary */ |
/* format and print the memory summary */ |
summary_format(memory_buffer, sizeof(memory_buffer), stats, memory_names); |
summary_format(memory_buffer, stats, memory_names); |
fputs(memory_buffer, stdout); |
fputs(memory_buffer, stdout); |
} |
} |
|
|
|
|
static char new[MAX_COLS]; |
static char new[MAX_COLS]; |
|
|
/* format the new line */ |
/* format the new line */ |
summary_format(new, sizeof(new), stats, memory_names); |
summary_format(new, stats, memory_names); |
line_update(memory_buffer, new, x_mem, y_mem); |
line_update(memory_buffer, new, x_mem, y_mem); |
} |
} |
|
|
|
|
return(cnt); |
return(cnt); |
} |
} |
|
|
static void summary_format(str, siz, numbers, names) |
static void summary_format(str, numbers, names) |
|
|
char *str; |
char *str; |
size_t siz; |
|
int *numbers; |
int *numbers; |
register char **names; |
register char **names; |
|
|
{ |
{ |
|
register char *p; |
register int num; |
register int num; |
register char *thisname; |
register char *thisname; |
|
|
if (siz == 0) |
|
return; |
|
|
|
/* format each number followed by its string */ |
/* format each number followed by its string */ |
*str = '\0'; |
p = str; |
while ((thisname = *names++) != NULL) |
while ((thisname = *names++) != NULL) |
{ |
{ |
/* get the number to format */ |
/* get the number to format */ |
|
|
if (thisname[0] == 'K') |
if (thisname[0] == 'K') |
{ |
{ |
/* yes: format it as a memory value */ |
/* yes: format it as a memory value */ |
strlcat(str, format_k(num), siz); |
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 */ |
strlcat(str, thisname+1, siz); |
p = strecpy(p, thisname+1); |
} |
} |
else |
else |
{ |
{ |
strlcat(str, itoa(num), siz); |
p = strecpy(p, itoa(num)); |
strlcat(str, thisname, siz); |
p = strecpy(p, thisname); |
} |
} |
} |
} |
|
|
/* ignore negative numbers, but display corresponding string */ |
/* ignore negative numbers, but display corresponding string */ |
else if (num < 0) |
else if (num < 0) |
{ |
{ |
strlcat(str, thisname, siz); |
p = strecpy(p, thisname); |
} |
} |
} |
} |
|
|
/* if the last two characters in the string are ", ", delete them */ |
/* if the last two characters in the string are ", ", delete them */ |
thisname = str + strlen(str) - 2; |
p -= 2; |
if (thisname >= str && thisname[0] == ',' && thisname[1] == ' ') |
if (p >= str && p[0] == ',' && p[1] == ' ') |
{ |
{ |
*thisname = '\0'; |
*p = '\0'; |
} |
} |
} |
} |
|
|