From owner-svn-src-head@FreeBSD.ORG Wed Mar 5 00:26:25 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A2D2A1EF; Wed, 5 Mar 2014 00:26:25 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8F79A171; Wed, 5 Mar 2014 00:26:25 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s250QP2c093905; Wed, 5 Mar 2014 00:26:25 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s250QPJa093904; Wed, 5 Mar 2014 00:26:25 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201403050026.s250QPJa093904@svn.freebsd.org> From: Adrian Chadd Date: Wed, 5 Mar 2014 00:26:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262759 - head/tools/tools/iwn/iwnstats X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Mar 2014 00:26:25 -0000 Author: adrian Date: Wed Mar 5 00:26:25 2014 New Revision: 262759 URL: http://svnweb.freebsd.org/changeset/base/262759 Log: Add command line parsing - and an -i option so I can monitor multiple iwn interfaces. Tested: * Intel 5100 Modified: head/tools/tools/iwn/iwnstats/main.c Modified: head/tools/tools/iwn/iwnstats/main.c ============================================================================== --- head/tools/tools/iwn/iwnstats/main.c Tue Mar 4 23:55:04 2014 (r262758) +++ head/tools/tools/iwn/iwnstats/main.c Wed Mar 5 00:26:25 2014 (r262759) @@ -252,12 +252,42 @@ iwn_print(struct iwnstats *is) printf("--\n"); } +static void +usage(void) +{ + printf("Usage: iwnstats [-h] [-i ifname]\n"); + printf(" -h: Help\n"); + printf(" -i : Use ifname (default %s)\n", + IWN_DEFAULT_IF); +} + int -main(int argc, const char *argv[]) +main(int argc, char *argv[]) { struct iwnstats *is; + int ch; + char *ifname; + + ifname = strdup(IWN_DEFAULT_IF); + + /* Parse command line arguments */ + while ((ch = getopt(argc, argv, + "hi:")) != -1) { + switch (ch) { + case 'i': + if (ifname) + free(ifname); + ifname = strdup(optarg); + break; + default: + case '?': + case 'h': + usage(); + exit(1); + } + } - is = iwnstats_new(IWN_DEFAULT_IF); + is = iwnstats_new(ifname); if (is == NULL) { fprintf(stderr, "%s: couldn't allocate new stats structure\n",