CL_CEPARSE - parse command line and environment variable.

Usage:

#include <cl.h>
cl = cl_ceparse(argc, argv, optab, env_name, header);

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.
char *env_name;
points to a string that contains the name of an environment variable.
char *header;
points to a string that should be output at the beginning of any error diagnostics.
CL_PARSED *cl;
points to a data structure containing the parsed command line.

Description:

The "cl_ceparse" function parses a command line, in a similar way to "cl_cparse". For more information, see "expl c internal parser cl_cparse".

The one significant difference between "cl_ceparse" and "cl_cparse" is that "cl_ceparse" uses an environment variable value as well as the other arguments. The function uses "getenv" to determine the value of the specified variable, then begins parsing this value in the same way that it would parse a command line. After this, "cl_ceparse" parses the true command line. If an argument on the command line matches an argument from the environment variable, the command line argument overwrites the setting inside the "cl" structure. Therefore, settings from the environment variable override any defaults set in the original Options Table, but settings on the command line override any corresponding settings in the environment variable.

Like "cl_cparse", "cl_ceparse" outputs usage information if it finds +HELP or -HELP, and terminates the program. If "cl_ceparse" encounters any parsing errors, it calls "cl_errors" to output appropriate diagnostics, then terminates the program.

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_parse
for the basic routine that parses a command line.
expl c internal parser cl_cparse
for a routine that parses a command line and automatically reports errors.

Copyright © 1996, Thinkage Ltd.