diff options
author | Guy Harris <guy@alum.mit.edu> | 1999-10-21 21:47:08 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 1999-10-21 21:47:08 +0000 |
commit | d4964f49444e8dc86f29efe3fb026b0c62745a67 (patch) | |
tree | 57bd59d75eed2459bfd12d72802628ea5d34e957 /gtk | |
parent | 06b0aeedfe9cb58380ecdc06e449979bd8c934b6 (diff) |
Have Ethereal check for a first command-line argument of "-G", rather
than a command name of "ethereal-dump-fields", to decide whether to run
as normal Ethereal or to just dump out the list of fields that can be
used in a display filter.
This allows us to continue to make that check without doing the regular
command line flag parsing (which we don't want to do, as we don't want
to call "gtk_init()" before making that check, as "gtk_init()" tries to
open an X display, and some people want not to have to have X running in
order to build Ethereal, or want not to have Ethereal try to open an X
connection over a slow line if it's just going to print field names to
the standard output), without having to make a link to "../ethereal"
from the "doc" directory (said link couldn't be a hard link, as ATK
apparently disallows hard links between directories, and I have the
vague impression that a symbolic link might cause other problems).
svn path=/trunk/; revision=902
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/main.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/gtk/main.c b/gtk/main.c index e7dbb58d85..63109a045b 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.24 1999/10/19 04:11:23 gram Exp $ + * $Id: main.c,v 1.25 1999/10/21 21:46:10 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -556,7 +556,10 @@ print_usage(void) { int main(int argc, char *argv[]) { - char *command_name, *s; +#ifdef HAVE_LIBPCAP + char *command_name; +#endif + char *s; int i; #ifndef WIN32 int opt; @@ -583,29 +586,42 @@ main(int argc, char *argv[]) ethereal_path = argv[0]; - /* If invoked as "ethereal-dump-fields", we dump out a glossary of - display filter symbols; we specify that by checking the name, - so that we can do so before looking at the argument list - - we don't want to look at the argument list, because we don't - want to call "gtk_init()", because we don't want to have to - do any X stuff just to do a build. */ +#ifdef HAVE_LIBPCAP command_name = strrchr(ethereal_path, '/'); if (command_name == NULL) command_name = ethereal_path; else command_name++; - if (strcmp(command_name, "ethereal-dump-fields") == 0) { + /* Set "capture_child" to indicate whether this is going to be a child + process for a "-S" capture. */ + capture_child = (strcmp(command_name, CHILD_NAME) == 0); +#endif + + /* If invoked with the "-G" flag, 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 + stuff just to do a build. + + Given that we call "gtk_init()" before doing the regular argument + list processing, so that it can handle X and GTK+ arguments and + remove them from the list at which we look, this means we must do + this before doing the regular argument list processing, as well. + + This means that: + + you must give the "-G" flag as the first flag on the command line; + + you must give it as "-G", nothing more, nothing less; + + any arguments after the "-G" flag will not be used. */ + if (argc >= 2 && strcmp(argv[1], "-G") == 0) { ethereal_proto_init(); proto_registrar_dump(); exit(0); } -#ifdef HAVE_LIBPCAP - /* Set "capture_child" to indicate whether this is going to be a child - process for a "-S" capture? */ - capture_child = (strcmp(command_name, CHILD_NAME) == 0); -#endif - /* Let GTK get its args */ gtk_init (&argc, &argv); |