aboutsummaryrefslogtreecommitdiffstats
path: root/clopts_common.c
diff options
context:
space:
mode:
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2005-06-13 22:40:11 +0000
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2005-06-13 22:40:11 +0000
commit6a0c33af797f3cd41815ba0b500726d1ca5cf90d (patch)
tree90b42c8e061da68e295f8641cc531b361c8a8ed0 /clopts_common.c
parenta6a08c7724413fdbcd9225c696fba413a13565d5 (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. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@14624 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'clopts_common.c')
-rw-r--r--clopts_common.c13
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);