CL_PARSE - parse a command line using an Options Table.

Usage:

#include <cl.h>
cl = cl_parse(argc, argv, optab);

Where:

int argc;
is the number of arguments on the command line.
char **argv;
points to a list of the arguments on the command line.
CL_DESCRIPTION *optab;
is an Options Table describing the possible arguments and options accepted on the command line.
CL_PARSED *cl;
points to a data structure containing the parsed command line. If "cl_parse" returns a NULL pointer, it means the command line could not be parsed.

Description:

The "cl_parse" function parses a command line, based on information given in an Options Table. For more information about constructing an Options Table, see "expl c internal parser" and "expl c internal parser macros".

The "argc" and "argv" arguments are usually the "argc" and "argv" values obtained as arguments to your program's "main" function. These give the arguments specified on the command line that invoked this program. The output of "cl_parse" is a data structure summarizing all the information obtained by parsing the command line.

If "cl_parse" cannot parse the command line at all, it returns a NULL pointer. In this case, the global variable

char *cl_fatal;

contains a message string explaining the cause of the failure.

It may also happen that "cl_parse" can parse the command line, but finds that the command line contains invalid input. For example, the command line may contain arguments which have the form of an option (like "-string") but which do not match any of the valid options in the Options Table. In this case, "cl_parse" returns a normal pointer to a parsed command line data structure. If you want to determine whether there were errors on the command line, you must call the "cl_errors" routine.

See Also:

expl c internal parser
for an overview of the parser routines.
expl c internal parser macros
for macros used in creating an Options Table.
expl c internal parser cl_errors
to determine if "cl_parse" found any errors.
expl c internal parser cl_cparse
for a routine that parses a command line and automatically reports errors.
expl c internal parser cl_ceparse
for a routine that is like "cl_cparse" but also handles environment variables.

Copyright © 1996, Thinkage Ltd.