[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.4.1 Data for Option Processing

This section describes the data that may be accessed from within the option processing callback routines. The following fields may be used in the following ways and may be used for read only. The first set is addressed from the tOptDesc* pointer:

These may be used by option procedures to determine which option they are working on (in case they handle several options).

These may be used by option procedures to determine which option was used to set the current option. This may be different from the above if the options are members of an equivalence class.

If AutoOpts is processing command line arguments, then this value will contain the current occurrence count. During the option preset phase (reading rc/ini files and examining environment variables), the value is zero.

The field may be tested for the following bit values (prefix each name with OPTST_, e.g. OPTST_INIT):

Initial compiled value. As a bit test, it will always yield FALSE.

The option was set via the SET_OPT() macro.

The option was set via an RC/INI file, or a call to the optionLoadLine() routine.

The option was set via a command line option.

This is a mask of flags that show the set state, one of the above four values.

This bit is set when the option was selected by an equivalenced option.

This bit is set if the option is to be disabled. (Meaning it was a long option prefixed by the disablement prefix, or the option has not been specified yet and initializes as disabled.)

As an example of how this might be used, in AutoGen I want to allow template writers to specify that the template output can be left in a writable or read-only state. To support this, there is a Guile function named set-writable (see section 3.4.32 `set-writable' - Make the output file be writable). Also, I provide for command options --writable and --not-writable. I give precedence to command line and RC file options, thus:

switch (STATE_OPT( WRITABLE )) {
    fprintf( stderr, zOverrideWarn, pCurTemplate->pzFileName,
             pCurMacro->lineNo );

    if (gh_boolean_p( set ) && (set == SCM_BOOL_F))

Pointer to the latest argument string. BEWARE If the argument type is numeric or an enumeration, then this will be the argument value and not a pointer to a string.

The following two fields are addressed from the tOptions* pointer:

Points to a NUL-terminated string containing the current program name, as retrieved from the argument vector.

Points to a NUL-terminated string containing the full path of the current program, as retrieved from the argument vector. (If available on your system.)

Note these fields get filled in during the first call to optionProcess(). All other fields are private, for the exclusive use of AutoOpts code and is subject to change.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Bruce Korb on February 17, 2003 using texi2html

Viewable With Any Browser   AutoGen Home