Popup a menu with configuration profiles instead of the profile dlg
[obnox/wireshark/wip.git] / dftest.c
index 2eae86cac948b469ed9510cf10f5c5b8fae9fdcb..8dd5bce8d2147df420c37602fba41a487879995e 100644 (file)
--- a/dftest.c
+++ b/dftest.c
@@ -2,8 +2,8 @@
  *
  * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * Shows display filter byte-code, for debugging dfilter routines.
@@ -43,6 +43,7 @@
 #include <epan/timestamp.h>
 #include <epan/plugins.h>
 #include <epan/filesystem.h>
+#include <epan/privileges.h>
 #include <epan/prefs.h>
 #include "util.h"
 #include "epan/dfilter/dfilter.h"
@@ -58,6 +59,7 @@ static void read_failure_message(const char *filename, int err);
 int
 main(int argc, char **argv)
 {
+       char            *init_progfile_dir_error;
        char            *text;
        char            *gpf_path, *pf_path;
        int             gpf_open_errno, gpf_read_errno;
@@ -65,14 +67,28 @@ main(int argc, char **argv)
        e_prefs         *prefs;
        dfilter_t       *df;
 
-       set_timestamp_setting(TS_RELATIVE);
+       /*
+        * Get credential information for later use.
+        */
+       get_credential_info();
+
+       /*
+        * Attempt to get the pathname of the executable file.
+        */
+       init_progfile_dir_error = init_progfile_dir(argv[0]);
+       if (init_progfile_dir_error != NULL) {
+               fprintf(stderr, "dftest: Can't get pathname of dftest program: %s.\n",
+                   init_progfile_dir_error);
+       }
+
+       timestamp_set_type(TS_RELATIVE);
 
-       /* register all dissectors; we must do this before checking for the
-       "-g" flag, as the "-g" flag dumps a list of fields registered
-       by the dissectors, and we must do it before we read the preferences,
-       in case any dissectors register preferences. */
-       epan_init(PLUGIN_DIR,register_all_protocols,
-                 register_all_protocol_handoffs,
+       /* Register all dissectors; we must do this before checking for the
+          "-g" flag, as the "-g" flag dumps a list of fields registered
+          by the dissectors, and we must do it before we read the preferences,
+          in case any dissectors register preferences. */
+       epan_init(register_all_protocols,
+                 register_all_protocol_handoffs, NULL, NULL,
                  failure_message, open_failure_message, read_failure_message);
 
        /* now register the preferences for any non-dissector modules.
@@ -116,7 +132,7 @@ main(int argc, char **argv)
 
        /* Check for filter on command line */
        if (argc <= 1) {
-               fprintf(stderr, "Usage: dftest filter\n");
+               fprintf(stderr, "Usage: dftest <filter>\n");
                exit(1);
        }
 
@@ -131,11 +147,14 @@ main(int argc, char **argv)
                epan_cleanup();
                exit(2);
        }
-       printf("dfilter ptr = 0x%08x\n", (unsigned int) df);
+       printf("dfilter ptr = 0x%08x\n", GPOINTER_TO_INT(df));
 
        printf("\n\n");
 
-       dfilter_dump(df);
+       if (df == NULL)
+               printf("Filter is empty\n");
+       else
+               dfilter_dump(df);
 
        epan_cleanup();
        exit(0);