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