Home | History | Annotate | Line # | Download | only in systat
globalcmds.c revision 1.1
      1 /*	$NetBSD: globalcmds.c,v 1.1 1999/12/16 04:40:03 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()
     37 {
     38 	int col, len;
     39 	struct mode *p;
     40 
     41 	move(CMDLINE, col = 0);
     42 	for (p = modes; p->c_name; p++) {
     43 		len = strlen(p->c_name);
     44 		if (col + len > COLS)
     45 			break;
     46 		addstr(p->c_name); col += len;
     47 		if (col + 1 < COLS)
     48 			addch(' ');
     49 	}
     50 	clrtoeol();
     51 }
     52 
     53 void
     54 global_load()
     55 {
     56 	(void)getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0]));
     57 	mvprintw(CMDLINE, 0, "%4.1f %4.1f %4.1f",
     58 	    avenrun[0], avenrun[1], avenrun[2]);
     59 	clrtoeol();
     60 }
     61 
     62 void
     63 global_quit()
     64 {
     65 	die(0);
     66 }
     67 
     68 void
     69 global_stop()
     70 {
     71 	alarm(0);
     72 	mvaddstr(CMDLINE, 0, "Refresh disabled.");
     73 	clrtoeol();
     74 }
     75