summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2008-07-07 13:27:02 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2008-07-07 13:27:02 (GMT)
commitbcbbacd1992e662173de831480ad6245b53d92de (patch) (side-by-side diff)
tree0a3182a015f12d3ff4ee1b5d8bcd4457ac2cca49
parent9c7894a9e562192caf0700288764c83d0b0e6699 (diff)
downloadipacct-bcbbacd1992e662173de831480ad6245b53d92de.tar.gz
ipacct-bcbbacd1992e662173de831480ad6245b53d92de.tar.bz2
(parse_opt): Remove leftover uses of optarg.
(main): Do not use optind.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--src/main.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/main.c b/src/main.c
index b02320a..6c72c38 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,5 +1,5 @@
/* This file is part of IPACCT
- Copyright (C) 1999,2000,2001,2002,2003,2004,2005 Sergey Poznyakoff
+ Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-/* $Id: main.c,v 1.9 2005/05/20 12:59:53 gray Exp $ */
+/* $Id: main.c,v 1.10 2008/07/07 13:27:02 gray Exp $ */
#if defined(HAVE_CONFIG_H)
# include <config.h>
#endif
@@ -126,19 +126,19 @@ parse_opt (key, arg, state)
dump_bytecode++;
break;
case 'c':
- profile = optarg;
+ profile = arg;
break;
case 'f':
foreground++;
break;
case 'F':
- infile = optarg;
+ infile = arg;
break;
case 'i':
- device = optarg;
+ device = arg;
break;
case 'l':
- log_name = optarg;
+ log_name = arg;
break;
case 'O':
optimize_expr++;
@@ -153,7 +153,7 @@ parse_opt (key, arg, state)
syntax_check++;
break;
case 't':
- ttw = atoi(optarg);
+ ttw = atoi(arg);
if (ttw <= 0)
die(1, "invalid timeslice value (%d)", ttw);
break;
@@ -170,7 +170,7 @@ parse_opt (key, arg, state)
fixed_clocks++;
break;
case 'u':
- user = optarg;
+ user = arg;
break;
default:
return ARGP_ERR_UNKNOWN;
@@ -313,8 +313,9 @@ main(argc, argv)
int c, type;
pcap_handler callback;
pid_t pid;
+ int index;
- if (argp_parse(&argp, argc, argv, 0, 0, NULL))
+ if (argp_parse(&argp, argc, argv, 0, &index, NULL))
exit(1);
read_profile(profile);
@@ -326,11 +327,11 @@ main(argc, argv)
alloc_snap_buffer();
if (infile) {
- if (optind < argc)
- die(1, "excess arguments after %s", argv[optind]);
+ if (index < argc)
+ die(1, "excess arguments after %s", argv[index]);
expr = read_expr(infile);
- } else if (optind < argc)
- expr = copy_argv(argc, argv, optind);
+ } else if (index < argc)
+ expr = copy_argv(argc, argv, index);
pcap = init(device, expr);
@@ -408,7 +409,7 @@ init(device, cmdbuf)
setuid(getuid());
- bzero((char *) &bpfcode, sizeof(bpfcode));
+ memset(&bpfcode, 0, sizeof(bpfcode));
if (pcap_compile(pd, &bpfcode, cmdbuf, optimize_expr, netmask) < 0)
die(1, pcap_geterr(pd));

Return to:

Send suggestions and report system problems to the System administrator.