From 5489ce999c730c4d912c33777c623db09305409a Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Mon, 13 Jun 2005 22:40:11 +0000 Subject: 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 --- clopts_common.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'clopts_common.c') 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 #include +#include #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); -- cgit v1.2.3