/* dftest.c.c
*
- * $Id: dftest.c,v 1.8 2004/02/21 22:00:46 guy Exp $
+ * $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
#include <epan/timestamp.h>
#include <epan/plugins.h>
#include <epan/filesystem.h>
-#include "prefs.h"
+#include <epan/prefs.h>
#include "util.h"
#include "epan/dfilter/dfilter.h"
#include "register.h"
packet_info pi;
-ts_type timestamp_type = TS_RELATIVE;
+
+static void failure_message(const char *msg_format, va_list ap);
+static void open_failure_message(const char *filename, int err,
+ gboolean for_writing);
+static void read_failure_message(const char *filename, int err);
int
main(int argc, char **argv)
e_prefs *prefs;
dfilter_t *df;
+ set_timestamp_setting(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_protocol_handoffs,
+ failure_message, open_failure_message, read_failure_message);
/* now register the preferences for any non-dissector modules.
we must do that before we read the preferences as well. */
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");
}
/*
- * Open/create errors are reported with an console message in "dftest".
+ * General errors are reported with an console message in "dftest".
*/
-void
-report_open_failure(const char *filename, int err, gboolean for_writing)
+static void
+failure_message(const char *msg_format, va_list ap)
{
- char *errmsg;
+ fprintf(stderr, "dftest: ");
+ vfprintf(stderr, msg_format, ap);
+ fprintf(stderr, "\n");
+}
- errmsg = g_strdup_printf(file_open_error_message(err, for_writing), filename);
- fprintf(stderr, "dftest: %s\n", errmsg);
- g_free(errmsg);
+/*
+ * Open/create errors are reported with an console message in "dftest".
+ */
+static void
+open_failure_message(const char *filename, int err, gboolean for_writing)
+{
+ fprintf(stderr, "dftest: ");
+ fprintf(stderr, file_open_error_message(err, for_writing), filename);
+ fprintf(stderr, "\n");
}
/*
* Read errors are reported with an console message in "dftest".
*/
-void
-report_read_failure(const char *filename, int err)
+static void
+read_failure_message(const char *filename, int err)
{
- fprintf(stderr, "dftest: An error occurred while reading from the file \"%s\": %s.",
- filename, strerror(err));
+ fprintf(stderr, "dftest: An error occurred while reading from the file \"%s\": %s.\n",
+ filename, strerror(err));
}