diff options
author | Gerald Combs <gerald@wireshark.org> | 2005-06-13 22:40:11 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2005-06-13 22:40:11 +0000 |
commit | 5489ce999c730c4d912c33777c623db09305409a (patch) | |
tree | 90b42c8e061da68e295f8641cc531b361c8a8ed0 /clopts_common.c | |
parent | 5a899bd97c1638052c174ea79a410c7e4e55de88 (diff) |
Change read_prefs() to use GStrings instead of (re)allocating memory
ourselves. This fixes a potential off-by-one error found by Steve Grubb.
Add two new -G options: defaultprefs and currentprefs. The first dumps
the default preferences to stdout and the second dumps the user's prefs
to stdout.
svn path=/trunk/; revision=14624
Diffstat (limited to 'clopts_common.c')
-rw-r--r-- | clopts_common.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/clopts_common.c b/clopts_common.c index 369c26d3c4..d30f8751b6 100644 --- a/clopts_common.c +++ b/clopts_common.c @@ -31,6 +31,7 @@ #include <epan/proto.h> #include <epan/packet.h> +#include <epan/prefs.h> #include "clopts_common.h" @@ -41,6 +42,10 @@ void handle_dashG_option(int argc, char **argv, char *progname) { + char *gpf_path, *pf_path; + int gpf_open_errno, gpf_read_errno; + int pf_open_errno, pf_read_errno; + if (argc >= 2 && strcmp(argv[1], "-G") == 0) { if (argc == 2) proto_registrar_dump_fields(1); @@ -57,7 +62,13 @@ handle_dashG_option(int argc, char **argv, char *progname) proto_registrar_dump_values(); else if (strcmp(argv[2], "decodes") == 0) dissector_dump_decodes(); - else { + else if (strcmp(argv[2], "defaultprefs") == 0) + write_prefs(NULL); + else if (strcmp(argv[2], "currentprefs") == 0) { + read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path, + &pf_open_errno, &pf_read_errno, &pf_path); + write_prefs(NULL); + } else { fprintf(stderr, "%s: Invalid \"%s\" option for -G flag\n", progname, argv[2]); exit(1); |