diff options
author | Guy Harris <guy@alum.mit.edu> | 2004-03-23 21:19:58 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2004-03-23 21:19:58 +0000 |
commit | 121f06fab70d77c4babb512924b2b8d3c3921944 (patch) | |
tree | 9dba3131d845040ea0ab402a8b3e4a5147d5d315 | |
parent | bf1315c25615bdd7d5ebff4245d8ba37b525871e (diff) | |
download | wireshark-121f06fab70d77c4babb512924b2b8d3c3921944.tar.gz |
Make "epan_init()" take, as additional arguments, pointers to routines
that dissectors should call to report file open and read errors, and
have "report_open_failure()" and "report_read_failure()" call through
those pointers, rather than being defined and exported by the
application using libethereal - instead, the application would define
those functions and pass pointers to them to 'epan_init()".
Move "report_err.h" to the epan directory, as the functions it declares
are now part of the libethereal API.
svn path=/trunk/; revision=10470
-rw-r--r-- | Makefile.common | 3 | ||||
-rw-r--r-- | alert_box.c | 17 | ||||
-rw-r--r-- | alert_box.h | 8 | ||||
-rw-r--r-- | dftest.c | 30 | ||||
-rw-r--r-- | epan/Makefile.am | 5 | ||||
-rw-r--r-- | epan/epan.c | 33 | ||||
-rw-r--r-- | epan/epan.h | 8 | ||||
-rw-r--r-- | epan/report_err.h (renamed from report_err.h) | 2 | ||||
-rw-r--r-- | gtk/main.c | 5 | ||||
-rw-r--r-- | packet-diameter.c | 4 | ||||
-rw-r--r-- | plugins/asn1/packet-asn1.c | 4 | ||||
-rw-r--r-- | plugins/plugin_api.h | 4 | ||||
-rw-r--r-- | plugins/plugin_api_list.c | 6 | ||||
-rw-r--r-- | tethereal.c | 18 |
14 files changed, 92 insertions, 55 deletions
diff --git a/Makefile.common b/Makefile.common index ef985db6a3..07520908ea 100644 --- a/Makefile.common +++ b/Makefile.common @@ -3,7 +3,7 @@ # a) common to both files and # b) portable between both files # -# $Id: Makefile.common,v 1.34 2004/03/23 19:51:05 guy Exp $ +# $Id: Makefile.common,v 1.35 2004/03/23 21:19:55 guy Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@ethereal.com> @@ -340,7 +340,6 @@ ethereal_INCLUDES = \ menu.h \ progress_dlg.h \ proto_hier_stats.h \ - report_err.h \ simple_dialog.h \ statusbar.h \ summary.h \ diff --git a/alert_box.c b/alert_box.c index d8a18b47db..2bb611fa83 100644 --- a/alert_box.c +++ b/alert_box.c @@ -2,7 +2,7 @@ * Routines to put up various "standard" alert boxes used in multiple * places * - * $Id: alert_box.c,v 1.4 2004/02/21 02:15:05 guy Exp $ + * $Id: alert_box.c,v 1.5 2004/03/23 21:19:55 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -35,7 +35,6 @@ #include <epan/dfilter/dfilter.h> #include "alert_box.h" -#include "report_err.h" #include "simple_dialog.h" @@ -59,19 +58,11 @@ open_failure_alert_box(const char *filename, int err, gboolean for_writing) } /* - * Open/create errors are reported with an alert box in Ethereal. - */ -void -report_open_failure(const char *filename, int err, gboolean for_writing) -{ - open_failure_alert_box(filename, err, for_writing); -} - -/* - * Read errors are reported with an alert box in Ethereal. + * Alert box for a failed attempt to read a file. + * "err" is assumed to be a UNIX-style errno. */ void -report_read_failure(const char *filename, int err) +read_failure_alert_box(const char *filename, int err) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "An error occurred while reading from the file \"%s\": %s.", diff --git a/alert_box.h b/alert_box.h index 667b8101ed..807f1106f0 100644 --- a/alert_box.h +++ b/alert_box.h @@ -2,7 +2,7 @@ * Routines to put up various "standard" alert boxes used in multiple * places * - * $Id: alert_box.h,v 1.3 2004/02/11 01:37:11 guy Exp $ + * $Id: alert_box.h,v 1.4 2004/03/23 21:19:55 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -40,6 +40,12 @@ extern void open_failure_alert_box(const char *filename, int err, gboolean for_writing); /* + * Alert box for a failed attempt to read a file. + * "err" is assumed to be a UNIX-style errno. + */ +extern void read_failure_alert_box(const char *filename, int err); + +/* * Alert box for a failed attempt to write to a file. * "err" is assumed to be a UNIX-style errno. */ @@ -1,6 +1,6 @@ /* dftest.c.c * - * $Id: dftest.c,v 1.9 2004/03/18 19:04:31 obiot Exp $ + * $Id: dftest.c,v 1.10 2004/03/23 21:19:55 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -50,6 +50,10 @@ packet_info pi; +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) { @@ -67,7 +71,8 @@ main(int argc, char **argv) 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, + 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. */ @@ -138,22 +143,23 @@ main(int argc, char **argv) /* * Open/create errors are reported with an console message in "dftest". */ -void -report_open_failure(const char *filename, int err, gboolean for_writing) +static void +open_failure_message(const char *filename, int err, gboolean for_writing) { - char *errmsg; + char *errmsg; - errmsg = g_strdup_printf(file_open_error_message(err, for_writing), filename); - fprintf(stderr, "dftest: %s\n", errmsg); - g_free(errmsg); + errmsg = g_strdup_printf(file_open_error_message(err, for_writing), + filename); + fprintf(stderr, "dftest: %s\n", errmsg); + g_free(errmsg); } /* * 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.", + filename, strerror(err)); } diff --git a/epan/Makefile.am b/epan/Makefile.am index ca49c06a39..52a082c378 100644 --- a/epan/Makefile.am +++ b/epan/Makefile.am @@ -2,7 +2,7 @@ # Automake file for the EPAN library # (Ethereal Protocol ANalyzer Library) # -# $Id: Makefile.am,v 1.43 2004/03/22 21:29:52 gerald Exp $ +# $Id: Makefile.am,v 1.44 2004/03/23 21:19:56 guy Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@ethereal.com> @@ -52,7 +52,7 @@ libethereal_la_SOURCES = \ column-utils.h \ epan.c \ epan.h \ - epan_dissect.h \ + epan_dissect.h \ except.c \ except.h \ exceptions.h \ @@ -79,6 +79,7 @@ libethereal_la_SOURCES = \ proto.h \ resolv.c \ resolv.h \ + report_err.h \ slab.h \ sna-utils.c \ sna-utils.h \ diff --git a/epan/epan.c b/epan/epan.c index 27fcb91177..b1fc6adc91 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -1,6 +1,6 @@ /* epan.h * - * $Id: epan.c,v 1.23 2003/05/04 18:50:53 gerald Exp $ + * $Id: epan.c,v 1.24 2004/03/23 21:19:56 guy Exp $ * * Ethereal Protocol Analyzer Library */ @@ -12,6 +12,7 @@ #include <glib.h> #include "epan.h" #include "epan_dissect.h" +#include "report_err.h" #include "conversation.h" #include "circuit.h" @@ -21,6 +22,9 @@ #include "../tap.h" #include "resolv.h" +static void (*report_open_failure_func)(const char *, int, gboolean); +static void (*report_read_failure_func)(const char *, int); + /* * XXX - this takes the plugin directory as an argument, because * libethereal now has its own configure script and "config.h" file, @@ -43,9 +47,13 @@ * libraries are located.) */ void -epan_init(const char *plugin_dir, void (register_all_protocols)(void), - void (register_all_handoffs)(void)) +epan_init(const char *plugin_dir, void (*register_all_protocols)(void), + void (*register_all_handoffs)(void), + void (*report_open_failure)(const char *, int, gboolean), + void (*report_read_failure)(const char *, int)) { + report_open_failure_func = report_open_failure; + report_read_failure_func = report_read_failure; except_init(); tvbuff_init(); frame_data_init(); @@ -81,6 +89,25 @@ epan_circuit_init(void) circuit_init(); } +/* + * Report an error when trying to open a file. + */ +void +report_open_failure(const char *filename, int err, + gboolean for_writing) +{ + (*report_open_failure_func)(filename, err, for_writing); +} + +/* + * Report an error when trying to read a file. + */ +void +report_read_failure(const char *filename, int err) +{ + (*report_read_failure_func)(filename, err); +} + epan_dissect_t* epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible) { diff --git a/epan/epan.h b/epan/epan.h index b3efd355cc..3493a7f5a2 100644 --- a/epan/epan.h +++ b/epan/epan.h @@ -1,6 +1,6 @@ /* epan.h * - * $Id: epan.h,v 1.15 2002/10/22 08:44:33 guy Exp $ + * $Id: epan.h,v 1.16 2004/03/23 21:19:56 guy Exp $ * * Ethereal Protocol Analyzer Library * @@ -32,8 +32,10 @@ typedef struct _epan_dissect_t epan_dissect_t; #include "dfilter/dfilter.h" -void epan_init(const char * plugindir, void (register_all_protocols)(void), - void (register_all_handoffs)(void)); +void epan_init(const char * plugindir, void (*register_all_protocols)(void), + void (*register_all_handoffs)(void), + void (*report_open_failure)(const char *, int, gboolean), + void (*report_read_failure)(const char *, int)); void epan_cleanup(void); void epan_conversation_init(void); void epan_circuit_init(void); diff --git a/report_err.h b/epan/report_err.h index c3e938cf6a..ef116eb046 100644 --- a/report_err.h +++ b/epan/report_err.h @@ -2,7 +2,7 @@ * Declarations of routines for dissectors to use to report errors to * the user (e.g., problems with preference settings) * - * $Id: report_err.h,v 1.1 2004/02/21 02:15:06 guy Exp $ + * $Id: report_err.h,v 1.1 2004/03/23 21:19:56 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> diff --git a/gtk/main.c b/gtk/main.c index 5074e7dd71..bd72fcd4ce 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.419 2004/03/20 06:34:08 guy Exp $ + * $Id: main.c,v 1.420 2004/03/23 21:19:56 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1939,7 +1939,8 @@ main(int argc, char *argv[]) "-G" flag, as the "-G" flag dumps information 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); + epan_init(PLUGIN_DIR,register_all_protocols,register_all_protocol_handoffs, + open_failure_alert_box, read_failure_alert_box); /* Register all tap listeners; we do this before we parse the arguments, as the "-z" argument can specify a registered tap. */ diff --git a/packet-diameter.c b/packet-diameter.c index c5ea037d15..18c36d81ed 100644 --- a/packet-diameter.c +++ b/packet-diameter.c @@ -1,7 +1,7 @@ /* packet-diameter.c * Routines for Diameter packet disassembly * - * $Id: packet-diameter.c,v 1.64 2004/03/21 23:19:36 guy Exp $ + * $Id: packet-diameter.c,v 1.65 2004/03/23 21:19:55 guy Exp $ * * Copyright (c) 2001 by David Frascone <dave@frascone.com> * @@ -48,7 +48,7 @@ #include "xmlstub.h" #include <epan/packet.h> #include <epan/resolv.h> -#include "report_err.h" +#include <epan/report_err.h> #include "prefs.h" #include "packet-tcp.h" diff --git a/plugins/asn1/packet-asn1.c b/plugins/asn1/packet-asn1.c index 1efcdcaf06..2c87ae2c0b 100644 --- a/plugins/asn1/packet-asn1.c +++ b/plugins/asn1/packet-asn1.c @@ -3,7 +3,7 @@ * * Copyright (c) 2003 by Matthijs Melchior <matthijs.melchior@xs4all.nl> * - * $Id: packet-asn1.c,v 1.21 2004/03/02 23:45:34 jmayer Exp $ + * $Id: packet-asn1.c,v 1.22 2004/03/23 21:19:58 guy Exp $ * * A plugin for: * @@ -82,8 +82,8 @@ #include "prefs.h" #include <epan/strutil.h> #include <epan/filesystem.h> +#include <epan/report_err.h> #include "asn1.h" -#include "report_err.h" #include "simple_dialog.h" #include "plugins/plugin_api_defs.h" diff --git a/plugins/plugin_api.h b/plugins/plugin_api.h index b47f713aed..15a49461a6 100644 --- a/plugins/plugin_api.h +++ b/plugins/plugin_api.h @@ -1,7 +1,7 @@ /* plugin_api.h * Routines for Ethereal plugins. * - * $Id: plugin_api.h,v 1.60 2004/03/04 07:07:03 guy Exp $ + * $Id: plugin_api.h,v 1.61 2004/03/23 21:19:57 guy Exp $ * * Ethereal - Network traffic analyzer * Copyright 2000 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -45,6 +45,7 @@ #include <epan/packet.h> #include <epan/conversation.h> +#include <epan/report_err.h> #include "prefs.h" #include "reassemble.h" #include "packet-giop.h" @@ -57,7 +58,6 @@ #include "xdlc.h" #include "epan/except.h" #include "epan/filesystem.h" -#include "report_err.h" #include "plugin_table.h" diff --git a/plugins/plugin_api_list.c b/plugins/plugin_api_list.c index d522687524..28bc0c1ea4 100644 --- a/plugins/plugin_api_list.c +++ b/plugins/plugin_api_list.c @@ -1,7 +1,7 @@ /* plugin_api_list.c * Used to generate various included files for plugin API * - * $Id: plugin_api_list.c,v 1.30 2004/03/04 07:07:03 guy Exp $ + * $Id: plugin_api_list.c,v 1.31 2004/03/23 21:19:57 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -29,6 +29,8 @@ #include <epan/packet.h> #include <epan/conversation.h> #include <epan/filesystem.h> +#include <epan/report_err.h> +#include <epan/except.h> #include "prefs.h" #include "reassemble.h" #include "packet-giop.h" @@ -39,8 +41,6 @@ #include "tap.h" #include "asn1.h" #include "xdlc.h" -#include "epan/except.h" -#include "report_err.h" gint check_col(column_info*, gint); void col_clear(column_info*, gint); diff --git a/tethereal.c b/tethereal.c index d92e77ab41..2450495d7a 100644 --- a/tethereal.c +++ b/tethereal.c @@ -1,6 +1,6 @@ /* tethereal.c * - * $Id: tethereal.c,v 1.232 2004/03/18 19:04:31 obiot Exp $ + * $Id: tethereal.c,v 1.233 2004/03/23 21:19:56 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -96,7 +96,6 @@ #include "ringbuffer.h" #include <epan/epan_dissect.h> #include "tap.h" -#include "report_err.h" #include <epan/timestamp.h> #ifdef HAVE_LIBPCAP @@ -186,6 +185,10 @@ static int pipe_dispatch(int, loop_data *, struct pcap_hdr *, \ #endif /* _WIN32 */ #endif +static void open_failure_message(const char *filename, int err, + gboolean for_writing); +static void read_failure_message(const char *filename, int err); + capture_file cfile; #ifdef HAVE_LIBPCAP typedef struct { @@ -836,7 +839,8 @@ main(int argc, char *argv[]) "-G" flag, as the "-G" flag dumps information 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); + epan_init(PLUGIN_DIR,register_all_protocols,register_all_protocol_handoffs, + open_failure_message, read_failure_message); /* Register all tap listeners; we do this before we parse the arguments, as the "-z" argument can specify a registered tap. */ @@ -2970,8 +2974,8 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing, /* * Open/create errors are reported with an console message in Tethereal. */ -void -report_open_failure(const char *filename, int err, gboolean for_writing) +static void +open_failure_message(const char *filename, int err, gboolean for_writing) { char *errmsg; @@ -3328,8 +3332,8 @@ pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr, /* * Read errors are reported with an console message in Tethereal. */ -void -report_read_failure(const char *filename, int err) +static void +read_failure_message(const char *filename, int err) { fprintf(stderr, "tethereal: An error occurred while reading from the file \"%s\": %s.", filename, strerror(err)); |