Home Libraries Author Links

Abstract Data Type StmCmdLine
[Getopts: Parse Command Line and Generate Manual Text]

Collaboration diagram for Abstract Data Type StmCmdLine:

Detailed Description

A valid StmCmdLine object manages parsing of command line options and their arguments.

CmdLine.

Valid objects of type StmCmdLine can be achieved only as return values of stmCmdLineCreate(). Moreover, variables of type StmCmdLine may have the value NULL meaning invalid or undefined.

The basic command line parsing capabilities a valid StmCmdLine object offers are similar to those of the UNIX standard library function getopt.

A StmCmdLine object stores the command line to parse as an array of \0 terminated strings and the options to be recognized as an array of StmCmdOptSpec objects (see stmCmdLineCreate()).

Each option can have an arbitrary number of alias names (see StmCmdOptSpec). An option name consisting of one character is called short option and is recognized by a leading '-' in the command line. An option name consisting of more than one characters is called a long option and is recognized by a leading '--' in the command line. If a short option is used with a leading '--' it is regarded as long option. Option arguments of short options cannot be optional. Short options without arguments can be combined by concatenating their option characters preceded by a single '-'. The argument of a short option is separated from its option name by whitespace unless the deprecated StmCmdLineFlags flag StmCmdLineAllowDirectlyFollowingOptArgs is set allowing the option argument following the option name directly. The argument of a long option is separated by its option name by '=' without intervening whitespace. Option arguments or parts thereof containing whitespace have to be quoted by '"' characters.

The special option '--' in the command line means end of options and causes the parsing of options to be terminated. All remaining arguments count as non option arguments.

For at most one option specified in the StmCmdOptSpec array the StmCmdOptSpecFlags flag StmCmdOptSpecArgsEnvOption flag can be set. This flag marks its option as argument environment variable definition option. Its option argument shall be of the form <name>=<value> and defines the argument environment variable <name> with value <value>. This variable can be used in subsequent command line arguments with the construct '@{<name>}' which is replaced then by <value>. If for such a replacement an argument environment variable <name> is not found, next a shell environment variable <name> is searched. If also this variable does not exist, the construct is not replaced.

For at most one option specified in the StmCmdOptSpec array the StmCmdOptSpecFlags flag StmCmdOptSpecArgsFromOption flag can be set. This flag marks its option as argument substitution option. Its option argument shall designate a file containing valid command line options and command arguments with the extension that newline or '#' or ';' characters followed by arbitrary content up to the line end are regarded as white space. Especially this file may contain other argument substitution options, or argument environment variable definitions and usages.

A simple example for the parsing of a command line can be found in test/dsettst.c:

    /* Evaluate command line options. */
    int t, tests = 1, count = 1000;
    StmBool appendFlag = StmFalse;
    StmDword optId;
    StmCmdOptSpec optSpec [] =
    {
        {StmId (h), "h\0help\0", StmCmdOptSpecOnlyOption},
        {StmId (V), "V\0version\0", StmCmdOptSpecOnlyOption},
        {StmId (s), "s\0silent\0"},
        {StmId (a), "a\0append\0"},
        {StmId (o), "o\0output\0", StmCmdOptSpecRequiresArg},
        {StmId (c), "c\0count\0", StmCmdOptSpecRequiresArg},
        {StmId (t), "t\0tests\0", StmCmdOptSpecRequiresArg},
        {0, NULL}
    };
    StmCmdLine cmdLine = stmCmdLineCreate (argc, (const char **) argv, optSpec);
    const char *prog = stmCmdLineGetProg (cmdLine);
    const char *helpMode = NULL;
    StmBool printVersion = StmFalse;
    stmCmdLineSetErrfp (cmdLine, stderr);
    for (optId = stmCmdLineGetFirstOptionId (cmdLine);
         optId;
         optId = stmCmdLineGetNextOptionId (cmdLine))
    {
        if (optId == StmId (h))
        {
            helpMode = stmCmdLineGetCurrentOptionName (cmdLine);
            continue;
        }
        if (optId == StmId (V))
        {
            printVersion = StmTrue;
            continue;
        }
        if (optId == StmId (s))
        {
            silent = StmTrue;
            continue;
        }
        if (optId == StmId (a))
        {
            appendFlag = StmTrue;
            continue;
        }
        if (optId == StmId (o))
        {
            const char *optarg = stmCmdLineGetCurrentOptionArg (cmdLine);
            assert (optarg);
            if (! (os = fopen (optarg, appendFlag ? "a" : "w")))
            {
                fprintf (stderr,
                         "%s: option %s: cannot open output file %s\n",
                         prog,
                         stmCmdLineGetCurrentOptionName (cmdLine),
                         optarg);
                stmCmdLineSetError (cmdLine, StmCmdLineOptionArgError);
            }
            continue;
        }
        if (optId == StmId (c))
        {
            const char *optarg = stmCmdLineGetCurrentOptionArg (cmdLine);
            char *end;
            long ll;
            assert (optarg);
            ll = strtol (optarg, &end, 10);
            if (*end || ll < 1 || ll > INT_MAX)
            {
                fprintf (stderr,
                         "%s: option %s: illegal option argument: %s\n",
                         prog,
                         stmCmdLineGetCurrentOptionName (cmdLine),
                         optarg);
                stmCmdLineSetError (cmdLine, StmCmdLineOptionArgError);
            }
            count = (int) ll;
            continue;
        }
        if (optId == StmId (t))
        {
            const char *optarg = stmCmdLineGetCurrentOptionArg (cmdLine);
            char *end;
            long ll;
            assert (optarg);
            ll = strtol (optarg, &end, 10);
            if (*end || ll < 1 || ll > INT_MAX)
            {
                fprintf (stderr,
                         "%s: option %s: illegal option argument: %s\n",
                         prog,
                         stmCmdLineGetCurrentOptionName (cmdLine),
                         optarg);
                stmCmdLineSetError (cmdLine, StmCmdLineOptionArgError);
            }
            tests = (int) ll;
            continue;
        }
    }

An elaborated example including argument environment variable definition and argument substitution options shows the source code of the command ctupdate contained in the SysToMath package ClearToolSuite.


Files

file  StmCmdLineAdtDoc.h
 Documentation of the abstract structure data type type StmCmdLine.

Data Structures

struct  StmCmdOptSpec
 Type specifying a command line option. More...

StmCmdLine Method Functions

enum  StmCmdLineFlags { StmCmdLineAllowDirectlyFollowingOptArgs = 0x00000001 }
 Constants used to influence the operation of a StmCmdLine object. More...
enum  StmCmdLineErrors {
  StmCmdLineSystemError = -1,
  StmCmdLineOk = 0,
  StmCmdLineOptionError = 1,
  StmCmdLineOptionArgError = 2,
  StmCmdLineArgumentError = 3,
  StmCmdLineWrongUsage = 4
}
 Error values of StmCmdLine objects. More...
StmDword stmCmdLineGetFlags (StmCmdLine cmdLine)
 Get the operation flags of the StmCmdLine object cmdLine.
int stmCmdLineSetFlags (StmCmdLine cmdLine, StmDword flags)
 Set the operation flags of the StmCmdLine object cmdLine to flags.
int stmCmdLineGetError (StmCmdLine cmdLine)
 Get the error state of the StmCmdLine object cmdLine.
int stmCmdLineSetError (StmCmdLine cmdLine, int error)
 Set the error state of the StmCmdLine object cmdLine to error.
const char * stmCmdLineGetErrbuf (StmCmdLine cmdLine)
 Get the error message buffer of the StmCmdLine object cmdLine.
int stmCmdLinePrintfErrbuf (StmCmdLine cmdLine, const char *format,...)
 Print formatted to the error message buffer of the StmCmdLine object cmdLine.
FILE * stmCmdLineGetErrfp (StmCmdLine cmdLine)
 Get the error output stream of the StmCmdLine object cmdLine.
int stmCmdLineSetErrfp (StmCmdLine cmdLine, FILE *errfp)
 Set the error output stream of the StmCmdLine object cmdLine to errfp.
StmDword stmCmdLineGetFirstOptionId (StmCmdLine cmdLine)
 Get the ID of the first option of the StmCmdLine object cmdLine.
StmDword stmCmdLineGetCurrentOptionId (StmCmdLine cmdLine)
 Get the ID of the current option of the StmCmdLine object cmdLine.
StmDword stmCmdLineGetNextOptionId (StmCmdLine cmdLine)
 Get the ID of the next option of the StmCmdLine object cmdLine.
const char * stmCmdLineGetProg (StmCmdLine cmdLine)
 Get the program name of the StmCmdLine object cmdLine.
size_t stmCmdLineGetCurrentArgIndex (StmCmdLine cmdLine)
 Get the current argument index of the StmCmdLine object cmdLine.
size_t stmCmdLineGetCurrentOptionIndex (StmCmdLine cmdLine)
 Get the current option index of the StmCmdLine object cmdLine.
const char * stmCmdLineGetCurrentOptionName (StmCmdLine cmdLine)
 Get the current option name of the StmCmdLine object cmdLine.
const char * stmCmdLineGetCurrentOptionArg (StmCmdLine cmdLine)
 Get the argument of the current option of the StmCmdLine object cmdLine.
size_t stmCmdLineGetArgCount (StmCmdLine cmdLine)
 Get the argument count of the StmCmdLine object cmdLine.
const char * stmCmdLineGetArg (StmCmdLine cmdLine, size_t argIndex)
 Get the argument at index argIndex of the StmCmdLine object cmdLine.
#define stmCmdLineGetOpterr   stmCmdLineGetError
 Alternative name for stmCmdLineGetError().
#define stmCmdLineSetOpterr   stmCmdLineSetError
 Alternative name for stmCmdLineSetError().

StmCmdLine Representation

An object of abstract data type StmCmdLine is represented as a pointer to its implementation.

typedef struct StmCmdLineImpl_ StmCmdLineImpl_
 Type name of implementation structure.
typedef StmCmdLineImpl_StmCmdLine
 Pointer to implementation.
typedef const StmCmdLineImpl_ConstStmCmdLine
 Pointer to constant implementation.

StmCmdLine Creation and Destruction

StmCmdLine stmCmdLineCreate (int argc, const char **argv, const StmCmdOptSpec *optSpec)
 Creation of a new StmCmdLine object.
void stmCmdLineDestroy (StmCmdLine cmdLine)
 Destruction of the StmCmdLine object cmdLine.

Typedefs

typedef struct StmCmdOptSpec StmCmdOptSpec
 Type name for structure StmCmdOptSpec.

Enumerations

enum  StmCmdOptSpecFlags {
  StmCmdOptSpecHasArg = 0x00000001,
  StmCmdOptSpecRequiresArg = 0x00000003,
  StmCmdOptSpecArgsEnvOption = 0x00000004,
  StmCmdOptSpecArgsFromOption = 0x00000008,
  StmCmdOptSpecFirstOption = 0x00000010,
  StmCmdOptSpecLastOption = 0x00000020,
  StmCmdOptSpecOnlyOption = 0x00000030
}
 Constants used for the flags member of StmCmdOptSpec. More...


Define Documentation

#define stmCmdLineGetOpterr   stmCmdLineGetError

Alternative name for stmCmdLineGetError().

Deprecated:
Only for backward compatibility.

Definition at line 359 of file getopts.h.

#define stmCmdLineSetOpterr   stmCmdLineSetError

Alternative name for stmCmdLineSetError().

Deprecated:
Only for backward compatibility.

Definition at line 384 of file getopts.h.


Typedef Documentation

typedef struct StmCmdOptSpec StmCmdOptSpec

Type name for structure StmCmdOptSpec.

Definition at line 189 of file getopts.h.

typedef struct StmCmdLineImpl_ StmCmdLineImpl_

Type name of implementation structure.

Definition at line 60 of file StmCmdLineAdtDoc.h.

typedef StmCmdLineImpl_* StmCmdLine

Pointer to implementation.

Examples:
cuglify.c, and dsettst.c.

Definition at line 63 of file StmCmdLineAdtDoc.h.

typedef const StmCmdLineImpl_* ConstStmCmdLine

Pointer to constant implementation.

Definition at line 66 of file StmCmdLineAdtDoc.h.


Enumeration Type Documentation

enum StmCmdOptSpecFlags

Constants used for the flags member of StmCmdOptSpec.

They may be bitwise ored.

Enumerator:
StmCmdOptSpecHasArg  The option has an argument.

StmCmdOptSpecRequiresArg  The option requires an argument.

StmCmdOptSpecArgsEnvOption  The option is the argument environment variable definition option.

StmCmdOptSpecArgsFromOption  The option is the argument substitution option.

StmCmdOptSpecFirstOption  The option must be the first option.

StmCmdOptSpecLastOption  The option must be the last option.

StmCmdOptSpecOnlyOption  The option must be the only option.

Definition at line 167 of file getopts.h.

enum StmCmdLineFlags

Constants used to influence the operation of a StmCmdLine object.

They may be bitwise ored.

Enumerator:
StmCmdLineAllowDirectlyFollowingOptArgs  If this flag is set, the argument of a short option may follow directly without intervening whitespace, which by default is not allowed.

Definition at line 293 of file getopts.h.

enum StmCmdLineErrors

Error values of StmCmdLine objects.

An enumerator of this enumeration is held by a valid StmCmdLine object as its error state.

Enumerator:
StmCmdLineSystemError  System error.

StmCmdLineOk  No error.

StmCmdLineOptionError  Option error.

StmCmdLineOptionArgError  Option argument error.

StmCmdLineArgumentError  Argument error.

StmCmdLineWrongUsage  Wrong usage error.

Definition at line 343 of file getopts.h.


Function Documentation

StmCmdLine stmCmdLineCreate ( int  argc,
const char **  argv,
const StmCmdOptSpec optSpec 
)

Creation of a new StmCmdLine object.

Parameters:
[in] argc Number of command line arguments including options and option arguments. This is normally the argc argument of the main function.
[in] argv A pointer to the first element of a argc dimensional array of command line arguments optionally followed by an extra NULL element. This is normally the argv argument of the main function containing the program path as its first element.
[in] optSpec If not NULL, a pointer to the first element of an array of StmCmdOptSpec objects specifying all possible options and their semantics. This array must be ended by an empty StmOptSpec object characterized by an StmCmdOptSpec::id member of 0 and a NULL pointer as StmCmdOptSpec::name member.
Effects:
The function creates a stmCmdLine object representing the command line specified by its argc command line arguments argv. It sets the program name later retrievable with stmCmdLineGetProg() as the basename of the program path. Then, if optSpec is not NULL, the function prepares the stmCmdLine object to be ready to be parsed according to the command line options specified by optSpec. This parsing shall be done by using the StmCmdLine object created as argument.
Returns:
NULL on error. Then the variable errno contains the error's cause.

The StmCmdLine object created on success.

Note:
For C++ sources in order to supply argv from main it has to be const casted.
See also:
stmCmdLineDestroy(), stmCmdLineGetProg().
Examples:
cuglify.c, and dsettst.c.

Referenced by main().

void stmCmdLineDestroy ( StmCmdLine  cmdLine  ) 

Destruction of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object to be destroyed.
Effects:
The function destroys the StmCmdLine object cmdLine. It is no error to call the function for a StmCmdLine object with value NULL in which case the function does nothing.
See also:
stmCmdLineCreate().
Examples:
cuglify.c, and dsettst.c.

Referenced by main().

StmDword stmCmdLineGetFlags ( StmCmdLine  cmdLine  ) 

Get the operation flags of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
Returns:
0, if cmdLine is NULL. Then the variable errno is set to EINVAL.

The operation flags of the valid StmCmdLine object cmdLine.

See also:
stmCmdLineSetFlags(), StmCmdLineFlags.

int stmCmdLineSetFlags ( StmCmdLine  cmdLine,
StmDword  flags 
)

Set the operation flags of the StmCmdLine object cmdLine to flags.

Parameters:
[in] cmdLine The StmCmdLine object.
[in] flags The flags to be set.
Effects:
Sets the operation flags of cmdLine to flags.
Returns:
-1, if cmdLine is NULL. Then the variable errno is set to EINVAL.

0, if cmdLine is valid.

See also:
stmCmdLineGetFlags(), StmCmdLineFlags.

int stmCmdLineGetError ( StmCmdLine  cmdLine  ) 

Get the error state of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
Returns:
StmCmdLineSystemError, if cmdLine is NULL. Then the variable errno is set to EINVAL.

The error state of the valid StmCmdLine object cmdLine as one of the enumerators of the enumeration StmCmdLineErrors.

See also:
stmCmdLineSetError(), StmCmdLineErrors.
Examples:
cuglify.c, and dsettst.c.

Referenced by main().

int stmCmdLineSetError ( StmCmdLine  cmdLine,
int  error 
)

Set the error state of the StmCmdLine object cmdLine to error.

Parameters:
[in] cmdLine The StmCmdLine object.
[in] error The error state to be set.
Effects:
If error is an enumerator of the enumeration StmCmdLineErrorsSets, the function sets error state of cmdLine to error, else to StmCmdLineSystemError.
Returns:
StmCmdLineSystemError, if cmdLine is NULL, or if error no enumerator of the enumeration StmCmdLineErrors. Then the variable errno is set to EINVAL.

0, if cmdLine is valid and error is an enumerator of the enumeration StmCmdLineErrors.

See also:
stmCmdLineGetError(), StmCmdLineErrors.
Examples:
cuglify.c, and dsettst.c.

Referenced by main().

const char* stmCmdLineGetErrbuf ( StmCmdLine  cmdLine  ) 

Get the error message buffer of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
Returns:
NULL, if cmdLine is NULL. Then the variable errno is set to EINVAL.

The error message buffer of the valid StmCmdLine object cmdLine.

See also:
stmCmdLinePrintfErrbuf().

int stmCmdLinePrintfErrbuf ( StmCmdLine  cmdLine,
const char *  format,
  ... 
)

Print formatted to the error message buffer of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
[in] format Format string as in printf.
Effects:
The function formats its arguments according to format and the arguments following format as the standard function printf does and replaces the error message buffer with that formatted output.
Returns:
-1, if cmdLine is NULL or if the printing fails. Then the variable errno is set accordingly.

On success the character length of the error message buffer.

See also:
stmCmdLineGetErrbuf().

FILE* stmCmdLineGetErrfp ( StmCmdLine  cmdLine  ) 

Get the error output stream of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
Remarks:
If the error output stream is set, it defines the stream to which the error messages are printed. If this error output stream is NULL (the default), these error messages are only printed to the error message buffer.
Returns:
NULL, if cmdLine is NULL. Then the variable errno is set to EINVAL.

The error output stream of the valid StmCmdLine object cmdLine or NULL, if no error output stream is set.

See also:
stmCmdLineSetErrfp().

int stmCmdLineSetErrfp ( StmCmdLine  cmdLine,
FILE *  errfp 
)

Set the error output stream of the StmCmdLine object cmdLine to errfp.

Parameters:
[in] cmdLine The StmCmdLine object.
[in] errfp The error output stream to be set.
Effects:
The function sets the error output stream to errfp. If errfp is not NULL, it defines the stream to which the error messages are printed. If this error output stream is NULL (the default), these error messages are only printed to the error message buffer.
Returns:
-1, if cmdLine is NULL. Then the variable errno is set to EINVAL.

0, if cmdLine is valid.

See also:
stmCmdLineGetErrfp().
Examples:
cuglify.c, and dsettst.c.

Referenced by main().

StmDword stmCmdLineGetFirstOptionId ( StmCmdLine  cmdLine  ) 

Get the ID of the first option of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
Returns:
0, if cmdLine is NULL. Then the variable errno is set to EINVAL.

0, if cmdLine is valid and stmCmdLineGetError() would return a value unequal to StmCmdLineOk.

0, if cmdLine is valid and stmCmdLineGetError() would return StmCmdLineOk, but cmdLine represents no option.

The StmCmdOptSpec::id member of the first option represented by the valid StmCmdLine object cmdLine.

See also:
stmCmdLineGetCurrentOptionId(), stmCmdLineGetNextOptionId, stmCmdLineGetError().
Examples:
cuglify.c, and dsettst.c.

Referenced by main().

StmDword stmCmdLineGetCurrentOptionId ( StmCmdLine  cmdLine  ) 

Get the ID of the current option of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
Returns:
0, if cmdLine is NULL. Then the variable errno is set to EINVAL.

The same StmCmdOptSpec::id member the most recently called function. stmCmdLineGetFirstOptionId() or stmCmdLineGetNextOptionId returned.

See also:
stmCmdLineGetFirstOptionId(), stmCmdLineGetNextOptionId.

StmDword stmCmdLineGetNextOptionId ( StmCmdLine  cmdLine  ) 

Get the ID of the next option of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
Returns:
0, if cmdLine is NULL. Then the variable errno is set to EINVAL.

0, if cmdLine is valid and stmCmdLineGetError() would return a value unequal to StmCmdLineOk.

0, if cmdLine is valid and stmCmdLineGetError() would return StmCmdLineOk, but cmdLine represents no next option.

The StmCmdOptSpec::id member of the next option represented by the valid StmCmdLine object cmdLine.

See also:
stmCmdLineGetFirstOptionId(), stmCmdLineGetCurrentOptionId, stmCmdLineGetError().
Examples:
cuglify.c, and dsettst.c.

Referenced by main().

const char* stmCmdLineGetProg ( StmCmdLine  cmdLine  ) 

Get the program name of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
Returns:
NULL, if cmdLine is NULL. Then the variable errno is set to EINVAL.

The base name of the program path represented by the valid StmCmdLine object cmdLine.

See also:
stmCmdLineCreate().
Examples:
cuglify.c, and dsettst.c.

Referenced by main().

size_t stmCmdLineGetCurrentArgIndex ( StmCmdLine  cmdLine  ) 

Get the current argument index of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
Returns:
0, if cmdLine is NULL. Then the variable errno is set to EINVAL.

The index in the argument array of the valid StmCmdLine object cmdLine designating the currently handled argument.

See also:
stmCmdLineGetCurrentOptionIndex().
Examples:
cuglify.c, and dsettst.c.

Referenced by main().

size_t stmCmdLineGetCurrentOptionIndex ( StmCmdLine  cmdLine  ) 

Get the current option index of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
Returns:
0, if cmdLine is NULL. Then the variable errno is set to EINVAL.

The index in the argument array of the valid StmCmdLine object cmdLine designating the currently handled option.

See also:
stmCmdLineGetCurrentOptionName(), stmCmdLineGetCurrentOptionArg().

const char* stmCmdLineGetCurrentOptionName ( StmCmdLine  cmdLine  ) 

Get the current option name of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
Returns:
NULL, if cmdLine is NULL. Then the variable errno is set to EINVAL.

The name of the option currently handled by the valid StmCmdLine object cmdLine. This name includes the leading '-' or '--'.

See also:
stmCmdLineGetCurrentOptionIndex(), stmCmdLineGetCurrentOptionArg().
Examples:
dsettst.c.

const char* stmCmdLineGetCurrentOptionArg ( StmCmdLine  cmdLine  ) 

Get the argument of the current option of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
Returns:
NULL, if cmdLine is NULL. Then the variable errno is set to EINVAL.

NULL, if the option currently handled by the valid StmCmdLine object cmdLine has no argument.

Else the quote removed and argument variable expanded argument of the option currently handled by the valid StmCmdLine object cmdLine.

See also:
stmCmdLineGetCurrentOptionIndex(), stmCmdLineGetCurrentOptionName().
Examples:
cuglify.c, and dsettst.c.

Referenced by main().

size_t stmCmdLineGetArgCount ( StmCmdLine  cmdLine  ) 

Get the argument count of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
Returns:
0, if cmdLine is NULL. Then the variable errno is set to EINVAL.

The number of elements of the argument array of the valid StmCmdLine object cmdLine.

See also:
stmCmdLineGetArg().
Examples:
cuglify.c, and dsettst.c.

Referenced by main().

const char* stmCmdLineGetArg ( StmCmdLine  cmdLine,
size_t  argIndex 
)

Get the argument at index argIndex of the StmCmdLine object cmdLine.

Parameters:
[in] cmdLine The StmCmdLine object.
[in] argIndex The argument index.
Returns:
NULL, if cmdLine is NULL. Then the variable errno is set to EINVAL.

NULL, if the argument at index argIndex of the argument array of the valid StmCmdLine object cmdLine does not exist.

Else the quote removed and argument variable expanded argument at index argIndex of the argument array of the valid StmCmdLine object cmdLine.

See also:
stmCmdLineGetArgCount().
Examples:
cuglify.c, and dsettst.c.

Referenced by main().


© Copyright Tom Michaelis 2002-2007

Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).