1108684Sphk/* 2108684Sphk * Copyright (c) 2003, Trent Nelson, <trent@arpa.com>. 3108684Sphk * All rights reserved. 4108684Sphk * 5108684Sphk * Redistribution and use in source and binary forms, with or without 6108684Sphk * modification, are permitted provided that the following conditions 7108684Sphk * are met: 8108684Sphk * 1. Redistributions of source code must retain the above copyright 9108684Sphk * notice, this list of conditions and the following disclaimer. 10108684Sphk * 2. Redistributions in binary form must reproduce the above copyright 11108684Sphk * notice, this list of conditions and the following disclaimer in the 12108684Sphk * documentation and/or other materials provided with the distribution. 13108684Sphk * 3. The name of the author may not be used to endorse or promote products 14108684Sphk * derived from this software without specific prior written permission. 15108684Sphk * 16108684Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17108684Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18108684Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19108684Sphk * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20108684Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21108684Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22108684Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23108684Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24108684Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25108684Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26108684Sphk * SUCH DAMAGE. 27108684Sphk * 28108684Sphk * $FreeBSD$ 29108684Sphk */ 30108684Sphk 31247036Smelifaro#include <sys/types.h> 32247036Smelifaro 33108684Sphk#include "systat.h" 34108684Sphk#include "extern.h" 35108684Sphk#include "convtbl.h" 36108684Sphk 37247036Smelifaro#include <stdlib.h> 38247036Smelifaro#include <string.h> 39247036Smelifaro 40164672Syarint curscale = SC_AUTO; 41247036Smelifarochar *matchline = NULL; 42247036Smelifaroint showpps = 0; 43247036Smelifaroint needsort = 0; 44108684Sphk 45108684Sphkint 46108684Sphkifcmd(const char *cmd, const char *args) 47108684Sphk{ 48164672Syar int scale; 49164669Syar 50126775Sdwmalone if (prefix(cmd, "scale")) { 51164672Syar if ((scale = get_scale(args)) != -1) 52164672Syar curscale = scale; 53108684Sphk else { 54108684Sphk move(CMDLINE, 0); 55108684Sphk clrtoeol(); 56164672Syar addstr("what scale? "); 57164672Syar addstr(get_helplist()); 58226396Sed } 59247036Smelifaro } else if (prefix(cmd, "match")) { 60247036Smelifaro if (args != NULL && *args != '\0' && memcmp(args, "*", 2) != 0) { 61247036Smelifaro /* We got a valid match line */ 62247037Smelifaro if (matchline != NULL) 63247036Smelifaro free(matchline); 64247036Smelifaro needsort = 1; 65247036Smelifaro matchline = strdup(args); 66247036Smelifaro } else { 67247036Smelifaro /* Empty or * pattern, turn filtering off */ 68247037Smelifaro if (matchline != NULL) 69247036Smelifaro free(matchline); 70247036Smelifaro needsort = 1; 71247036Smelifaro matchline = NULL; 72247036Smelifaro } 73247036Smelifaro } else if (prefix(cmd, "pps")) 74247036Smelifaro showpps = !showpps; 75247036Smelifaro 76164669Syar return (1); 77108684Sphk} 78