summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore 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,8 +1,8 @@
/* 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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
@@ -11,13 +11,13 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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
#include <stdio.h>
#include <sys/types.h>
@@ -123,25 +123,25 @@ parse_opt (key, arg, state)
{
switch (key) {
case 'b':
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++;
break;
case 'p':
promisc_off++;
@@ -150,13 +150,13 @@ parse_opt (key, arg, state)
single_process++;
break;
case 'S':
syntax_check++;
break;
case 't':
- ttw = atoi(optarg);
+ ttw = atoi(arg);
if (ttw <= 0)
die(1, "invalid timeslice value (%d)", ttw);
break;
case 'T':
test_mode++;
foreground++;
@@ -167,13 +167,13 @@ parse_opt (key, arg, state)
debug_profile();
break;
case 'x':
fixed_clocks++;
break;
case 'u':
- user = optarg;
+ user = arg;
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
@@ -310,30 +310,31 @@ main(argc, argv)
int argc;
char **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);
if (syntax_check)
return 0;
if (test_mode)
return test_shell();
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);
if (!(callback = lookup_pcap_callback(type = pcap_datalink(pcap))))
die(1, "unknown data link type 0x%x", type);
@@ -405,13 +406,13 @@ init(device, cmdbuf)
die(1, buf);
} else
die(1, buf);
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));
if (dump_bytecode) {
bpf_dump(&bpfcode, dump_bytecode);

Return to:

Send suggestions and report system problems to the System administrator.