Go to the previous, next section.

Command-Line Parser

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:

No argument is expected. The default value is 0. If the argument is present, the value becomes 1.

A single integer is expected.

A single string is expected.

A single string is expected for each occurrence of this option, but the option can be repeated with different arguments.

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,

Go to the previous, next section.