[= AutoGen Template -*- Mode: C -*-

#  List the output suffixes that are to be generated.
#  Header must come first.  An env variable is set that
#  is used in processing the C file.
#
#  $Id: libhead.tpl,v 2.1 1999/07/07 19:42:32 bkorb Exp $

h
=]
[=

_SETENV HDRNAME _outfile =][=


# "The #define name we use to self-exclude the header" =][=

_SETENV DEFNAME prog_name _get _outfile
    "#2$echo '%s_%s'|tr -- '-./[a-z]' '___[A-Z]'" _printf _shell=][=

# "Let the real output begin..."
#
=]/*
[=_eval "# *  " _DNE=]
 */
/*
 *  This file contains the programmatic interface to the
 *  Automated Options generated for the [=prog_name=] library.
 *  This header is for use *only* in compiling that library..
 *  These macros are documented in the AutoGen info file
 *  in the "Autoopts" chapter.  Please refer to that doc
 *  for usage help.
 */

#ifndef [=_eval DEFNAME _env=]
#define [=_eval DEFNAME _env=]
[=
_IF copyright _exist=]
/*
 * [=_eval prog_name _get _cap copyright _get owner _get
       "#3$%s copyright %s %s" _printf=][=

  _IF copyright_note _exist=]
 *
[=copyright_note=][=

  _ELIF copyright_gpl _exist=]
 *
[=_eval prog_name _get _cap "# * " _gpl=][=

  _ELIF copyright_lgpl _exist=]
 *
[=_eval prog_name _get _cap owner _get "# * " _lgpl=][=
  _ENDIF "copyright notes" =]
 */[=
_ENDIF "copyright exists" =]
#include <options.h>

/*
 *  Enumeration of each library option:
 */
typedef enum {[=
_FOR flag=][=
  _IF documentation _exist ! =]
        INDEX_[=prefix _up #_ +=]OPT_[=name _up #%-16s _printf
               =] =[=_EVAL _index #%3d _printf=],[=
  _ENDIF =][=
/FLAG=]
        [=prog_name _up=]_LIBRARY_OPT_CT
} te[=prefix _cap=]OptIndex;

#define     [=prefix _up #_ +=]DESC(n)     ([=opts_ptr=][INDEX_[=
                 prefix _up #_ +=]OPT_ ## n])
#define     HAVE_[=prefix _up #_ +=]OPT(n) (! UNUSED_OPT(&[=prefix _up #_ +
                 =]DESC(n)))[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]
#define      [=prefix _up #_ +=]OPT_ARG(n) ([=prefix _up #_ +
                 =]DESC(n).pzLastArg)[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]
#define    STATE_[=prefix _up #_ +=]OPT(n) ([=prefix _up #_ +
                 =]DESC(n).fOptState & OPTST_SET_MASK)[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]
#define    COUNT_[=prefix _up #_ +=]OPT(n) ([=prefix _up #_ +
                 =]DESC(n).optOccCt)[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]
#define    ISSEL_[=prefix _up #_ +=]OPT(n) (SELECTED_OPT(&[=prefix _up #_ +
                 =]DESC(n)))[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]
#define ISUNUSED_[=prefix _up #_ +=]OPT(n) (UNUSED_OPT(& [=prefix _up #_ +
                 =]DESC(n)))[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]
#define  ENABLED_[=prefix _up #_ +=]OPT(n) (! DISABLED_OPT(& [=prefix _up #_ +
                 =]DESC(n)))[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]
#define  STACKCT_[=prefix _up #_ +=]OPT(n) (((tArgList*)([=prefix _up #_ +
                         =]DESC(n).optCookie))->useCt)[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]
#define STACKLST_[=prefix _up #_ +=]OPT(n) (((tArgList*)([=prefix _up #_ +
                         =]DESC(n).optCookie))->apzArgs)[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]
#define    CLEAR_[=prefix _up #_ +=]OPT(n) STMTS( \
                [=prefix _up #_ +=]DESC(n).fOptState &= OPTST_PERSISTENT;   \
                if ( ([=prefix _up #_ +
                    =]DESC(n).fOptState & OPTST_INITENABLED) == 0) \
                    [=prefix _up #_ +=]DESC(n).fOptState |= OPTST_DISABLED; \
                [=prefix _up #_ +=]DESC(n).optCookie = (void*)NULL )[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]

/*
 *  Interface defines for specific options.
 */[=

_FOR flag =][=
 _IF documentation _exist =][=
   _IF call_proc _exist flag_code _exist | =][=
     _IF setable _exist ! =][=
        _ERROR name _get
           "ERROR:  the doc option %s has a handler proc, but is not setable"
           _printf =][=
     _ENDIF =][=

   _ELSE =][=
     _IF setable _exist =][=
        _ERROR name _get
           "ERROR:  the doc option %s has no handler proc, but is setable"
           _printf =][=
     _ENDIF =][=

   _ENDIF "callout procedure exists" =][=

 _ELSE "not a documentation option" =][=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]
#define VALUE_[=prefix _up #_ +=]OPT_[=name _up "#%-14s" _printf=] [=

        _IF   value _len 1 = =]'[=value=]'[=
        _ELIF value _get _up NUMBER = =]NUMBER_OPTION[=
              _SETENV NUMBER_OPTION _index =][=
        _ELIF value _exist =][=
              _ERROR name _get
                     "Error:  value for opt %s must be single char or 'NUMBER'"
                     _printf =][=
        _ELIF _index 0x20 <= =][=_eval _index=][=
        _ELSE                =][=_eval _index 96 +=][=
        _ENDIF=][=#


* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=][=
  _IF flag_arg _get #=.* ~
=]
#define [=prefix _up #_ +=]OPT_VALUE_[=name _up "#%-14s" _printf
                =] ((t_word)([=prefix _up #_ +=]OPT_ARG([=name _up=])))[=
  _ENDIF=][=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=][=
  _IF equivalence _get _UP name _get _UP = =]
#define WHICH_[=prefix _up #_ +=]OPT_[=name _up "#%-14s" _printf
                =] ([=prefix _up #_ +=]DESC([=name _up=]).optActualValue)[=
  _ENDIF=][=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=][=
  _IF setable _exist =][=
    _IF  equivalence _exist !
         equivalence _get _UP name _get _UP == |


 =]
#define SET_[=prefix _up #_ +=]OPT_[=name _up=][=
      _IF flag_arg _exist=](a)[=_ENDIF=]   STMTS( \
        [=prefix _up #_ +=]DESC([=name _up
                       =]).optActualIndex = [=_eval _index=]; \
        [=prefix _up #_ +=]DESC([=name _up
                       =]).optActualValue = VALUE_[=prefix _up #_ +
                       =]OPT_[=name _up=]; \
        [=prefix _up #_ +=]DESC([=name _up=]).fOptState &= OPTST_PERSISTENT; \
        [=prefix _up #_ +=]DESC([=name _up=]).fOptState |= OPTST_SET[=
      _IF flag_arg _exist=]; \
        [=prefix _up #_ +=]DESC([=name _up=]).pzLastArg  = [=
        _IF flag_arg _get #=.* ~=](char*)atoi[=_ENDIF=](a)[=
      _ENDIF flag_arg-exists =][=
      _IF call_proc _exist
          flag_code _exist |
          flag_proc _exist |
          stack_arg _exist |=]; \
        (*([=prefix _up #_ +=]DESC([=name _up=]).pOptProc))( [=
                  prog_desc=], [=opts_ptr=] + [=_eval _index=] )[=
      _ENDIF "callout procedure exists" =] )[=


    _ELSE "not equivalenced"
=]
#define SET_[=prefix _up #_ +=]OPT_[=name _up=][=
      _IF flag_arg _exist=](a)[=_ENDIF=]   STMTS( \
        [=prefix _up #_ +=]DESC([=equivalence _up
                       =]).optActualIndex = [=_eval _index=]; \
        [=prefix _up #_ +=]DESC([=equivalence _up
                       =]).optActualValue = VALUE_[=prefix _up #_ +
                       =]OPT_[=name _up=]; \
        [=prefix _up #_ +=]DESC([=equivalence _up
                       =]).fOptState &= OPTST_PERSISTENT; \
        [=prefix _up #_ +=]DESC([=equivalence _up
                       =]).fOptState |= OPTST_SET | OPTST_EQUIVALENCE[=
      _IF flag_arg _exist=]; \
        [=prefix _up #_ +=]DESC([=equivalence _up=]).pzLastArg  = [=
        _IF flag_arg _get #=.* ~=](char*)atoi[=_ENDIF=](a)[=
      _ENDIF flag_arg-exists =][=
      _IF call_proc _exist
          flag_code _exist |
          flag_proc _exist |
          stack_arg _exist |=]; \
        (*([=prefix _up #_ +=]DESC([=name _up=]).pOptProc))( [=
                           prog_desc=], \
                [=opts_ptr=] + INDEX_[=
                         prefix _up #_ +=]OPT_[=equivalence _up=] )[=
      _ENDIF "callout procedure exists" =] )[=

    _ENDIF is/not equivalenced =][=

  _ENDIF setable =][=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=][=
  _IF setable _exist disable _exist & =]
#define DISABLE_[=prefix _up #_ +=]OPT_[=name _up=]   STMTS( \
        [=prefix _up #_ +=]DESC([=name _up=]).fOptState &= OPTST_PERSISTENT; \
        [=prefix _up #_ +=]DESC([=name _up
            =]).fOptState |= OPTST_SET | OPTST_DISABLED; \
        [=prefix _up #_ +=]DESC([=name _up=]).pzLastArg  = (char*)NULL[=
    _IF call_proc _exist
        flag_code _exist |
        flag_proc _exist |
        stack_arg _exist |=]; \
        (*([=prefix _up #_ +=]DESC([=name _up=]).pOptProc))( &[=
                  prog_desc=], [=opts_ptr=] + [=_eval _index=] )[=
     _ENDIF "callout procedure exists" =] )[=

  _ENDIF setable/disableable-exists =][=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

End of option-specific defines

 =][=

 _ENDIF documentation =][=
/flag=][=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]

#define  ERRSKIP_[=prefix _up #_ +=]OPTERR STMTS( [=prog_desc
                         =]->fOptSet &= ~OPTPROC_ERRSTOP )[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]
#define  ERRSTOP_[=prefix _up #_ +=]OPTERR STMTS( [=prog_desc
                         =]->fOptSet |= OPTPROC_ERRSTOP )[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]
#define  RESTART_[=prefix _up #_ +=]OPT(n) STMTS( \
                [=prog_desc=]->curOptIdx = (n); \
                [=prog_desc=]->pzCurOpt  = (char*)NULL )[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *

=]
#define     [=prefix _up #_ +=]USAGE(c)    (*[=prog_desc
                         =]->pUsageProc)( [=prog_desc=], c )[=#

* * * * * * * * * * * * * * * * * * * * * * * * * * * *
=]

#endif /* [=_eval DEFNAME _env=] */
