Fix "disable this protocol by default".
[jlayton/wireshark.git] / dftest.c
index bb941ea994b49beca7049710150b18a087112bc4..9b4276ecac2f49349e1e51c166533f62257cc8cd 100644 (file)
--- a/dftest.c
+++ b/dftest.c
@@ -35,7 +35,9 @@
 #include <epan/prefs.h>
 #include <epan/dfilter/dfilter.h>
 
+#ifdef HAVE_PLUGINS
 #include <wsutil/plugins.h>
+#endif
 #include <wsutil/filesystem.h>
 #include <wsutil/privileges.h>
 #include <wsutil/report_err.h>
@@ -58,6 +60,7 @@ main(int argc, char **argv)
        int             gpf_open_errno, gpf_read_errno;
        int             pf_open_errno, pf_read_errno;
        dfilter_t       *df;
+       gchar           *err_msg;
 
        /*
         * Get credential information for later use.
@@ -79,12 +82,22 @@ main(int argc, char **argv)
        timestamp_set_type(TS_RELATIVE);
        timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
 
+#ifdef HAVE_PLUGINS
+       /* Register all the plugin types we have. */
+       epan_register_plugin_types(); /* Types known to libwireshark */
+
+       /* Scan for plugins.  This does *not* call their registration routines;
+          that's done later. */
+       scan_plugins();
+#endif
+
        /* 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);
+       if (!epan_init(register_all_protocols, register_all_protocol_handoffs,
+           NULL, NULL))
+               return 2;
 
        /* set the c-language locale to the native environment. */
        setlocale(LC_ALL, "");
@@ -133,8 +146,9 @@ main(int argc, char **argv)
        printf("Filter: \"%s\"\n", text);
 
        /* Compile it */
-       if (!dfilter_compile(text, &df)) {
-               fprintf(stderr, "dftest: %s\n", dfilter_error_msg);
+       if (!dfilter_compile(text, &df, &err_msg)) {
+               fprintf(stderr, "dftest: %s\n", err_msg);
+               g_free(err_msg);
                epan_cleanup();
                exit(2);
        }