aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-05-14 10:15:12 +0000
committerGuy Harris <guy@alum.mit.edu>2002-05-14 10:15:12 +0000
commite390d7e0cc3cb6247f5198bc81baff90b754051c (patch)
tree1a25f5a6711676f4ad9ee3967225728d2895601e
parenteb4f9a696cd794274ba34f2a54f30272855dd0d7 (diff)
Make the "-G" flag take an argument. If no arugment is specified, or if
the argument is "fields", dump out a table of the fields, as we currently do; if the argument is "protocols", dump out a table of the protocols. svn path=/trunk/; revision=5462
-rw-r--r--epan/proto.c34
-rw-r--r--epan/proto.h7
-rw-r--r--gtk/main.c28
-rw-r--r--tethereal.c23
4 files changed, 69 insertions, 23 deletions
diff --git a/epan/proto.c b/epan/proto.c
index f5b00a3422..ed32d85ba3 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.68 2002/05/09 23:50:28 gram Exp $
+ * $Id: proto.c,v 1.69 2002/05/14 10:15:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -2946,12 +2946,34 @@ proto_find_field_from_offset(proto_tree *tree, guint offset, tvbuff_t *tvb)
return offsearch.finfo;
}
+/* Dumps the protocols in the registration database to stdout. An independent
+ * program can take this output and format it into nice tables or HTML or
+ * whatever.
+ *
+ * There is one record per line. The fields are tab-delimited.
+ *
+ * Field 1 = protocol name
+ * Field 2 = protocol short name
+ * Field 3 = protocol filter name
+ */
+void
+proto_registrar_dump_protocols(void)
+{
+ protocol_t *protocol;
+ int i;
+ void *cookie;
+ for (i = proto_get_first_protocol(&cookie); i != -1;
+ i = proto_get_next_protocol(&cookie)) {
+ protocol = find_protocol_by_id(i);
+ printf("%s\t%s\t%s\n", protocol->name, protocol->short_name,
+ protocol->filter_name);
+ }
+}
-
-
-/* Dumps the contents of the registration database to stdout. An indepedent program can take
- * this output and format it into nice tables or HTML or whatever.
+/* Dumps the contents of the registration database to stdout. An indepedent
+ * program can take this output and format it into nice tables or HTML or
+ * whatever.
*
* There is one record per line. Each record is either a protocol or a header
* field, differentiated by the first field. The fields are tab-delimited.
@@ -2971,7 +2993,7 @@ proto_find_field_from_offset(proto_tree *tree, guint offset, tvbuff_t *tvb)
* Field 5 = parent protocol abbreviation
*/
void
-proto_registrar_dump(void)
+proto_registrar_dump_fields(void)
{
header_field_info *hfinfo, *parent_hfinfo;
int i, len;
diff --git a/epan/proto.h b/epan/proto.h
index 84469890df..ae1a9521ba 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -1,7 +1,7 @@
/* proto.h
* Definitions for protocol display
*
- * $Id: proto.h,v 1.31 2002/04/29 07:55:31 guy Exp $
+ * $Id: proto.h,v 1.32 2002/05/14 10:15:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -554,8 +554,11 @@ extern gboolean proto_check_for_protocol_or_field(proto_tree* tree, int id);
* tree. */
extern GPtrArray* proto_get_finfo_ptr_array(proto_tree *tree, int hfindex);
+/* Dumps a glossary of the protocol registrations to STDOUT */
+extern void proto_registrar_dump_protocols(void);
+
/* Dumps a glossary of the protocol and field registrations to STDOUT */
-extern void proto_registrar_dump(void);
+extern void proto_registrar_dump_fields(void);
/* Points to the first element of an array of Booleans, indexed by
a subtree item type; that array element is TRUE if subtrees of
diff --git a/gtk/main.c b/gtk/main.c
index f26a885386..2c5d976a10 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.247 2002/05/03 03:30:15 guy Exp $
+ * $Id: main.c,v 1.248 2002/05/14 10:15:12 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1254,17 +1254,19 @@ main(int argc, char *argv[])
#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. */
+ "-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);
/* Now register the preferences for any non-dissector modules.
We must do that before we read the preferences as well. */
prefs_register_modules();
- /* If invoked with the "-G" flag, we dump out a glossary of
- display filter symbols.
+ /* If invoked with the "-G" flag, we dump out information based on
+ the argument to the "-G" flag; if no argument is specified,
+ for backwards compatibility we dump out a glossary of display
+ filter symbols.
We must do this before calling "gtk_init()", because "gtk_init()"
tries to open an X display, and we don't want to have to do any X
@@ -1281,9 +1283,19 @@ main(int argc, char *argv[])
you must give it as "-G", nothing more, nothing less;
- any arguments after the "-G" flag will not be used. */
+ the first argument after the "-G" flag, if present, will be used
+ to specify the information to dump;
+
+ arguments after that will not be used. */
if (argc >= 2 && strcmp(argv[1], "-G") == 0) {
- proto_registrar_dump();
+ if (argc == 2)
+ proto_registrar_dump_fields();
+ else {
+ if (strcmp(argv[2], "fields") == 0)
+ proto_registrar_dump_fields();
+ else if (strcmp(argv[2], "protocols") == 0)
+ proto_registrar_dump_protocols();
+ }
exit(0);
}
diff --git a/tethereal.c b/tethereal.c
index 3e0f726a3c..83369ef45f 100644
--- a/tethereal.c
+++ b/tethereal.c
@@ -1,6 +1,6 @@
/* tethereal.c
*
- * $Id: tethereal.c,v 1.135 2002/03/31 20:56:59 guy Exp $
+ * $Id: tethereal.c,v 1.136 2002/05/14 10:15:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -321,22 +321,31 @@ main(int argc, char *argv[])
char badopt;
/* 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. */
+ "-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);
/* Now register the preferences for any non-dissector modules.
We must do that before we read the preferences as well. */
prefs_register_modules();
- /* If invoked with the "-G" flag, we dump out a glossary of
- display filter symbols.
+ /* If invoked with the "-G" flag, we dump out information based on
+ the argument to the "-G" flag; if no argument is specified,
+ for backwards compatibility we dump out a glossary of display
+ filter symbols.
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) {
- proto_registrar_dump();
+ if (argc == 2)
+ proto_registrar_dump_fields();
+ else {
+ if (strcmp(argv[2], "fields") == 0)
+ proto_registrar_dump_fields();
+ else if (strcmp(argv[2], "protocols") == 0)
+ proto_registrar_dump_protocols();
+ }
exit(0);
}