From owner-p4-projects@FreeBSD.ORG Sun Oct 19 06:24:33 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 772FE1065689; Sun, 19 Oct 2008 06:24:33 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3B90C1065686 for ; Sun, 19 Oct 2008 06:24:33 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 2AA008FC17 for ; Sun, 19 Oct 2008 06:24:33 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id m9J6OWxo037986 for ; Sun, 19 Oct 2008 06:24:32 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id m9J6OWnV037984 for perforce@freebsd.org; Sun, 19 Oct 2008 06:24:32 GMT (envelope-from sam@freebsd.org) Date: Sun, 19 Oct 2008 06:24:32 GMT Message-Id: <200810190624.m9J6OWnV037984@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 151543 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Oct 2008 06:24:33 -0000 http://perforce.freebsd.org/chv.cgi?CH=151543 Change 151543 by sam@sam_ebb on 2008/10/19 06:24:00 Extend -o option: add predefined output formats selectable by name. For now there's just "default". In the future these might come from a dot file to simplify use. Affected files ... .. //depot/projects/vap/tools/tools/ath/athstats/main.c#4 edit Differences ... ==== //depot/projects/vap/tools/tools/ath/athstats/main.c#4 (text+ko) ==== @@ -49,8 +49,27 @@ #include "athstats.h" -#define S_DEFAULT \ - "input,output,altrate,short,long,xretry,crcerr,crypt,phyerr,rssi,rate" +static struct { + const char *tag; + const char *fmt; +} tags[] = { + { "default", + "input,output,altrate,short,long,xretry,crcerr,crypt,phyerr,rssi,rate" + }, +}; + +static const char * +getfmt(const char *tag) +{ +#define N(a) (sizeof(a)/sizeof(a[0])) + int i; + for (i = 0; i < N(tags); i++) + if (strcasecmp(tags[i].tag, tag) == 0) + return tags[i].fmt; + errx(-1, "unknown tag \%s\"", tag); + /*NOTREACHED*/ +#undef N +} static int signalled; @@ -70,7 +89,7 @@ ifname = getenv("ATH"); if (ifname == NULL) ifname = "ath0"; - wf = athstats_new(ifname, S_DEFAULT); + wf = athstats_new(ifname, getfmt("default")); while ((c = getopt(argc, argv, "i:lo:")) != -1) { switch (c) { case 'i': @@ -80,7 +99,7 @@ wf->print_fields(wf, stdout); return 0; case 'o': - wf->setfmt(wf, optarg); + wf->setfmt(wf, getfmt(optarg)); break; default: errx(-1, "usage: %s [-a] [-i ifname] [-l] [-o fmt] [interval]\n", argv[0]);