LCOV - code coverage report
Current view: top level - src - mkernel-opt.h (source / functions) Hit Total Coverage
Test: mkernel.info Lines: 3 3 100.0 %
Date: 2024-07-31 19:18:37 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*   -*- buffer-read-only: t -*- vi: set ro:
       2             :  *
       3             :  *  DO NOT EDIT THIS FILE   (mkernel-opt.h)
       4             :  *
       5             :  *  It has been AutoGen-ed
       6             :  *  From the definitions    mkernel-opt.def
       7             :  *  and the template file   options
       8             :  *
       9             :  * Generated from AutoOpts 42:1:17 templates.
      10             :  *
      11             :  *  AutoOpts is a copyrighted work.  This header file is not encumbered
      12             :  *  by AutoOpts licensing, but is provided under the licensing terms chosen
      13             :  *  by the mkernel author or copyright holder.  AutoOpts is
      14             :  *  licensed under the terms of the LGPL.  The redistributable library
      15             :  *  (``libopts'') is licensed under the terms of either the LGPL or, at the
      16             :  *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
      17             :  *  for details.
      18             :  *
      19             :  * The mkernel program is copyrighted and licensed
      20             :  * under the following terms:
      21             :  *
      22             :  *  Copyright (C) 2017 Francois Cerbelle, all rights reserved.
      23             :  *  This is free software. It is licensed for use, modification and
      24             :  *  redistribution under the terms of the GNU Lesser General Public License,
      25             :  *  version 3 or later <http://gnu.org/licenses/lgpl.html>
      26             :  *
      27             :  *  mkernel is free software: you can redistribute it and/or modify it
      28             :  *  under the terms of the GNU Lesser General Public License as published
      29             :  *  by the Free Software Foundation, either version 3 of the License, or
      30             :  *  (at your option) any later version.
      31             :  *
      32             :  *  mkernel is distributed in the hope that it will be useful, but
      33             :  *  WITHOUT ANY WARRANTY; without even the implied warranty of
      34             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      35             :  *  See the GNU Lesser General Public License for more details.
      36             :  *
      37             :  *  You should have received a copy of the GNU Lesser General Public License
      38             :  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.";
      39             :  */
      40             : /**
      41             :  *  This file contains the programmatic interface to the Automated
      42             :  *  Options generated for the mkernel program.
      43             :  *  These macros are documented in the AutoGen info file in the
      44             :  *  "AutoOpts" chapter.  Please refer to that doc for usage help.
      45             :  */
      46             : #ifndef AUTOOPTS_MKERNEL_OPT_H_GUARD
      47             : #define AUTOOPTS_MKERNEL_OPT_H_GUARD 1
      48             : #include "config.h"
      49             : #include <autoopts/options.h>
      50             : #include <stdarg.h>
      51             : #include <stdnoreturn.h>
      52             : 
      53             : /**
      54             :  *  Ensure that the library used for compiling this generated header is at
      55             :  *  least as new as the version current when the header template was released
      56             :  *  (not counting patch version increments).  Also ensure that the oldest
      57             :  *  tolerable version is at least as old as what was current when the header
      58             :  *  template was released.
      59             :  */
      60             : #define AO_TEMPLATE_VERSION 172033
      61             : #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
      62             :  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
      63             : # error option template version mismatches autoopts/options.h header
      64             :   Choke Me.
      65             : #endif
      66             : 
      67             : #if GCC_VERSION > 40400
      68             : #define NOT_REACHED __builtin_unreachable();
      69             : #else
      70             : #define NOT_REACHED
      71             : #endif
      72             : 
      73             : /**
      74             :  *  Enumeration of each option type for mkernel
      75             :  */
      76             : typedef enum {
      77             :     INDEX_OPT_MODULE_PATH  =  0,
      78             :     INDEX_OPT_VERSION      =  1,
      79             :     INDEX_OPT_HELP         =  2,
      80             :     INDEX_OPT_MORE_HELP    =  3,
      81             :     INDEX_OPT_SAVE_OPTS    =  4,
      82             :     INDEX_OPT_LOAD_OPTS    =  5
      83             : } teOptIndex;
      84             : /** count of all options for mkernel */
      85             : #define OPTION_CT    6
      86             : /** mkernel version */
      87             : #define MKERNEL_VERSION       "0.0.2"
      88             : /** Full mkernel version text */
      89             : #define MKERNEL_FULL_VERSION  "mkernel 0.0.2"
      90             : 
      91             : /**
      92             :  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
      93             :  *  option name (as in the teOptIndex enumeration above).
      94             :  *  e.g. HAVE_OPT(MODULE_PATH)
      95             :  */
      96             : #define         DESC(n) (mkernelOptions.pOptDesc[INDEX_OPT_## n])
      97             : /** 'true' if an option has been specified in any way */
      98             : #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
      99             : /** The string argument to an option. The argument type must be \"string\". */
     100             : #define      OPT_ARG(n) (DESC(n).optArg.argString)
     101             : /** Mask the option state revealing how an option was specified.
     102             :  *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
     103             :  * \a OPTST_DEFINED, \a OPTST_RESET or zero.
     104             :  */
     105             : #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
     106             : /** Count of option's occurrances *on the command line*. */
     107             : #define    COUNT_OPT(n) (DESC(n).optOccCt)
     108             : /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
     109             : #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
     110             : /** 'true' if \a HAVE_OPT would yield 'false'. */
     111             : #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
     112             : /** 'true' if OPTST_DISABLED bit not set. */
     113             : #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
     114             : /** number of stacked option arguments.
     115             :  *  Valid only for stacked option arguments. */
     116             : #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
     117             : /** stacked argument vector.
     118             :  *  Valid only for stacked option arguments. */
     119             : #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
     120             : /** Reset an option. */
     121             : #define    CLEAR_OPT(n) STMTS( \
     122             :                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
     123             :                 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
     124             :                     DESC(n).fOptState |= OPTST_DISABLED; \
     125             :                 DESC(n).optCookie = NULL )
     126             : /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
     127             : /**
     128             :  *  Enumeration of mkernel exit codes
     129             :  */
     130             : typedef enum {
     131             :     MKERNEL_EXIT_SUCCESS         = 0,
     132             :     MKERNEL_EXIT_FAILURE         = 1,
     133             :     MKERNEL_EXIT_USAGE_ERROR     = 64,
     134             :     MKERNEL_EXIT_NO_CONFIG_INPUT = 66,
     135             :     MKERNEL_EXIT_LIBOPTS_FAILURE = 70
     136             : }   mkernel_exit_code_t;
     137             : /**
     138             :  *  Interface defines for specific options.
     139             :  * @{
     140             :  */
     141             : #define VALUE_OPT_MODULE_PATH    'M'
     142             : /** option flag (value) for help-value option */
     143             : #define VALUE_OPT_HELP          'h'
     144             : /** option flag (value) for more-help-value option */
     145             : #define VALUE_OPT_MORE_HELP     'H'
     146             : /** option flag (value) for version-value option */
     147             : #define VALUE_OPT_VERSION       'v'
     148             : /** option flag (value) for save-opts-value option */
     149             : #define VALUE_OPT_SAVE_OPTS     '>'
     150             : /** option flag (value) for load-opts-value option */
     151             : #define VALUE_OPT_LOAD_OPTS     '<'
     152             : #define SET_OPT_SAVE_OPTS(a)   STMTS( \
     153             :         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
     154             :         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
     155             :         DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
     156             : /*
     157             :  *  Interface defines not associated with particular options
     158             :  */
     159             : #define ERRSKIP_OPTERR  STMTS(mkernelOptions.fOptSet &= ~OPTPROC_ERRSTOP)
     160             : #define ERRSTOP_OPTERR  STMTS(mkernelOptions.fOptSet |= OPTPROC_ERRSTOP)
     161             : #define RESTART_OPT(n)  STMTS( \
     162             :                 mkernelOptions.curOptIdx = (n); \
     163             :                 mkernelOptions.pzCurOpt  = NULL )
     164             : #define START_OPT       RESTART_OPT(1)
     165             : #define USAGE(c)        (*mkernelOptions.pUsageProc)(&mkernelOptions, c)
     166             : 
     167             : #ifdef  __cplusplus
     168             : extern "C" {
     169             : #endif
     170             : 
     171             : 
     172             : /* * * * * *
     173             :  *
     174             :  *  Declare the mkernel option descriptor.
     175             :  */
     176             : extern tOptions mkernelOptions;
     177             : 
     178             : #if defined(ENABLE_NLS)
     179             : # ifndef _
     180             : #   include <stdio.h>
     181             : #   ifndef HAVE_GETTEXT
     182             :       extern char * gettext(char const *);
     183             : #   else
     184             : #     include <libintl.h>
     185             : #   endif
     186             : 
     187             : # ifndef ATTRIBUTE_FORMAT_ARG
     188             : #   define ATTRIBUTE_FORMAT_ARG(_a)
     189             : # endif
     190             : 
     191             : static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
     192        2023 : static inline char* aoGetsText(char const* pz) {
     193        2023 :     if (pz == NULL) return NULL;
     194        2023 :     return (char*)gettext(pz);
     195             : }
     196             : #   define _(s)  aoGetsText(s)
     197             : # endif /* _() */
     198             : 
     199             : # define OPT_NO_XLAT_CFG_NAMES  STMTS(mkernelOptions.fOptSet |= \
     200             :                                     OPTPROC_NXLAT_OPT_CFG;)
     201             : # define OPT_NO_XLAT_OPT_NAMES  STMTS(mkernelOptions.fOptSet |= \
     202             :                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
     203             : 
     204             : # define OPT_XLAT_CFG_NAMES     STMTS(mkernelOptions.fOptSet &= \
     205             :                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
     206             : # define OPT_XLAT_OPT_NAMES     STMTS(mkernelOptions.fOptSet &= \
     207             :                                   ~OPTPROC_NXLAT_OPT;)
     208             : 
     209             : #else   /* ENABLE_NLS */
     210             : # define OPT_NO_XLAT_CFG_NAMES
     211             : # define OPT_NO_XLAT_OPT_NAMES
     212             : 
     213             : # define OPT_XLAT_CFG_NAMES
     214             : # define OPT_XLAT_OPT_NAMES
     215             : 
     216             : # ifndef _
     217             : #   define _(_s)  _s
     218             : # endif
     219             : #endif  /* ENABLE_NLS */
     220             : 
     221             : 
     222             : #ifdef  __cplusplus
     223             : }
     224             : #endif
     225             : #endif /* AUTOOPTS_MKERNEL_OPT_H_GUARD */
     226             : 
     227             : /* mkernel-opt.h ends here */

Generated by: LCOV version 1.16