[vorbis-dev] ogg123 / Solaris

Jeff Squyres jsquyres at lsc.nd.edu
Sun Dec 31 10:06:50 PST 2000

On Sun, 31 Dec 2000, Kenneth C. Arnold wrote:

> > getopt(3C) is in stdlib.h on Solaris. This isn't GNU getopt, though. I
> > don't know whether ogg123 uses the GNU extensions.
> ogg123 uses getopt_long. I wrote it to the GNU manpage so I don't know
> what is POSIX-compatible and what isn't, but since oggenc includes the
> GNU getopt sources anyway, I see no reason _not_ to link to those.

I don't think that it is a good idea to include sources for something that
is already in the OS/compiler.

See my post http://www.xiph.org/archives/vorbis-dev/0359.html (which might
well turn into http://www.xiph.org/archives/vorbis-dev/200012/0359.html
tomorrow...?  That's somewhat of a guess...)

Here's my reasoning:

1. getopt() already exists in Linux, Solaris, IRIX, AIX, and HP-UX.  I
think we can safely assume that it already exists in POSIX operating

2. getopt_long() only seems to exist in Linux.

3. The GNU man page for getopt() says that getopt() is a POSIX function.

4. The only difference between POSIX getopt() and GNU getopt() is that the
POSIX version assumes that all options will come first -- it will stop
processing argv when it hits a string that doesn't begin with '-'.  This
seems to be the behavior that oggenc/ogg123 expect (by the help messages
that are printed from "-h").

--> Therefore, it seems that we only need to supply getopt_long().  The
global variable optind (and friends) already exist in POSIX systems
because getopt() already exists.  More to the point -- why reinvent the
wheel when the OS/compiler already provides it?  It seems dangerous to do
this -- it doesn't [seem to] cause any problems *now*, but it may in the
future.  One can imagine linking scenarios where you get multiple symbol
definitions for optind, for example.

5. The getopt.c and getopt1.c that are provided with oggenc are not C++
friendly (although it's not hard to clean them up a bit; I did yesterday
with about 10-15 minutes of work).  As I mentioned previously,
oggenc/ogg123 are not C++, but other derrivate works are (cough cough mine
cough cough :-).

{+} Jeff Squyres
{+} squyres at cse.nd.edu
{+} Perpetual Obsessive Notre Dame Student Craving Utter Madness
{+} "I came to ND for 4 years and ended up staying for a decade"

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.

More information about the Vorbis-dev mailing list