Allow taps to have menu item registration routines; the menu item

registration routines, for taps with menu items (taps that can be run
from the "Tools->Statistics" menu), create the menu item for the tap.
"make-tapreg-dotc" constructs a "register_all_tap_menus()" function that
calls all the tap menu item registration routines it finds, and Ethereal
calls that routine after the main window has been constructed (so that
the main menu exists, as the menu items are added to it).  (Tethereal
doesn't call it.)

Get rid of the "menu" and "menu_init" arguments to
"register_ethereal_tap"; the menu item is registered in the tap's menu
item registration routine, not in its main registration routine.

Have the RTP GUI tap register its menu item that way, rather than by
having it compiled into "gtk/menu.c".  (We're not ready yet to have taps
whose menu items are under a submenu register themselves in that
fashion, as "register_tap_menu_item()" can't yet create submenus.)


git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7540 f5534014-38df-0310-8fa8-9805f1628bb7
This commit is contained in:
guy 2003-04-23 03:51:03 +00:00
parent 5a53268e4c
commit 9abce60635
23 changed files with 80 additions and 88 deletions

View File

@ -1,7 +1,7 @@
# Makefile.am
# Automake file for the GTK interface routines for Ethereal
#
# $Id: Makefile.am,v 1.55 2003/04/16 07:24:06 guy Exp $
# $Id: Makefile.am,v 1.56 2003/04/23 03:51:02 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@ethereal.com>
@ -40,8 +40,7 @@ ETHEREAL_TAP_SRC = \
rpc_progs.h \
smb_stat.c \
smb_stat.h \
tap_rtp.c \
tap_rtp.h
tap_rtp.c
ethereal-tap-register.c: $(ETHEREAL_TAP_SRC) $(top_srcdir)/make-tapreg-dotc
@echo Making ethereal-tap-register.c

View File

@ -1,7 +1,7 @@
/* dcerpc_stat.c
* dcerpc_stat 2002 Ronnie Sahlberg
*
* $Id: dcerpc_stat.c,v 1.3 2002/11/11 15:39:05 oabad Exp $
* $Id: dcerpc_stat.c,v 1.4 2003/04/23 03:51:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -610,5 +610,5 @@ gtk_dcerpcstat_cb(GtkWidget *w _U_, gpointer d _U_)
void
register_tap_listener_gtkdcerpcstat(void)
{
register_ethereal_tap("dcerpc,rtt,", gtk_dcerpcstat_init, NULL, NULL);
register_ethereal_tap("dcerpc,rtt,", gtk_dcerpcstat_init);
}

View File

@ -1,7 +1,7 @@
/* io_stat.c
* io_stat 2002 Ronnie Sahlberg
*
* $Id: io_stat.c,v 1.18 2003/03/05 20:12:04 guy Exp $
* $Id: io_stat.c,v 1.19 2003/04/23 03:51:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -1650,6 +1650,6 @@ register_tap_listener_gtk_iostat(void)
{
io_stat_widget_table = g_hash_table_new(io_stat_widget_hash,
io_stat_widget_equal);
register_ethereal_tap("io,stat", gtk_iostat_init, NULL, NULL);
register_ethereal_tap("io,stat", gtk_iostat_init);
}

View File

@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.288 2003/04/16 05:55:41 guy Exp $
* $Id: main.c,v 1.289 2003/04/23 03:51:03 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -1356,7 +1356,7 @@ typedef struct _ethereal_tap_list {
static ethereal_tap_list *tap_list=NULL;
void
register_ethereal_tap(char *cmd, void (*func)(char *arg), char *dummy _U_, void (*dummy2)(void) _U_)
register_ethereal_tap(char *cmd, void (*func)(char *arg))
{
ethereal_tap_list *newtl;
@ -1462,6 +1462,9 @@ main(int argc, char *argv[])
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 tap listeners; we do this before we parse the arguments,
as the "-z" argument can specify a registered tap. */
register_all_tap_listeners();
/* Now register the preferences for any non-dissector modules.
@ -2072,10 +2075,12 @@ main(int argc, char *argv[])
to a file that our parent will read? */
if (!capture_child) {
#endif
/* No. Pop up the main window, and read in a capture file if
/* No. Pop up the main window, register menus for taps (which we
must do after creating the main window, so that we can add
menu items to the main menu), and read in a capture file if
we were told to. */
create_main_window(pl_size, tv_size, bv_size, prefs);
register_all_tap_menus();
set_menus_for_capture_file(FALSE);
/* open tap windows after creating the main window to avoid GTK warnings */

View File

@ -1,7 +1,7 @@
/* menu.c
* Menu routines
*
* $Id: menu.c,v 1.90 2003/04/23 03:13:16 guy Exp $
* $Id: menu.c,v 1.91 2003/04/23 03:51:03 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -65,7 +65,6 @@
#include "mgcp_stat.h"
#include "compat_macros.h"
#include "gtkglobals.h"
#include "tap_rtp.h"
#include "../tap.h"
GtkWidget *popup_menu_object;
@ -260,8 +259,6 @@ static GtkItemFactoryEntry menu_items[] =
NULL),
ITEM_FACTORY_ENTRY("/Tools/Statistics/MGCP/RTD", NULL, gtk_mgcpstat_cb,
0, NULL, NULL),
ITEM_FACTORY_ENTRY("/Tools/Statistics/RTP Analysis...", NULL, rtp_analyse_cb,
0, NULL, NULL),
ITEM_FACTORY_ENTRY("/_Help", NULL, NULL, 0, "<LastBranch>", NULL),
ITEM_FACTORY_STOCK_ENTRY("/Help/_Help", NULL, help_cb, 0, GTK_STOCK_HELP),
ITEM_FACTORY_ENTRY("/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL),

View File

@ -2,7 +2,7 @@
* mgcp-statistics for ethereal
* Copyright 2003 Lars Roland
*
* $Id: mgcp_stat.c,v 1.1 2003/04/16 07:24:06 guy Exp $
* $Id: mgcp_stat.c,v 1.2 2003/04/23 03:51:03 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -342,7 +342,7 @@ gtk_mgcpstat_init(char *optarg)
void
register_tap_listener_gtkmgcpstat(void)
{
register_ethereal_tap("mgcp,rtd", gtk_mgcpstat_init, NULL, NULL);
register_ethereal_tap("mgcp,rtd", gtk_mgcpstat_init);
}

View File

@ -1,7 +1,7 @@
/* rpc_progs.c
* rpc_progs 2002 Ronnie Sahlberg
*
* $Id: rpc_progs.c,v 1.6 2002/12/16 07:02:05 sahlberg Exp $
* $Id: rpc_progs.c,v 1.7 2003/04/23 03:51:03 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -397,5 +397,5 @@ gtk_rpcprogs_cb(GtkWidget *w _U_, gpointer d _U_)
void
register_tap_listener_gtkrpcprogs(void)
{
register_ethereal_tap("rpc,programs", gtk_rpcprogs_init, NULL, NULL);
register_ethereal_tap("rpc,programs", gtk_rpcprogs_init);
}

View File

@ -1,7 +1,7 @@
/* rpc_stat.c
* rpc_stat 2002 Ronnie Sahlberg
*
* $Id: rpc_stat.c,v 1.6 2002/11/11 15:39:06 oabad Exp $
* $Id: rpc_stat.c,v 1.7 2003/04/23 03:51:03 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -604,5 +604,5 @@ gtk_rpcstat_cb(GtkWidget *w _U_, gpointer d _U_)
void
register_tap_listener_gtkrpcstat(void)
{
register_ethereal_tap("rpc,rtt,", gtk_rpcstat_init, NULL, NULL);
register_ethereal_tap("rpc,rtt,", gtk_rpcstat_init);
}

View File

@ -1,7 +1,7 @@
/* smb_stat.c
* smb_stat 2003 Ronnie Sahlberg
*
* $Id: smb_stat.c,v 1.2 2003/04/22 09:30:59 sahlberg Exp $
* $Id: smb_stat.c,v 1.3 2003/04/23 03:51:03 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -489,7 +489,7 @@ gtk_smbstat_init(char *optarg)
void
register_tap_listener_gtksmbstat(void)
{
register_ethereal_tap("smb,rtt", gtk_smbstat_init, NULL, NULL);
register_ethereal_tap("smb,rtt", gtk_smbstat_init);
}

View File

@ -1,7 +1,7 @@
/*
* tap_rtp.c
*
* $Id: tap_rtp.c,v 1.8 2003/03/11 08:46:26 sahlberg Exp $
* $Id: tap_rtp.c,v 1.9 2003/04/23 03:51:03 guy Exp $
*
* RTP analysing addition for ethereal
*
@ -98,7 +98,6 @@
#endif
#include <gtk/gtk.h>
#include "tap_rtp.h"
#include "globals.h"
#include <string.h>
#include "epan/packet_info.h"
@ -111,6 +110,7 @@
#include "dlg_utils.h"
#include "ui_util.h"
#include "simple_dialog.h"
#include "menu.h"
#include "main.h"
#include <math.h>
#include "progress_dlg.h"
@ -1611,7 +1611,7 @@ static void get_reversed_ssrc(void *prs)
/* XXX only handles RTP over IPv4, should add IPv6 support */
/* when the user clicks the RTP dialog button */
void rtp_analyse_cb(GtkWidget *w _U_, gpointer data _U_)
static void rtp_analyse_cb(GtkWidget *w _U_, gpointer data _U_)
{
info_stat *rs;
gchar filter_text[256];
@ -1734,11 +1734,16 @@ rtp_analyse_init(char *dummy _U_)
rtp_analyse_cb(NULL, NULL);
}
/* XXX compiler warning:passing arg 2 of `register_ethereal_tap' from incompatible pointer type */
void
register_tap_listener_gtkrtp(void)
{
register_ethereal_tap("rtp", rtp_analyse_init, NULL, NULL);
register_ethereal_tap("rtp", rtp_analyse_init);
}
void
register_tap_menu_gtkrtp(void)
{
register_tap_menu_item("RTP Analysis...", rtp_analyse_cb);
}
@ -1918,4 +1923,3 @@ static gboolean copy_file(gchar *dest, gint channels, /*gint format,*/ void *dat
return TRUE;
}

View File

@ -1,35 +0,0 @@
/*
* tap_rtp.h
*
* $Id: tap_rtp.h,v 1.3 2003/03/06 22:36:43 guy Exp $
*
* Declaration for rtp analysing tool
*
* Copyright 2003, Iskratel, Ltd, Kranj
* By Miha Jemec <m.jemec@iskratel.si>
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __TAP_RTP_H__
#define __TAP_RTP_H__
void rtp_analyse_cb(GtkWidget *, gpointer);
#endif /* _TAP_RTP_H_ */

View File

@ -39,4 +39,23 @@ done | while read func; do
done
echo '}' >>${outfile}-tmp
#
# Build code to call all the tap listener menu item registration routines.
#
echo 'void register_all_tap_menus(void) {' >>${outfile}-tmp
for f in "$@"
do
if [ -f $f ]
then
srcfile=$f
else
srcfile=$srcdir/$f
fi
grep '^register_tap_menu_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';' | sed -e 's/(.*//'
done | while read func; do
echo " { extern void $func (void);" >>${outfile}-tmp
echo " $func ();}" >>${outfile}-tmp
done
echo '}' >>${outfile}-tmp
mv ${outfile}-tmp ${outfile}

View File

@ -1,13 +1,12 @@
/* register.h
* Definitions for protocol registration
*
* $Id: register.h,v 1.4 2002/10/31 22:16:01 guy Exp $
* $Id: register.h,v 1.5 2003/04/23 03:50:59 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@ -29,5 +28,6 @@
extern void register_all_protocols(void);
extern void register_all_protocol_handoffs(void);
extern void register_all_tap_listeners(void);
extern void register_ethereal_tap(char *str, void (*init)(char *), char *menu, void(*menu_init)(void));
extern void register_all_tap_menus(void);
extern void register_ethereal_tap(char *str, void (*init)(char *));
#endif /* __REGISTER_H__ */

View File

@ -1,7 +1,7 @@
/* tap-dcerpcstat.c
* dcerpcstat 2002 Ronnie Sahlberg
*
* $Id: tap-dcerpcstat.c,v 1.3 2002/10/31 22:16:01 guy Exp $
* $Id: tap-dcerpcstat.c,v 1.4 2003/04/23 03:50:59 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -277,5 +277,5 @@ dcerpcstat_init(char *optarg)
void
register_tap_listener_dcerpcstat(void)
{
register_ethereal_tap("dcerpc,rtt,", dcerpcstat_init, NULL, NULL);
register_ethereal_tap("dcerpc,rtt,", dcerpcstat_init);
}

View File

@ -1,7 +1,7 @@
/* tap-iostat.c
* iostat 2002 Ronnie Sahlberg
*
* $Id: tap-iostat.c,v 1.4 2003/04/22 09:02:47 sahlberg Exp $
* $Id: tap-iostat.c,v 1.5 2003/04/23 03:50:59 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -312,6 +312,6 @@ iostat_init(char *optarg)
void
register_tap_listener_iostat(void)
{
register_ethereal_tap("io,stat,", iostat_init, NULL, NULL);
register_ethereal_tap("io,stat,", iostat_init);
}

View File

@ -1,7 +1,7 @@
/* tap-iousers.c
* iostat 2003 Ronnie Sahlberg
*
* $Id: tap-iousers.c,v 1.4 2003/03/03 23:46:48 sahlberg Exp $
* $Id: tap-iousers.c,v 1.5 2003/04/23 03:50:59 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -459,6 +459,6 @@ iousers_init(char *optarg)
void
register_tap_listener_iousers(void)
{
register_ethereal_tap("io,users,", iousers_init, NULL, NULL);
register_ethereal_tap("io,users,", iousers_init);
}

View File

@ -1,7 +1,7 @@
/* tap-mgcpstat.c
* mgcpstat 2003 Lars Roland
*
* $Id: tap-mgcpstat.c,v 1.4 2003/04/16 07:24:04 guy Exp $
* $Id: tap-mgcpstat.c,v 1.5 2003/04/23 03:50:59 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -230,6 +230,6 @@ mgcpstat_init(char *optarg)
void
register_tap_listener_mgcpstat(void)
{
register_ethereal_tap("mgcp,rtd", mgcpstat_init, NULL, NULL);
register_ethereal_tap("mgcp,rtd", mgcpstat_init);
}

View File

@ -1,7 +1,7 @@
/* tap-protocolinfo.c
* protohierstat 2002 Ronnie Sahlberg
*
* $Id: tap-protocolinfo.c,v 1.1 2002/11/04 12:10:59 sahlberg Exp $
* $Id: tap-protocolinfo.c,v 1.2 2003/04/23 03:50:59 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -122,6 +122,6 @@ protocolinfo_init(char *optarg)
void
register_tap_listener_protocolinfo(void)
{
register_ethereal_tap("proto,colinfo,", protocolinfo_init, NULL, NULL);
register_ethereal_tap("proto,colinfo,", protocolinfo_init);
}

View File

@ -1,7 +1,7 @@
/* tap-protohierstat.c
* protohierstat 2002 Ronnie Sahlberg
*
* $Id: tap-protohierstat.c,v 1.1 2002/11/01 05:29:34 sahlberg Exp $
* $Id: tap-protohierstat.c,v 1.2 2003/04/23 03:50:59 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -212,6 +212,6 @@ protohierstat_init(char *optarg)
void
register_tap_listener_protohierstat(void)
{
register_ethereal_tap("io,phs", protohierstat_init, NULL, NULL);
register_ethereal_tap("io,phs", protohierstat_init);
}

View File

@ -1,7 +1,7 @@
/* tap-rpcprogs.c
* rpcstat 2002 Ronnie Sahlberg
*
* $Id: tap-rpcprogs.c,v 1.3 2002/10/31 22:16:01 guy Exp $
* $Id: tap-rpcprogs.c,v 1.4 2003/04/23 03:50:59 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -237,7 +237,7 @@ rpcprogs_init(char *optarg _U_)
void
register_tap_listener_rpcprogs(void)
{
register_ethereal_tap("rpc,programs", rpcprogs_init, NULL, NULL);
register_ethereal_tap("rpc,programs", rpcprogs_init);
}

View File

@ -1,7 +1,7 @@
/* tap-rpcstat.c
* rpcstat 2002 Ronnie Sahlberg
*
* $Id: tap-rpcstat.c,v 1.6 2002/11/01 01:11:59 sahlberg Exp $
* $Id: tap-rpcstat.c,v 1.7 2003/04/23 03:50:59 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -358,6 +358,6 @@ rpcstat_init(char *optarg)
void
register_tap_listener_rpcstat(void)
{
register_ethereal_tap("rpc,rtt,", rpcstat_init, NULL, NULL);
register_ethereal_tap("rpc,rtt,", rpcstat_init);
}

View File

@ -1,7 +1,7 @@
/* tap-smbstat.c
* smbstat 2003 Ronnie Sahlberg
*
* $Id: tap-smbstat.c,v 1.1 2003/01/22 00:42:03 sahlberg Exp $
* $Id: tap-smbstat.c,v 1.2 2003/04/23 03:50:59 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -295,6 +295,6 @@ smbstat_init(char *optarg)
void
register_tap_listener_smbstat(void)
{
register_ethereal_tap("smb,rtt", smbstat_init, NULL, NULL);
register_ethereal_tap("smb,rtt", smbstat_init);
}

View File

@ -1,6 +1,6 @@
/* tethereal.c
*
* $Id: tethereal.c,v 1.180 2003/04/16 05:55:37 guy Exp $
* $Id: tethereal.c,v 1.181 2003/04/23 03:50:59 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -329,7 +329,7 @@ typedef struct _ethereal_tap_list {
static ethereal_tap_list *tap_list=NULL;
void
register_ethereal_tap(char *cmd, void (*func)(char *arg), char *dummy _U_, void (*dummy2)(void) _U_)
register_ethereal_tap(char *cmd, void (*func)(char *arg))
{
ethereal_tap_list *newtl;
@ -378,6 +378,9 @@ main(int argc, char *argv[])
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 tap listeners; we do this before we parse the arguments,
as the "-z" argument can specify a registered tap. */
register_all_tap_listeners();
/* Now register the preferences for any non-dissector modules.