ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: [Wireshark-dev] Switching to getopt_long() - or to g_option?

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Mon, 14 Apr 2008 13:26:05 -0700
bugzilla-daemon@xxxxxxxxxxxxx wrote:

--- Comment #1 from Andrew Feren <acferen@xxxxxxxxx>  2008-04-14 11:35:31 GMT ---
The choice of -x for the commandline argument was arbitrary.  I didn't see any
particular reasoning for the other switch choices so I started at z and worked
backwards until I found an unused letter.

Should we switch from using getopt() to using getopt_long()? It's available in most Linux distributions (as it's in glibc), newer versions of most if not all *BSDs as well as Mac OS X, and newer versions of Solaris, and we could supply the glibc version on platforms that lack it (we're already supplying the glibc version of getopt() on Windows, which is probably the only platform we run on that lacks getopt()).

That would let us have multi-character strings for options, and still support single-character aliases for the options we already support (and add single-character aliases for options we think would be frequently used).

Or, alternatively, now that we've dropped support for GLib 1.2[.x], we could just use the GOptions command-line parser in GLib, although that would also require that we drop support for GLib 2.x prior to GLib 2.6. For Wireshark, that *might* let us use gtk_init_with_args() rather than gtk_init(), if we do the main argument parsing at the time we're calling gtk_init(), although we still have to do the "pre-parse" before calling gtk_init_with_args().