competition update
This commit is contained in:
265
language_model/srilm-1.7.3/misc/doc/Opt.doc
Normal file
265
language_model/srilm-1.7.3/misc/doc/Opt.doc
Normal file
@@ -0,0 +1,265 @@
|
||||
_________________________________________________________________
|
||||
|
||||
NNAAMMEE
|
||||
Opt_Parse, Opt_PrintUsage - Manage command line options
|
||||
|
||||
SSYYNNOOPPSSIISS
|
||||
##iinncclluuddee <<ooppttiioonn..hh>>
|
||||
|
||||
int OOpptt__PPaarrssee(_a_r_g_c_, _a_r_g_v_, _o_p_t_i_o_n_A_r_r_a_y_, _n_u_m_O_p_t_i_o_n_s_, _f_l_a_g_s)
|
||||
|
||||
void OOpptt__PPrriinnttUUssaaggee(_c_o_m_m_a_n_d_N_a_m_e_, _o_p_t_i_o_n_A_r_r_a_y_, _n_u_m_O_p_t_i_o_n_s)
|
||||
|
||||
AARRGGUUMMEENNTTSS
|
||||
int _a_r_g_c (in) Number of arguments on
|
||||
command line.
|
||||
|
||||
char _*_*_a_r_g_v (in/out) Command line arguments
|
||||
passed to main program.
|
||||
|
||||
char _*_c_o_m_m_a_n_d_N_a_m_e (in) Name of the program being
|
||||
run, usually _a_r_g_v[0].
|
||||
|
||||
Option _*_o_p_t_i_o_n_A_r_r_a_y (in) An array of option
|
||||
descriptions.
|
||||
|
||||
int _n_u_m_O_p_t_i_o_n_s (in) Number of elements in
|
||||
optionArray, usually
|
||||
obtained using the
|
||||
OOpptt__NNuummbbeerr macro, e.g.
|
||||
OOpptt__NNuummbbeerr(optionArray).
|
||||
|
||||
int _f_l_a_g_s (in) If non-zero, then it spec-
|
||||
ifies one or more flags
|
||||
that control the parsing
|
||||
of arguments. Different
|
||||
flags may be OR'ed
|
||||
together. The only flags
|
||||
currently defined are
|
||||
OPT_ALLOW_CLUSTERING and
|
||||
_______________________________________O_P_T___O_P_T_I_O_N_S___F_I_R_S_T_._________
|
||||
|
||||
DDEESSCCRRIIPPTTIIOONN
|
||||
OOpptt__PPaarrssee parses the command line arguments of a program
|
||||
according to an array of option descriptions. Starting with
|
||||
_a_r_g_v[1], it parses as many options as it can and returns the
|
||||
rest of the options in the _a_r_g_v array, compacted to the
|
||||
beginning of the array (starting with _a_r_g_v[1]). The return
|
||||
value indicates how many options are returned in the _a_r_g_v
|
||||
array (including _a_r_g_v[0]). Opt_Parse returns options that
|
||||
don't start with ``-'' unless they are arguments for options
|
||||
that it parses. OOpptt__PPaarrssee also returns any options follow-
|
||||
ing an OOPPTT__RREESSTT option (see below for more details).
|
||||
|
||||
Each element of the array _o_p_t_i_o_n_A_r_r_a_y has the following
|
||||
structure: ttyyppeeddeeff ssttrruucctt Option {
|
||||
iinntt _t_y_p_e;
|
||||
cchhaarr*_k_e_y;
|
||||
cchhaarr*_v_a_l_u_e_P_t_r;
|
||||
cchhaarr*_d_o_c_M_s_g; } Option;
|
||||
|
||||
The _k_e_y field is a string that identifies this option. For
|
||||
example, if _k_e_y is ffoooo, then this Option will match a --ffoooo
|
||||
command-line option. If _k_e_y is the empty string (``'') then
|
||||
it matches a -- command-line option. If _k_e_y is NULL, the
|
||||
Option will not match any command-line options (this feature
|
||||
is only useful for OPT_DOC options). _D_o_c_M_s_g is a
|
||||
documentation string to print out as part of a help message.
|
||||
The _t_y_p_e field determines what to do when this Option is
|
||||
matched. It also determines the meaning of the _v_a_l_u_e_P_t_r
|
||||
field. _T_y_p_e should always be specified using one of the
|
||||
following macros:
|
||||
|
||||
OOPPTT__TTRRUUEE
|
||||
Treats _v_a_l_u_e_P_t_r as the address of an integer, and
|
||||
stores the value 1 in that integer.
|
||||
|
||||
OOPPTT__FFAALLSSEE
|
||||
Treats _v_a_l_u_e_P_t_r as the address of an integer and stores
|
||||
the value 0 in that integer.
|
||||
|
||||
OOPPTT__CCOONNSSTTAANNTT(_v_a_l_u_e)
|
||||
This is a generalized form of OPT_TRUE and OPT_FALSE.
|
||||
Treats _v_a_l_u_e_P_t_r as the address of an integer and stores
|
||||
_v_a_l_u_e in that integer. _V_a_l_u_e must be a positive inte-
|
||||
ger.
|
||||
|
||||
OOPPTT__IINNTT
|
||||
The next argument after the one matching _k_e_y must con-
|
||||
tain an integer string in the format accepted by ssttrrttooll
|
||||
(e.g. ``0'' and ``0x'' prefixes may be used to specify
|
||||
octal or hexadecimal numbers, respectively). _V_a_l_u_e_P_t_r
|
||||
will be treated as the address of an integer, and the
|
||||
value given by the next argument will be stored there.
|
||||
|
||||
OOPPTT__TTIIMMEE
|
||||
The next argument after the one matching _k_e_y must con-
|
||||
tain a string that is parsable as a date and time.
|
||||
Currently, only two formats are recognized: _s_e_c_o_n_d_s
|
||||
|
||||
and _y_y.._m_m.._d_d.._h_h.._m_m.._s_s
|
||||
|
||||
The first form is simply the number of seconds since
|
||||
the start of the epoch (1 January 1970, 0 hours GMT).
|
||||
The second form specifies the year (e.g., 91 or 1991),
|
||||
month (1-12), day of the month, hours (0-23), minutes
|
||||
(0-59), and seconds (0-59). All fields must be speci-
|
||||
fied. _V_a_l_u_e_P_t_r will be treated as the address of a
|
||||
ttiimmee__tt (defined in <<ttiimmee..hh>>), and the given time will
|
||||
be stored there. All times are in terms of the current
|
||||
timezone and daylight savings rules.
|
||||
|
||||
Note that this flavor can clobber the static buffer
|
||||
used by the llooccaallttiimmee library routine.
|
||||
|
||||
OOPPTT__FFLLOOAATT
|
||||
The next argument after the one matching _k_e_y must con-
|
||||
tain a floating-point number in the format accepted by
|
||||
ssttrrttooll. _V_a_l_u_e_P_t_r will be treated as the address of an
|
||||
double-precision floating point value, and the value
|
||||
given by the next argument will be stored there.
|
||||
|
||||
OOPPTT__SSTTRRIINNGG
|
||||
Treats _v_a_l_u_e_P_t_r as the address of a (char *), and
|
||||
stores a pointer to the next argument in the location
|
||||
pointed to by _v_a_l_u_e_P_t_r.
|
||||
OOPPTT__DDOOCC
|
||||
This option is intended primarily as a way of printing
|
||||
extra documentation during help message printouts. It
|
||||
isn't normally used as an actual option (and normally
|
||||
its _k_e_y field is NULL). If it is invoked as an option,
|
||||
then the same thing happens as for the ``-?'' option:
|
||||
descriptions get printed for all options in _o_p_t_i_o_n_A_r_r_a_y
|
||||
and OOpptt__PPaarrssee calls exit(0) to terminate the process.
|
||||
|
||||
OOPPTT__RREESSTT
|
||||
This option is used by programs that allow the last
|
||||
several of their options to be the name and/or options
|
||||
for some other program. If an OOPPTT__RREESSTT option is
|
||||
found, then OOpptt__PPaarrssee doesn't process any of the
|
||||
remaining arguments; it returns them all at the begin-
|
||||
ning of _a_r_g_v. In addition, OOpptt__PPaarrssee treats _v_a_l_u_e_P_t_r
|
||||
as the address of an integer value, and stores in that
|
||||
value the index of the first of the OOPPTT__RREESSTT options in
|
||||
the returned _a_r_g_v. This allows the program to distin-
|
||||
guish the OOPPTT__RREESSTT options from other unprocessed
|
||||
options that preceeded the OOPPTT__RREESSTT.
|
||||
|
||||
OOPPTT__FFUUNNCC
|
||||
When one of these options is encountered, _v_a_l_u_e_P_t_r is
|
||||
treated as the address of a function which is then
|
||||
called with the following calling sequence: iinntt
|
||||
_f_u_n_c_(_o_p_t_S_t_r_i_n_g_, _n_e_x_t_A_r_g_)
|
||||
cchhaarr *_o_p_t_S_t_r_i_n_g;
|
||||
cchhaarr *_n_e_x_t_A_r_g; { }
|
||||
|
||||
The _o_p_t_S_t_r_i_n_g parameter points to the current option,
|
||||
and _n_e_x_t_A_r_g points to the next option from _a_r_g_v (or
|
||||
NULL if there aren't any more options in _a_r_g_v. If _f_u_n_c
|
||||
uses _n_e_x_t_A_r_g as an argument to the current option (so
|
||||
that Opt_Parse should skip it), then it should return
|
||||
1. Otherwise it should return 0.
|
||||
|
||||
OOPPTT__GGEENNFFUUNNCC
|
||||
Treat _v_a_l_u_e_P_t_r as the address of a function and pass
|
||||
all of the remaining arguments to it in the following
|
||||
way: iinntt _g_e_n_f_u_n_c_(_o_p_t_S_t_r_i_n_g_, _a_r_g_c_, _a_r_g_v_)
|
||||
cchhaarr *_o_p_t_S_t_r_i_n_g;
|
||||
iinntt _a_r_g_c;
|
||||
cchhaarr **_a_r_g_v; { }
|
||||
|
||||
_A_r_g_c and _a_r_g_v refer to all of the options after the one
|
||||
that triggered the call, and _o_p_t_S_t_r_i_n_g points to the
|
||||
triggering option. _G_e_n_f_u_n_c should behave in a fashion
|
||||
similar to OOpptt__PPaarrssee: parse as many of the remaining
|
||||
arguments as it can, then return any that are left by
|
||||
compacting them to the beginning of _a_r_g_v (starting at
|
||||
_a_r_g_v[0]). _G_e_n_f_u_n_c should return a count of how many
|
||||
arguments are left in _a_r_g_v_; OOpptt__PPaarrssee will process
|
||||
them.
|
||||
|
||||
|
||||
FFLLAAGGSS
|
||||
OOPPTT__AALLLLOOWW__CCLLUUSSTTEERRIINNGG
|
||||
This will permit several options to be clustered
|
||||
together with a single ``-'', e.g., ``foo -abc'' will
|
||||
be handled the same way as ``foo -a -b -c''.
|
||||
OPT_ALLOW_CLUSTERING is likely to cause confusing
|
||||
behavior unless each option is identified with a single
|
||||
character.
|
||||
|
||||
|
||||
OOPPTT__OOPPTTIIOONNSS__FFIIRRSSTT
|
||||
This causes OOpptt__PPaarrssee to stop parsing the command line
|
||||
anytime something that is not an option is detected.
|
||||
Thus, a program that takes some options followed by a
|
||||
command to execute (along with that command's options)
|
||||
can parse its own options using OPT_OPTIONS_FIRST.
|
||||
When the command to execute is encountered, assuming it
|
||||
does not begin with a hyphen, OOpptt__PPaarrssee will return the
|
||||
command and its arguments starting at _a_r_g_v[1], ignoring
|
||||
any arguments with hyphens following the first non-
|
||||
option.
|
||||
|
||||
UUSSAAGGEE MMEESSSSAAGGEE
|
||||
OOpptt__PPrriinnttUUssaaggee may be invoked to print out all the documen-
|
||||
tation strings (plus option names and default values) for a
|
||||
command's options. If OOpptt__PPaarrssee encounters an option ``-?''
|
||||
or ``-help'', then it will call OOpptt__PPrriinnttUUssaaggee and exit.
|
||||
Note: in some shells the question-mark must be escaped
|
||||
(e.g., ``foo -\?'' in _c_s_h).
|
||||
|
||||
|
||||
EEXXAAMMPPLLEE
|
||||
Here is an example definition of a set of option descrip-
|
||||
tions and some sample command lines that use the options.
|
||||
Note the effect on argc and argv; command arguments that
|
||||
get interpreted as options or option values are eliminated
|
||||
from argv, and argc is updated to reflect reduced number of
|
||||
arguments. /*
|
||||
* Define and set default values for globals.
|
||||
*/ Boolean debugFlag = FALSE; int numReps = 100; char
|
||||
defaultFileName[] = "out"; char *fileName = defaultFileName;
|
||||
Boolean exec = FALSE;
|
||||
|
||||
/*
|
||||
* Define option descriptions.
|
||||
*/ Option optionArray[] = {
|
||||
OPT_TRUE, "X", (char *) &debugFlag, "Turn on debugging
|
||||
printfs",
|
||||
OPT_INT, "N", (char *) &numReps, "Number of repeti-
|
||||
tions",
|
||||
OPT_STRING, "of", (char *) &fileName, "Output filename",
|
||||
OPT_REST, "x", (char *) &exec,
|
||||
"File to exec, followed by any arguments (must be
|
||||
last argument).", };
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[]; {
|
||||
Opt_Parse(argc, argv, optionArray,
|
||||
Opt_Number(optionArray),
|
||||
OPT_ALLOW_CLUSTERING);
|
||||
|
||||
/*
|
||||
* the rest of the program.
|
||||
*/ }
|
||||
|
||||
Note that default values can be assigned to option vari-
|
||||
ables. Also, numOptions gets calculated by the compiler in
|
||||
this example. Here are some example command lines and their
|
||||
effects. prog -N 200 infile # just sets the numReps
|
||||
variable to 200 prog -of out200 infile # sets fileName to
|
||||
reference "out200" prog -XN 10 infile # sets the debug
|
||||
flag, also sets numReps In all of the above examples, the
|
||||
return value from Opt_Parse will be 2, _a_r_g_v[0] will be
|
||||
``prog'', _a_r_g_v[1] will be ``infile'', and _a_r_g_v[2] will be
|
||||
NULL.
|
||||
|
||||
KKEEYYWWOORRDDSS
|
||||
arguments, command line, options
|
||||
|
||||
|
||||
|
||||
|
||||
[65;1H[K
|
||||
285
language_model/srilm-1.7.3/misc/doc/Opt.man
Normal file
285
language_model/srilm-1.7.3/misc/doc/Opt.man
Normal file
@@ -0,0 +1,285 @@
|
||||
'\" Copyright 1991 Regents of the University of California
|
||||
'\" Permission to use, copy, modify, and distribute this
|
||||
'\" documentation for any purpose and without fee is hereby
|
||||
'\" granted, provided that this notice appears in all copies.
|
||||
'\" The University of California makes no representations about
|
||||
'\" the suitability of this material for any purpose. It is
|
||||
'\" provided "as is" without express or implied warranty.
|
||||
'\"
|
||||
'\" $Header: /home/srilm/CVS/srilm/misc/doc/Opt.man,v 1.4 1991/01/28 17:00:56 kupfer Exp $ SPRITE (Berkeley)
|
||||
'/"
|
||||
.so \*(]ltmac.sprite
|
||||
.HS Opt lib
|
||||
.BS
|
||||
.SH NAME
|
||||
Opt_Parse, Opt_PrintUsage \- Manage command line options
|
||||
.SH SYNOPSIS
|
||||
\fB#include <option.h>\fR
|
||||
.sp
|
||||
int
|
||||
\fBOpt_Parse\fR(\fIargc, argv, optionArray, numOptions, flags\fR)
|
||||
.sp
|
||||
void
|
||||
\fBOpt_PrintUsage\fR(\fIcommandName, optionArray, numOptions\fR)
|
||||
.SH ARGUMENTS
|
||||
.AS Option *optionArray
|
||||
.AP int argc in
|
||||
Number of arguments on command line.
|
||||
.AP char **argv in/out
|
||||
Command line arguments passed to main program.
|
||||
.AP char *commandName in
|
||||
Name of the program being run, usually \fIargv\fR[0].
|
||||
.AP Option *optionArray in
|
||||
An array of option descriptions.
|
||||
.AP int numOptions in
|
||||
Number of elements in optionArray, usually obtained using the
|
||||
\fBOpt_Number\fR macro, e.g. \fBOpt_Number\fR(optionArray).
|
||||
.AP int flags in
|
||||
If non-zero, then it specifies one or more flags that control the
|
||||
parsing of arguments. Different flags may be OR'ed together. The
|
||||
only flags currently defined are OPT_ALLOW_CLUSTERING and OPT_OPTIONS_FIRST.
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
\fBOpt_Parse\fR parses the command line arguments of a program according
|
||||
to an array of option descriptions. Starting with \fIargv\fR[1], it parses
|
||||
as many options as it can and returns the rest of the options in
|
||||
the \fIargv\fR array, compacted to the beginning of the array (starting
|
||||
with \fIargv\fR[1]). The return value indicates how many options are
|
||||
returned in the \fIargv\fR array (including \fIargv\fR[0]).
|
||||
Opt_Parse returns options that don't start with ``-'' unless they
|
||||
are arguments for options that it parses. \fBOpt_Parse\fR also returns
|
||||
any options following an \fBOPT_REST\fR option (see below for more details).
|
||||
.PP
|
||||
Each element of the array
|
||||
\fIoptionArray\fR has the following structure:
|
||||
.DS
|
||||
.ta 2c
|
||||
\fBtypedef struct\fR Option {
|
||||
\fBint\fR \fItype\fR;
|
||||
\fBchar\fR *\fIkey\fR;
|
||||
\fBchar\fR *\fIvaluePtr\fR;
|
||||
\fBchar\fR *\fIdocMsg\fR;
|
||||
} Option;
|
||||
.DE
|
||||
.LP
|
||||
The \fIkey\fR field is a string that identifies this option. For
|
||||
example, if \fIkey\fR is \fBfoo\fR, then this Option will match
|
||||
a \fB\-foo\fR command-line option. If \fIkey\fR is the empty
|
||||
string (``'') then it matches a \fB\-\fR command-line option.
|
||||
If \fIkey\fR is NULL, the Option
|
||||
will not match any command-line options (this feature is only useful
|
||||
for OPT_DOC options).
|
||||
\fIDocMsg\fR is a documentation string to print out as part of a
|
||||
help message.
|
||||
The \fItype\fR field determines what to do when this Option is
|
||||
matched. It also determines the meaning of the \fIvaluePtr\fR
|
||||
field. \fIType\fR should always be specified using one of the
|
||||
following macros:
|
||||
.TP
|
||||
\fBOPT_TRUE\fR
|
||||
Treats \fIvaluePtr\fR as the address of an integer, and stores
|
||||
the value 1 in that integer.
|
||||
.TP
|
||||
\fBOPT_FALSE\fR
|
||||
Treats \fIvaluePtr\fR as the address of an integer and stores
|
||||
the value 0 in that integer.
|
||||
.TP
|
||||
\fBOPT_CONSTANT\fR(\fIvalue\fR)
|
||||
This is a generalized form of OPT_TRUE and OPT_FALSE. Treats
|
||||
\fIvaluePtr\fR as the address of an integer and stores \fIvalue\fR
|
||||
in that integer. \fIValue\fR must be a positive integer.
|
||||
.TP
|
||||
\fBOPT_INT\fR
|
||||
The next argument after the one matching \fIkey\fR must contain an
|
||||
integer string in the format accepted by \fBstrtol\fR (e.g. ``0''
|
||||
and ``0x'' prefixes may be used to specify octal or hexadecimal
|
||||
numbers, respectively). \fIValuePtr\fR
|
||||
will be treated as the address of an integer, and the value given
|
||||
by the next argument will be stored there.
|
||||
.TP
|
||||
\fBOPT_TIME\fR
|
||||
The next argument after the one matching \fIkey\fR must contain a
|
||||
string that is parsable as a date and time. Currently, only two
|
||||
formats are recognized:
|
||||
.DS
|
||||
\fIseconds\fR
|
||||
.DE
|
||||
.IP
|
||||
and
|
||||
.DS
|
||||
\fIyy\fB.\fImm\fB.\fIdd\fB.\fIhh\fB.\fImm\fB.\fIss\fR
|
||||
.DE
|
||||
.IP
|
||||
The first form is simply the number of seconds since the start of the
|
||||
epoch (1 January 1970, 0 hours GMT). The second form specifies the
|
||||
year (e.g., 91 or 1991),
|
||||
month (1-12), day of the month, hours (0-23), minutes (0-59), and
|
||||
seconds (0-59). All fields must be specified.
|
||||
\fIValuePtr\fR
|
||||
will be treated as the address of a
|
||||
.B time_t
|
||||
(defined in
|
||||
.BR <time.h> ),
|
||||
and the given time will be stored there.
|
||||
All times are in terms of the current timezone and daylight savings
|
||||
rules.
|
||||
.IP
|
||||
Note that this flavor can clobber the static buffer used by the
|
||||
.B localtime
|
||||
library routine.
|
||||
.TP
|
||||
\fBOPT_FLOAT\fR
|
||||
The next argument after the one matching \fIkey\fR must contain a
|
||||
floating-point number in the format accepted by \fBstrtol\fR.
|
||||
\fIValuePtr\fR will be treated as the address of an double-precision
|
||||
floating point value, and the
|
||||
value given by the next argument will be stored there.
|
||||
.TP
|
||||
\fBOPT_STRING\fR
|
||||
Treats \fIvaluePtr\fR as the address of a (char *), and stores a pointer
|
||||
to the next argument in the location
|
||||
pointed to by \fIvaluePtr\fR.
|
||||
.TP
|
||||
\fBOPT_DOC\fR
|
||||
This option is intended primarily as a way of printing extra documentation
|
||||
during help message printouts. It isn't normally used as an actual
|
||||
option (and normally its \fIkey\fR field is NULL).
|
||||
If it is invoked as an option, then the same thing happens as for
|
||||
the ``-?'' option: descriptions get printed for all options in
|
||||
\fIoptionArray\fR and \fBOpt_Parse\fR calls exit(0) to terminate the process.
|
||||
.TP
|
||||
\fBOPT_REST\fR
|
||||
This option is used by programs that allow the last several of their
|
||||
options to be the name and/or options for some other program. If
|
||||
an \fBOPT_REST\fR option is found, then \fBOpt_Parse\fR doesn't process any
|
||||
of the remaining arguments; it returns them all at the beginning of \fIargv\fR.
|
||||
In addition, \fBOpt_Parse\fR treats \fIvaluePtr\fR as the address of an
|
||||
integer value, and stores in that value the index of the first of the
|
||||
\fBOPT_REST\fR options in the returned \fIargv\fR. This allows the
|
||||
program to distinguish the \fBOPT_REST\fR options from other
|
||||
unprocessed options that preceeded the \fBOPT_REST\fR.
|
||||
.TP
|
||||
\fBOPT_FUNC\fR
|
||||
When one of these options is encountered, \fIvaluePtr\fR is treated
|
||||
as the address of a function which is then called
|
||||
with the following calling sequence:
|
||||
.DS
|
||||
.ta 1c 2c 3c 4c 5c 6c
|
||||
\fBint\fI
|
||||
func(optString, nextArg)
|
||||
\fBchar\fR *\fIoptString\fR;
|
||||
\fBchar\fR *\fInextArg\fR;
|
||||
{
|
||||
}
|
||||
.DE
|
||||
.IP
|
||||
The \fIoptString\fR parameter points to the current option, and
|
||||
\fInextArg\fR points to the next option from \fIargv\fR (or NULL
|
||||
if there aren't any more options in \fIargv\fR. If \fIfunc\fR
|
||||
uses \fInextArg\fR as an argument to the current option (so that
|
||||
Opt_Parse should skip it), then it should return 1. Otherwise it
|
||||
should return 0.
|
||||
.TP
|
||||
\fBOPT_GENFUNC\fR
|
||||
Treat \fIvaluePtr\fR as the address of a function and pass all of the
|
||||
remaining arguments to it in the following way:
|
||||
.DS
|
||||
.ta 1c 2c 3c 4c 5c 6c
|
||||
\fBint\fI
|
||||
genfunc(optString, argc, argv)
|
||||
\fBchar\fR *\fIoptString\fR;
|
||||
\fBint\fR \fIargc\fR;
|
||||
\fBchar\fR **\fIargv\fR;
|
||||
{
|
||||
}
|
||||
.DE
|
||||
.IP
|
||||
\fIArgc\fR and \fIargv\fR refer to all of the options after the
|
||||
one that triggered the call, and \fIoptString\fR points to the
|
||||
triggering option. \fIGenfunc\fR should behave in a fashion similar
|
||||
to \fBOpt_Parse\fR: parse as many of the remaining arguments as it can,
|
||||
then return any that are left by compacting them to the beginning of
|
||||
\fIargv\fR (starting at \fIargv\fR[0]). \fIGenfunc\fR
|
||||
should return a count of how many arguments are left in \fIargv;
|
||||
\fBOpt_Parse\fR will process them.
|
||||
|
||||
.SH "FLAGS"
|
||||
.IP \fBOPT_ALLOW_CLUSTERING\fR
|
||||
This will
|
||||
permit several options to be clustered together with a
|
||||
single ``-'', e.g., ``foo -abc'' will be handled the same way as
|
||||
``foo -a -b -c''. OPT_ALLOW_CLUSTERING is likely to cause confusing
|
||||
behavior unless each option is identified with a single character.
|
||||
.IP \fBOPT_OPTIONS_FIRST\fR
|
||||
This causes \fBOpt_Parse\fR to stop parsing the command line anytime something
|
||||
that is not an option is detected. Thus, a program that takes some options
|
||||
followed by a command to execute (along with that command's options) can
|
||||
parse its own options using OPT_OPTIONS_FIRST. When the command to execute is
|
||||
encountered, assuming it does not begin with a hyphen, \fBOpt_Parse\fR will
|
||||
return the command and its arguments starting at \fIargv\fR[1], ignoring
|
||||
any arguments with hyphens following the first non-option.
|
||||
.SH "USAGE MESSAGE"
|
||||
.PP
|
||||
\fBOpt_PrintUsage\fR may be invoked to print out all the documentation strings
|
||||
(plus option names and default values) for a command's options. If
|
||||
\fBOpt_Parse\fR encounters an option ``-?'' or ``-help'', then it will call
|
||||
\fBOpt_PrintUsage\fR
|
||||
and exit. Note: in some shells the question-mark must be escaped
|
||||
(e.g., ``foo -\e?'' in \fIcsh\fR).
|
||||
|
||||
.SH EXAMPLE
|
||||
.PP
|
||||
Here is an example definition of a set of option descriptions and
|
||||
some sample command lines that use the options. Note the effect
|
||||
on argc and argv; command arguments that get interpreted as
|
||||
options or option values are eliminated from argv, and argc
|
||||
is updated to reflect reduced number of arguments.
|
||||
.DS
|
||||
/*
|
||||
* Define and set default values for globals.
|
||||
*/
|
||||
Boolean debugFlag = FALSE;
|
||||
int numReps = 100;
|
||||
char defaultFileName[] = "out";
|
||||
char *fileName = defaultFileName;
|
||||
Boolean exec = FALSE;
|
||||
|
||||
/*
|
||||
* Define option descriptions.
|
||||
*/
|
||||
Option optionArray[] = {
|
||||
OPT_TRUE, "X", (char *) &debugFlag, "Turn on debugging printfs",
|
||||
OPT_INT, "N", (char *) &numReps, "Number of repetitions",
|
||||
OPT_STRING, "of", (char *) &fileName, "Output filename",
|
||||
OPT_REST, "x", (char *) &exec,
|
||||
"File to exec, followed by any arguments (must be last argument).",
|
||||
};
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
Opt_Parse(argc, argv, optionArray, Opt_Number(optionArray),
|
||||
OPT_ALLOW_CLUSTERING);
|
||||
|
||||
/*
|
||||
* the rest of the program.
|
||||
*/
|
||||
}
|
||||
.DE
|
||||
.PP
|
||||
Note that default values can be assigned to option variables.
|
||||
Also, numOptions gets calculated by the compiler in this example.
|
||||
Here are some example command lines and their effects.
|
||||
.DS
|
||||
prog -N 200 infile # just sets the numReps variable to 200
|
||||
prog -of out200 infile # sets fileName to reference "out200"
|
||||
prog -XN 10 infile # sets the debug flag, also sets numReps
|
||||
.DE
|
||||
In all of the above examples, the return value from Opt_Parse will be 2,
|
||||
\fIargv\fR[0] will be ``prog'', \fIargv\fR[1] will be ``infile'',
|
||||
and \fIargv\fR[2] will be NULL.
|
||||
|
||||
.SH KEYWORDS
|
||||
arguments, command line, options
|
||||
213
language_model/srilm-1.7.3/misc/doc/tmac.sprite
Normal file
213
language_model/srilm-1.7.3/misc/doc/tmac.sprite
Normal file
@@ -0,0 +1,213 @@
|
||||
.\" This file contains extra Ditroff macros used in Sprite man pages:
|
||||
.\"
|
||||
.\" .HS name section [date [version]]
|
||||
.\" Replacement for .TH in other man pages. See below for valid
|
||||
.\" section names.
|
||||
.\"
|
||||
.\" .LG
|
||||
.\" Increase font size; opposite of .SM
|
||||
.\"
|
||||
.\" .AP type name in/out [indent]
|
||||
.\" Start paragraph describing an argument to a library procedure.
|
||||
.\" type is type of argument (int, etc.), in/out is either "in", "out",
|
||||
.\" or "in/out" to describe whether procedure reads or modifies arg,
|
||||
.\" and indent is equivalent to second arg of .IP (shouldn't ever be
|
||||
.\" needed; use .AS below instead)
|
||||
.\"
|
||||
.\" .AS [type [name]]
|
||||
.\" Give maximum sizes of arguments for setting tab stops. Type and
|
||||
.\" name are examples of largest possible arguments that will be passed
|
||||
.\" to .AP later. If args are omitted, default tab stops are used.
|
||||
.\"
|
||||
.\" .BS
|
||||
.\" Start box enclosure. From here until next .BE, everything will be
|
||||
.\" enclosed in one large box.
|
||||
.\"
|
||||
.\" .BE
|
||||
.\" End of box enclosure.
|
||||
.\"
|
||||
.\" .VS
|
||||
.\" Begin vertical sidebar, for use in marking newly-changed parts
|
||||
.\" of man pages.
|
||||
.\"
|
||||
.\" .VE
|
||||
.\" End of vertical sidebar.
|
||||
.\"
|
||||
' # Heading for Sprite man pages
|
||||
.de HS
|
||||
.PD
|
||||
.DT
|
||||
.AS
|
||||
.if n .nr IN .5i
|
||||
.if t .nr IN .5i
|
||||
.nr LL \\n(.l
|
||||
.ds ]S UNKNOWN SECTION (\\$2)
|
||||
.if '\\$2'cmds' .ds ]S User Commands
|
||||
.if '\\$2'lib' .ds ]S C Library Procedures
|
||||
.if '\\$2'dev' .ds ]S Devices
|
||||
.if '\\$2'tcl' .ds ]S Tcl Command Language Library
|
||||
.if '\\$2'admin' .ds ]S Administrative Commands
|
||||
.if '\\$2'daemons' .ds ]S Daemons
|
||||
.if '\\$2'files' .ds ]S File Formats
|
||||
.ds ]H \\$1
|
||||
.ds ]D \\*(]S
|
||||
.ie '\\$3'' .ds ]L Printed:\\ \\ \\*(DY
|
||||
.el .ds ]L Modified:\\ \\ \\$3
|
||||
.if t .ie '\\$4'' .ds ]W Sprite version 1.0
|
||||
.if t .el .ds ]W Sprite version \\$4
|
||||
.if n .ie '\\$4'' .ds ]W Sprite v.1.0
|
||||
.if n .el .ds ]W Sprite v.\\$4
|
||||
.if !"\\$3"" .ds ]L \\$3
|
||||
.wh 0 }H
|
||||
.if t .wh -1i }B
|
||||
.if n .wh -1.167i }F
|
||||
.if \\n(nl .bp 1
|
||||
.em }M
|
||||
.}E
|
||||
.DT
|
||||
.nr )I .5i
|
||||
.nr )R 0
|
||||
.ad b
|
||||
..
|
||||
' # Increase point size 1 tick
|
||||
.de LG
|
||||
.ps +1
|
||||
.it 1 }N
|
||||
.if !"\\$1"" \&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6
|
||||
..
|
||||
' # Start an argument description
|
||||
.de AP
|
||||
.ie !"\\$4"" .TP \\$4
|
||||
.el \{\
|
||||
. ie !"\\$2"" .TP \\n()Cu
|
||||
. el .TP 15
|
||||
.\}
|
||||
.ie !"\\$3"" \{\
|
||||
.ta \\n()Au \\n()Bu
|
||||
\&\\$1 \\fI\\$2\\fP (\\$3)
|
||||
.\".b
|
||||
.\}
|
||||
.el \{\
|
||||
.br
|
||||
.ie !"\\$2"" \{\
|
||||
\&\\$1 \\fI\\$2\\fP
|
||||
.\}
|
||||
.el \{\
|
||||
\&\\fI\\$1\\fP
|
||||
.\}
|
||||
.\}
|
||||
.DT
|
||||
..
|
||||
' # define tabbing values for .AP
|
||||
.de AS
|
||||
.nr )A 10n
|
||||
.if !"\\$1"" .nr )A \\w'\\$1'u+3n
|
||||
.nr )B \\n()Au+15n
|
||||
.\"
|
||||
.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
|
||||
.nr )C \\n()Bu+\\w'(in/out)'u+2n
|
||||
..
|
||||
' # BS - start boxed text
|
||||
.de BS
|
||||
.br
|
||||
.mk )a
|
||||
.ds )b 1
|
||||
.if n .nf
|
||||
.if n .ti 0
|
||||
.if n \l'\\n(.lu\(ul'
|
||||
.if n .fi
|
||||
..
|
||||
' # Special macro to handle page bottom: finish off current
|
||||
' # box/sidebar if in box/sidebar mode, then invoked standard
|
||||
' # page bottom macro.
|
||||
.de }B
|
||||
.if '\\*()b'1' \{\
|
||||
.ev 1
|
||||
'ti 0
|
||||
'nf
|
||||
.if t \h'-1.5n'\L'|\\n()au-1.5v'\l'\\n(.lu+3n\(ul'\L'-|\\n()au+1.5v'\l'|0u-1.5n\(ul'
|
||||
'sp -1
|
||||
.ev
|
||||
'fi
|
||||
.\}
|
||||
.if '\\*()v'2' \{\
|
||||
.if t \{\
|
||||
.ev 1
|
||||
'ti 0
|
||||
'nf
|
||||
.br
|
||||
\h'\\n(.lu+3n'\v'-1v'\L'|\\n()bu-1v\(br'\v'-|\\n()bu+2v'\h'|0u'
|
||||
'sp -1
|
||||
'fi
|
||||
.ev
|
||||
.\}
|
||||
.\}
|
||||
.}F
|
||||
..
|
||||
' # What to do when the head of the page occurs during boxed text
|
||||
' # or vertical sidebar: update starting position for box/sidebar.
|
||||
.am }H
|
||||
.mk )a
|
||||
.mk )b
|
||||
..
|
||||
' # BE - end boxed text (draw box now)
|
||||
.de BE
|
||||
.sp -1
|
||||
.nf
|
||||
.ti 0
|
||||
.ie n \l'\\n(.lu\(ul'
|
||||
.el \{
|
||||
\h'-1.5n'\L'|\\n()au-1.5v'\l'\\n(.lu+3n\(ul'\L'-|\\n()au+1.5v'\l'|0u-1.5n\(ul'
|
||||
.\" \h = move left 1.5n
|
||||
.\" \L = draw up, len= )a units + 1.5v
|
||||
.\" \L draws a line, arg = distance. if negative, draws up.
|
||||
.\" The position in reg. )a is used to draw the vertical lines.
|
||||
.\" |\\n)au = distance from current loc. to )a (negative distance)
|
||||
.\" -1.5v = distance above )a since there is text at )a's location
|
||||
.\" \l = draw right, len= cur. line length + 3n using underrule
|
||||
.\" \L = draw down, len= )a units + 1.5v
|
||||
.\" \l = draw left, back to original spot
|
||||
.\}
|
||||
.fi
|
||||
.br
|
||||
.ds )b 0
|
||||
..
|
||||
' # VS - start vertical sidebar
|
||||
.de VS
|
||||
.mk )b
|
||||
.if n 'mc \s12\(br\s0
|
||||
.if t \{\
|
||||
.ds )v 2
|
||||
.\}
|
||||
..
|
||||
' # VE - end of vertical sidebar
|
||||
.de VE
|
||||
.if n 'mc
|
||||
.if t \{\
|
||||
.ev 1
|
||||
.nf
|
||||
.ti 0
|
||||
\h'|\\n(.lu+3n'\L'|\\n()bu-1v\(bv'\v'-|\\n()bu+1v'\h'-|\\n(.lu+3n'
|
||||
.sp -1
|
||||
.fi
|
||||
.ev
|
||||
.\}
|
||||
.ds )v 0
|
||||
..
|
||||
.\"
|
||||
.\" Define the string DY to be the current date
|
||||
.\" format: month day, year
|
||||
.\"
|
||||
.if \n(mo-0 .ds MO January
|
||||
.if \n(mo-1 .ds MO February
|
||||
.if \n(mo-2 .ds MO March
|
||||
.if \n(mo-3 .ds MO April
|
||||
.if \n(mo-4 .ds MO May
|
||||
.if \n(mo-5 .ds MO June
|
||||
.if \n(mo-6 .ds MO July
|
||||
.if \n(mo-7 .ds MO August
|
||||
.if \n(mo-8 .ds MO September
|
||||
.if \n(mo-9 .ds MO October
|
||||
.if \n(mo-10 .ds MO November
|
||||
.if \n(mo-11 .ds MO December
|
||||
.ds DY \*(MO \n(dy, 19\n(yr
|
||||
Reference in New Issue
Block a user