aboutsummaryrefslogtreecommitdiffstats
path: root/editcap.c
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2006-01-10 22:00:37 +0000
committerUlf Lamping <ulf.lamping@web.de>2006-01-10 22:00:37 +0000
commitae477dc44f6d413518c52c20ba5b65a7d7f3d43e (patch)
tree0366cf2ef5cef5475e140e9d218f65abb7ab26ba /editcap.c
parentc38f10aec7dcfab161ab55a44577696ef108bd67 (diff)
print the list of available types also if the given type is invalid
svn path=/trunk/; revision=16993
Diffstat (limited to 'editcap.c')
-rw-r--r--editcap.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/editcap.c b/editcap.c
index d459853484..58d2f08c87 100644
--- a/editcap.c
+++ b/editcap.c
@@ -245,33 +245,28 @@ static void usage(void)
fprintf(stderr, "\n");
}
+static void list_capture_types(void) {
+ int i;
-static void bad_option_help(int bad_opt) {
- int i;
- const char *string;
-
-
- switch(bad_opt) {
- case'F':
- fprintf(stderr, "The available capture file types for \"F\":\n");
+ fprintf(stderr, "editcap: The available capture file types for \"F\":\n");
for (i = 0; i < WTAP_NUM_FILE_TYPES; i++) {
if (wtap_dump_can_open(i))
fprintf(stderr, " %s - %s\n",
wtap_file_type_short_string(i), wtap_file_type_string(i));
}
- break;
- case'T':
- fprintf(stderr, "The available encapsulation types for \"T\":\n");
+}
+
+static void list_encap_types(void) {
+ int i;
+ const char *string;
+
+ fprintf(stderr, "editcap: The available encapsulation types for \"T\":\n");
for (i = 0; i < WTAP_NUM_ENCAP_TYPES; i++) {
string = wtap_encap_short_string(i);
if (string != NULL)
fprintf(stderr, " %s - %s\n",
string, wtap_encap_string(i));
}
- break;
- default:
- usage();
- }
}
int main(int argc, char *argv[])
@@ -316,8 +311,9 @@ int main(int argc, char *argv[])
case 'F':
out_file_type = wtap_short_string_to_file_type(optarg);
if (out_file_type < 0) {
- fprintf(stderr, "editcap: \"%s\" isn't a valid capture file type\n",
+ fprintf(stderr, "editcap: \"%s\" isn't a valid capture file type\n\n",
optarg);
+ list_capture_types();
exit(1);
}
break;
@@ -346,7 +342,16 @@ int main(int argc, char *argv[])
break;
case '?': /* Bad options if GNU getopt */
- bad_option_help(optopt);
+ switch(optopt) {
+ case'F':
+ list_capture_types();
+ break;
+ case'T':
+ list_encap_types();
+ break;
+ default:
+ usage();
+ }
exit(1);
break;
@@ -375,8 +380,9 @@ int main(int argc, char *argv[])
case 'T':
out_frame_type = wtap_short_string_to_encap(optarg);
if (out_frame_type < 0) {
- fprintf(stderr, "editcap: \"%s\" isn't a valid encapsulation type\n",
+ fprintf(stderr, "editcap: \"%s\" isn't a valid encapsulation type\n\n",
optarg);
+ list_encap_types();
exit(1);
}
break;