.\" -*-nroff-*-
-.TH mdwopt 3 "6 July 1999" mLib
+.TH mdwopt 3 "6 July 1999" "Straylight/Edgeware" "mLib utilities library"
.SH "NAME"
mdwopt \- command-line option parser
.\" @mdwopt
is considered to be a non-option, since it usually represents standard
input or output as a filename, and the word containing only a
double-dash
-.RB ` \-\-'
+.RB ` \-\- '
is used to mark all following words as being non-options regardless of
their initial character.
.PP
.SS "Short option syntax"
Short options are the sort which Unix has known for ages: an option is a
single letter, preceded by a
-.RB ` \-| '.
+.RB ` \- '.
Short options can be joined together to save space (and possibly to make
silly words): e.g., instead of giving options
.RB ` "\-x \-y" ',
.PP
The data block is a structure containing at least the following members:
.TP
-.B arg
+.B "char *arg"
Pointer to the argument of the current option, or null. Argument
strings persist for as long as the underlying command line argument
array
.I argv
does, so it's usually safe just to remember the pointer.
.TP
-.B opt
+.B "int opt"
Value of the current option
.TP
-.B int
+.B "int ind"
Must be initialized to 0 before the first call to
.BR mdwopt .
After the last call, it is the index into
.I argv
of the first nonoption argument.
.TP
-.B err
+.B "int err"
Set to nonzero to allow
.B mdwopt
to emit error messages about illegal option syntax. (This would be a
.B getopt
compatibility.)
.TP
-.B prog
+.B "char *prog"
Contains the program's name, stripped of any path prefix. This is an
obsolete feature: the
.BR quis (3)
.B err
and
.B ind
-members of the structure must be initialized
+members of the structure must be initialized.
.PP
The arguments
.I argc
.B arg
member of the data block; a null pointer is stored if there was no
argument. If a negated option was found, the option character is
-returned ORred with
+returned ORed with
.B OPTF_NEGATED
(bit 8 set).
.SS "Long option parsing"
.BR "struct option" ,
which contains the following members (in order):
.TP
-.B name
+.B "const char *name"
Pointer to the option's name.
.TP
-.B has_arg
+.B "int has_arg"
A flags word describing the option. (The name is historical.)
.TP
-.B flag
+.B "int *flag"
Address of the flag variable to use when this option is matched.
.TP
-.B val
+.B "int val"
Value to store or return when this option is matched.
.PP
The table is terminated by an entry whose
possibly with bit 8 set if the option was
negated.
.PP
-Arguments for long options are stored in the
+Arguments from long options are stored in the
.B arg
+member of the data block.
.SS "Other optional features"
The
.I flags