[ < ] [ > ]   [ << ] [ 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:

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

`optActualIndex'
`optActualValue'
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.

`optOccCt'
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.

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

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

`SET'
The option was set via the SET_OPT() macro.

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

`DEFINED'
The option was set via a command line option.

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

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

`DISABLED'
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.33 `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 )) {
case OPTST_DEFINED:
case OPTST_PRESET:
    fprintf( stderr, zOverrideWarn, pCurTemplate->pzFileName,
             pCurMacro->lineNo );
    break;

default:
    if (gh_boolean_p( set ) && (set == SCM_BOOL_F))
        CLEAR_OPT( WRITABLE );
    else
        SET_OPT_WRITABLE;
}

`pzLastArg'
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:

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

`pzProgPath'
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 June 4, 2003 using texi2html

Viewable With Any Browser   AutoGen Home