Ethereal-dev: Re: [Ethereal-dev] Not possible to capture packets on win32 on latest svn build?

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Ulf Lamping <ulf.lamping@xxxxxx>
Date: Thu, 17 Nov 2005 09:20:23 +0100
Guy Harris wrote:

Not exiting before *re*-scanning the command line parameters is *also* a
bad idea, as one error message is better than two, and getopt() will print
error messages for at least some command-line problems.
Hmmm, so both ways don't work well :-(

(Using g_warning() for command-line errors is also a bit of a bad idea, as
it makes the error messages *REALLY* ugly:

   $ ethereal -tq
   14:19:21          Warn ethereal: Invalid time stamp type "q"
   14:19:21          Warn It must be "r" for relative, "a" for absolute,
   14:19:21          Warn "ad" for absolute with date, or "d" for delta.

The time stamp and "Warn" serve no purpose and just clutter the output,
making it harder to read.)
That's ugly, right. But having *no* output at all on Win32 is even much worse. That's the reason I've changed it that way, it was simply a quick fix.

If there's a case where getopt() returns '?' in the capture child, that's
an error.  If the command-line arguments are different, the option string
should be different, too.
The option strings are different, it's changed for the second check:

 /* 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);
 if (capture_child) {
   strcat(optstring, OPTSTRING_CHILD);
 }

We might need to move this way up before the first check. I can't remember if there was a reason not to do so.

The fix is to print a usage message in that case.  I'm compiling that fix
now, although I have to take off for a medical appointment and won't be
back for a while, so I'll check it in later.
Shouldn't be too difficult.

Regards, ULFL