From e8f5dac7d455f1b64bb287630bbd532b550da691 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 5 Dec 1999 01:27:14 +0000 Subject: Use the new routines in Wiretap to make the argument to "-T" be a symbolic name, and to list the encapsulation types in the usage message. Note in the usage message that the default output encapsulation type is "same as the input file" and that the default output file type is "libpcap". svn path=/trunk/; revision=1213 --- editcap.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'editcap.c') diff --git a/editcap.c b/editcap.c index f5b997683d..0e306f021e 100644 --- a/editcap.c +++ b/editcap.c @@ -1,7 +1,7 @@ /* Edit capture files. We can delete records, or simply convert from one * format to another format. * - * $Id: editcap.c,v 1.2 1999/12/04 21:42:56 guy Exp $ + * $Id: editcap.c,v 1.3 1999/12/05 01:27:14 guy Exp $ * * Originally written by Richard Sharpe. * Improved by Guy Harris. @@ -81,18 +81,27 @@ edit_callback(u_char *user, const struct wtap_pkthdr *phdr, int offset, void usage() { int i; + char *string; - fprintf(stderr, "Usage: editcap [-r] [-T ] [-F ] \\\n"); + fprintf(stderr, "Usage: editcap [-r] [-T ] [-F ] \\\n"); fprintf(stderr, " [ ... ]\n"); fprintf(stderr, " where\t-r specifies that the records specified should be kept, not deleted, \n"); fprintf(stderr, " default is to delete\n"); - fprintf(stderr, " \t-T specified the encapsulation type\n"); - fprintf(stderr, " \t-F specifies the capture file type:\n"); + fprintf(stderr, " \t-T specifies the encapsulation type to use:\n"); + for (i = 0; i < WTAP_NUM_ENCAP_TYPES; i++) { + string = wtap_encap_short_string(i); + if (string != NULL) + fprintf(stderr, " \t %s - %s\n", + string, wtap_encap_string(i)); + } + fprintf(stderr, " \t default is the same as the input file\n"); + fprintf(stderr, " \t-F specifies the capture file type to write:\n"); for (i = 0; i < WTAP_NUM_FILE_TYPES; i++) { if (wtap_dump_can_open(i)) fprintf(stderr, " \t %s - %s\n", wtap_file_type_short_string(i), wtap_file_type_string(i)); } + fprintf(stderr, " \t default is libpcap\n"); } int main(int argc, char *argv[]) @@ -112,7 +121,12 @@ int main(int argc, char *argv[]) switch (opt) { case 'T': - out_frame_type = atoi(optarg); + out_frame_type = wtap_short_string_to_encap(optarg); + if (out_frame_type < 0) { + fprintf(stderr, "editcap: \"%s\" is not a valid encapsulation type\n", + optarg); + exit(1); + } break; case 'F': -- cgit v1.2.3