PERFORCE change 151543 for review
Sam Leffler
sam at FreeBSD.org
Sun Oct 19 06:24:33 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=151543
Change 151543 by sam at 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]);
More information about the p4-projects
mailing list