forked from osmocom/wireshark
Turn "ethereal_proto_init()" and "ethereal_proto_cleanup()" into
"dissect_init()" and "dissect_cleanup()", in "packet.c", so that we don't duplicate those routines in Ethereal and Tethereal (and so on), and don't have to remember to update N different versions of them if we have to change the way we do one-time initialization and cleanup. svn path=/trunk/; revision=1790
This commit is contained in:
parent
5f0fc518c7
commit
c2b1feea05
24
gtk/main.c
24
gtk/main.c
|
@ -1,6 +1,6 @@
|
|||
/* main.c
|
||||
*
|
||||
* $Id: main.c,v 1.114 2000/04/04 06:46:41 guy Exp $
|
||||
* $Id: main.c,v 1.115 2000/04/04 07:03:07 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -1068,22 +1068,6 @@ file_quit_cmd_cb (GtkWidget *widget, gpointer data)
|
|||
gtk_main_quit();
|
||||
}
|
||||
|
||||
/* call initialization routines at program startup time */
|
||||
static void
|
||||
ethereal_proto_init(void) {
|
||||
proto_init();
|
||||
dfilter_init();
|
||||
#ifdef HAVE_PLUGINS
|
||||
init_plugins();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
ethereal_proto_cleanup(void) {
|
||||
proto_cleanup();
|
||||
dfilter_cleanup();
|
||||
}
|
||||
|
||||
static void
|
||||
print_usage(void) {
|
||||
|
||||
|
@ -1170,7 +1154,7 @@ main(int argc, char *argv[])
|
|||
|
||||
any arguments after the "-G" flag will not be used. */
|
||||
if (argc >= 2 && strcmp(argv[1], "-G") == 0) {
|
||||
ethereal_proto_init();
|
||||
dissect_init();
|
||||
proto_registrar_dump();
|
||||
exit(0);
|
||||
}
|
||||
|
@ -1472,7 +1456,7 @@ main(int argc, char *argv[])
|
|||
Hmmm should we do it here
|
||||
*/
|
||||
|
||||
ethereal_proto_init(); /* Init anything that needs initializing */
|
||||
dissect_init(); /* Init anything that needs initializing */
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
/* Is this a "child" ethereal, which is only supposed to pop up a
|
||||
|
@ -1560,7 +1544,7 @@ main(int argc, char *argv[])
|
|||
|
||||
gtk_main();
|
||||
|
||||
ethereal_proto_cleanup();
|
||||
dissect_cleanup();
|
||||
g_free(rc_file);
|
||||
|
||||
gtk_exit(0);
|
||||
|
|
20
packet.c
20
packet.c
|
@ -1,7 +1,7 @@
|
|||
/* packet.c
|
||||
* Routines for packet disassembly
|
||||
*
|
||||
* $Id: packet.c,v 1.72 2000/04/04 05:37:36 guy Exp $
|
||||
* $Id: packet.c,v 1.73 2000/04/04 07:02:56 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -1037,6 +1037,24 @@ void blank_packetinfo(void)
|
|||
pi.destport = 0;
|
||||
}
|
||||
|
||||
/* Do all one-time initialization. */
|
||||
void
|
||||
dissect_init(void)
|
||||
{
|
||||
proto_init();
|
||||
dfilter_init();
|
||||
#ifdef HAVE_PLUGINS
|
||||
init_plugins();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
dissect_cleanup(void)
|
||||
{
|
||||
proto_cleanup();
|
||||
dfilter_cleanup();
|
||||
}
|
||||
|
||||
/* Allow protocols to register "init" routines, which are called before
|
||||
we make a pass through a capture file and dissect all its packets
|
||||
(e.g., when we read in a new capture file, or run a "filter packets"
|
||||
|
|
7
packet.h
7
packet.h
|
@ -1,7 +1,7 @@
|
|||
/* packet.h
|
||||
* Definitions for packet disassembly structures and routines
|
||||
*
|
||||
* $Id: packet.h,v 1.178 2000/04/04 05:37:34 guy Exp $
|
||||
* $Id: packet.h,v 1.179 2000/04/04 07:02:57 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -288,6 +288,11 @@ void *p_get_proto_data(frame_data *, int);
|
|||
|
||||
void blank_packetinfo(void);
|
||||
|
||||
/* Do all one-time initialization. */
|
||||
void dissect_init(void);
|
||||
|
||||
void dissect_cleanup(void);
|
||||
|
||||
/* Allow protocols to register "init" routines, which are called before
|
||||
we make a pass through a capture file and dissect all its packets
|
||||
(e.g., when we read in a new capture file, or run a "filter packets"
|
||||
|
|
30
tethereal.c
30
tethereal.c
|
@ -1,6 +1,6 @@
|
|||
/* tethereal.c
|
||||
*
|
||||
* $Id: tethereal.c,v 1.23 2000/04/04 06:46:29 guy Exp $
|
||||
* $Id: tethereal.c,v 1.24 2000/04/04 07:02:58 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -122,22 +122,6 @@ FILE *data_out_file = NULL;
|
|||
guint main_ctx, file_ctx;
|
||||
ts_type timestamp_type = RELATIVE;
|
||||
|
||||
/* call initialization routines at program startup time */
|
||||
static void
|
||||
ethereal_proto_init(void) {
|
||||
proto_init();
|
||||
dfilter_init();
|
||||
#ifdef HAVE_PLUGINS
|
||||
init_plugins();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
ethereal_proto_cleanup(void) {
|
||||
proto_cleanup();
|
||||
dfilter_cleanup();
|
||||
}
|
||||
|
||||
static void
|
||||
print_usage(void)
|
||||
{
|
||||
|
@ -198,7 +182,7 @@ main(int argc, char *argv[])
|
|||
We do this here to mirror what happens in the GTK+ version, although
|
||||
it's not necessary here. */
|
||||
if (argc >= 2 && strcmp(argv[1], "-G") == 0) {
|
||||
ethereal_proto_init();
|
||||
dissect_init();
|
||||
proto_registrar_dump();
|
||||
exit(0);
|
||||
}
|
||||
|
@ -420,12 +404,12 @@ main(int argc, char *argv[])
|
|||
else if (cf.snap < MIN_PACKET_SIZE)
|
||||
cf.snap = MIN_PACKET_SIZE;
|
||||
|
||||
ethereal_proto_init(); /* Init anything that needs initializing */
|
||||
dissect_init(); /* Init anything that needs initializing */
|
||||
|
||||
if (rfilter != NULL) {
|
||||
if (dfilter_compile(rfilter, &rfcode) != 0) {
|
||||
fprintf(stderr, "tethereal: %s\n", dfilter_error_msg);
|
||||
ethereal_proto_cleanup();
|
||||
dissect_cleanup();
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
@ -433,12 +417,12 @@ main(int argc, char *argv[])
|
|||
if (cf_name) {
|
||||
err = open_cap_file(cf_name, FALSE, &cf);
|
||||
if (err != 0) {
|
||||
ethereal_proto_cleanup();
|
||||
dissect_cleanup();
|
||||
exit(2);
|
||||
}
|
||||
err = load_cap_file(&cf, out_file_type);
|
||||
if (err != 0) {
|
||||
ethereal_proto_cleanup();
|
||||
dissect_cleanup();
|
||||
exit(2);
|
||||
}
|
||||
cf_name[0] = '\0';
|
||||
|
@ -475,7 +459,7 @@ main(int argc, char *argv[])
|
|||
#endif
|
||||
}
|
||||
|
||||
ethereal_proto_cleanup();
|
||||
dissect_cleanup();
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue