globalcmds.c revision 1.3 1 /* $NetBSD: globalcmds.c,v 1.3 1999/12/16 06:16:17 jwise Exp $ */
2
3 /*-
4 * Copyright (c) 1980, 1992, 1993 Jim Wise
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28 #include <curses.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include "systat.h"
32 #include "extern.h"
33
34
35 void
36 global_help(args)
37 char *args;
38 {
39 int col, len;
40 struct mode *p;
41
42 move(CMDLINE, col = 0);
43 for (p = modes; p->c_name; p++) {
44 len = strlen(p->c_name);
45 if (col + len > COLS)
46 break;
47 addstr(p->c_name); col += len;
48 if (col + 1 < COLS)
49 addch(' ');
50 }
51 clrtoeol();
52 }
53
54 void
55 global_interval(args)
56 char *args;
57 {
58 int interval;
59
60 if (!args) {
61 interval = 5;
62 } else {
63 interval = atoi(args);
64 }
65
66 if (interval <= 0) {
67 error("%d: bad interval.", interval);
68 return;
69 }
70
71 alarm(0);
72 naptime = interval;
73 display(0);
74 status();
75 }
76
77
78 void
79 global_load(args)
80 char *args;
81 {
82 (void)getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0]));
83 mvprintw(CMDLINE, 0, "%4.1f %4.1f %4.1f",
84 avenrun[0], avenrun[1], avenrun[2]);
85 clrtoeol();
86 }
87
88 void
89 global_quit(args)
90 char *args;
91 {
92 die(0);
93 }
94
95 void
96 global_stop(args)
97 char *args;
98 {
99 alarm(0);
100 mvaddstr(CMDLINE, 0, "Refresh disabled.");
101 clrtoeol();
102 }
103