The SUIF library provides a generic interface for a command line parser.
The parser is defined and implemented in the files `cmdparse.h' and
`cmdparse.cc'. The SUIF program can provide a structure that
contains a list of command line options, the type of arguments these
options can handle, and pointers to data where the argument values will
be stored. The data locations will be initialized to default values
specified in the options table before parsing begins. The
parse_cmd_line
function is called with argc
, argv
,
the options table, and the number of options in the table. If the
parser finds one of the options on the command line, the option (and its
argument, if any) are removed from argv
and argc
is
appropriately adjusted. Thus when parsing is finished, argv
contains only unrecognized options (such as file names).
The following types of arguments are supported:
CLO_NOARG
CLO_INT
CLO_STRING
CLO_MULTI_STRING
For example:
static boolean quiet; static int size; static cmd_line_option my_options[] = { { CLO_NOARG, "-quiet", "", &quiet }, { CLO_INT, "-size", "8", &size } }; parse_cmd_line(argc, argv, my_options, sizeof(my_options)/sizeof(cmd_line_option));