summaryrefslogtreecommitdiff
path: root/usr.bin/top/commands.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-05-29 00:56:57 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-05-29 00:56:57 +0000
commit32de456d0946e52c50edde609338d43b8387fd44 (patch)
treebfa5bfb624b4a84573dd1a8d473f0b6abf1b4c86 /usr.bin/top/commands.c
parentd7117e3a3eb409851b4bea2d7e0d8884ed8f3f16 (diff)
Instead of using hand-crafted redraws minimizing screen updates, use curses.
Enables nice things like process highlighting without hurting the brain. ok deraadt@
Diffstat (limited to 'usr.bin/top/commands.c')
-rw-r--r--usr.bin/top/commands.c72
1 files changed, 5 insertions, 67 deletions
diff --git a/usr.bin/top/commands.c b/usr.bin/top/commands.c
index c246d86e681..d2b85bcb87c 100644
--- a/usr.bin/top/commands.c
+++ b/usr.bin/top/commands.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commands.c,v 1.27 2007/02/23 13:31:45 millert Exp $ */
+/* $OpenBSD: commands.c,v 1.28 2007/05/29 00:56:56 otto Exp $ */
/*
* Top users/processes display for Unix
@@ -60,46 +60,6 @@ static size_t str_addarg(char *, size_t, char *, int);
static int err_compar(const void *, const void *);
/*
- * show_help() - display the help screen; invoked in response to
- * either 'h' or '?'.
- */
-void
-show_help(void)
-{
- printf("Top version %s, %s\n", version_string(), copyright);
- puts("These single-character commands are available:\n"
- "\n"
- "h | ? - help; show this text\n"
- "^L - redraw screen\n"
- "q - quit");
-
- /* not all commands are available with overstrike terminals */
- if (overstrike) {
- puts("\n"
- "Other commands are also available, but this terminal is not\n"
- "sophisticated enough to handle those commands gracefully.\n");
- } else {
- puts(
- "+ - reset any g, p, or u filters\n"
- "C - toggle the display of command line arguments\n"
- "d count - show `count' displays, then exit\n"
- "e - list errors generated by last \"kill\" or \"renice\" command\n"
- "g string - filter on command name (g+ selects all commands)\n"
- "I | i - toggle the display of idle processes\n"
- "k [-sig] pid - send signal `-sig' to process `pid'\n"
- "n|# count - show `count' processes\n"
- "o field - specify sort order (size, res, cpu, time, pri)\n"
- "p pid - display process by `pid' (p+ selects all processes)\n"
- "r count pid - renice process `pid' to nice value `count'\n"
- "S - toggle the display of system processes\n"
- "s time - change delay between displays to `time' seconds\n"
- "T - toggle the display of threads\n"
- "u user - display processes for `user' (u+ selects all users)\n"
- "\n");
- }
-}
-
-/*
* Utility routines that help with some of the commands.
*/
static char *
@@ -151,13 +111,8 @@ scanint(char *str, int *intp)
#define ERRMAX 20
-struct errs { /* structure for a system-call error */
- int err; /* value of errno (that is, the actual error) */
- char *arg; /* argument that caused the error */
-};
-
-static struct errs errs[ERRMAX];
-static int errcnt;
+struct errs errs[ERRMAX];
+int errcnt;
static char *err_toomany = " too many errors occurred";
static char *err_listem =
" Many errors occurred. Press `e' to display the list of errors.";
@@ -270,8 +225,8 @@ str_addarg(char *str, size_t len, char *arg, int first)
static int
err_compar(const void *e1, const void *e2)
{
- const struct errs *p1 = (struct errs *) e1;
- const struct errs *p2 = (struct errs *) e2;
+ const struct errs *p1 = (const struct errs *) e1;
+ const struct errs *p2 = (const struct errs *) e2;
int result;
if ((result = p1->err - p2->err) == 0)
@@ -289,23 +244,6 @@ error_count(void)
}
/*
- * show_errors() - display on stdout the current log of errors.
- */
-void
-show_errors(void)
-{
- struct errs *errp = errs;
- int cnt = 0;
-
- printf("%d error%s:\n\n", errcnt, errcnt == 1 ? "" : "s");
- while (cnt++ < errcnt) {
- printf("%5s: %s\n", errp->arg,
- errp->err == 0 ? "Not a number" : strerror(errp->err));
- errp++;
- }
-}
-
-/*
* kill_procs(str) - send signals to processes, much like the "kill"
* command does; invoked in response to 'k'.
*/