aboutsummaryrefslogtreecommitdiffstats
path: root/text2pcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-08-01 03:22:15 +0000
committerGuy Harris <guy@alum.mit.edu>2001-08-01 03:22:15 +0000
commit97a90e0f6ca5b8a8737905a43881c18833032125 (patch)
tree9384ed58ca3308893fcc86488ea9ec2317783a45 /text2pcap.c
parent26a68c20fc7d95691a6ecc330d4866e908acebec (diff)
"getopt()" doesn't support multiple option arguments to a flag; have
"-u" take a single argument with two port numbers separated by a comma. svn path=/trunk/; revision=3802
Diffstat (limited to 'text2pcap.c')
-rw-r--r--text2pcap.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/text2pcap.c b/text2pcap.c
index dd089a39b3..d760828210 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -6,7 +6,7 @@
*
* (c) Copyright 2001 Ashok Narayanan <ashokn@cisco.com>
*
- * $Id: text2pcap.c,v 1.3 2001/07/13 00:55:52 guy Exp $
+ * $Id: text2pcap.c,v 1.4 2001/08/01 03:22:14 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -603,6 +603,7 @@ static void
parse_options (int argc, char *argv[])
{
int c;
+ char *p;
/* Scan CLI parameters */
while ((c = getopt(argc, argv, "dqr:w:e:i:l:o:u:")) != -1) {
@@ -642,11 +643,19 @@ parse_options (int argc, char *argv[])
case 'u':
hdr_udp = TRUE;
- if (!optarg || sscanf(optarg, "%ld", &hdr_udp_src) < 1) {
+ hdr_udp_src = strtol(optarg, &p, 10);
+ if (p == optarg || (*p != ',' && *p != '\0')) {
fprintf(stderr, "Bad src port for '-u'\n");
help(argv[0]);
}
- if (optind >= argc || sscanf(argv[optind], "%ld", &hdr_udp_dest) < 1) {
+ if (*p == '\0') {
+ fprintf(stderr, "No dest port specified for '-u'\n");
+ help(argv[0]);
+ }
+ p++;
+ optarg = p;
+ hdr_udp_dest = strtol(optarg, &p, 10);
+ if (p == optarg || *p != '\0') {
fprintf(stderr, "Bad dest port for '-u'\n");
help(argv[0]);
}