genshell.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /* -*- buffer-read-only: t -*- vi: set ro:
  2. *
  3. * DO NOT EDIT THIS FILE (genshell.h)
  4. *
  5. * It has been AutoGen-ed
  6. * From the definitions genshell.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 genshellopt 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 genshellopt program is copyrighted and licensed
  20. * under the following terms:
  21. *
  22. * Copyright (C) 1999-2018 Bruce Korb, 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 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>
  26. *
  27. * The genshellopt library is free software; you can redistribute it and/or
  28. * modify it under the terms of the GNU Library General Public License as
  29. * published by the Free Software Foundation; either version 2 of the
  30. * License, or (at your option) any later version.
  31. *
  32. * This library 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. See the GNU
  35. * Library General Public License for more details.
  36. *
  37. * You should have received a copy of the GNU Library General Public
  38. * License along with this library; if not, see
  39. * <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>
  40. */
  41. /**
  42. * This file contains the programmatic interface to the Automated
  43. * Options generated for the genshellopt program.
  44. * These macros are documented in the AutoGen info file in the
  45. * "AutoOpts" chapter. Please refer to that doc for usage help.
  46. */
  47. #ifndef AUTOOPTS_GENSHELL_H_GUARD
  48. #define AUTOOPTS_GENSHELL_H_GUARD 1
  49. #include <autoopts/options.h>
  50. #include <stdarg.h>
  51. #include <stdnoreturn.h>
  52. /**
  53. * Ensure that the library used for compiling this generated header is at
  54. * least as new as the version current when the header template was released
  55. * (not counting patch version increments). Also ensure that the oldest
  56. * tolerable version is at least as old as what was current when the header
  57. * template was released.
  58. */
  59. #define AO_TEMPLATE_VERSION 172033
  60. #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
  61. || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
  62. # error option template version mismatches autoopts/options.h header
  63. Choke Me.
  64. #endif
  65. #if GCC_VERSION > 40400
  66. #define NOT_REACHED __builtin_unreachable();
  67. #else
  68. #define NOT_REACHED
  69. #endif
  70. /**
  71. * Enumeration of each option type for genshellopt
  72. */
  73. typedef enum {
  74. INDEX_GENSHELL_OPT_SCRIPT = 0,
  75. INDEX_GENSHELL_OPT_SHELL = 1,
  76. INDEX_GENSHELL_OPT_VERSION = 2,
  77. INDEX_GENSHELL_OPT_HELP = 3,
  78. INDEX_GENSHELL_OPT_MORE_HELP = 4
  79. } teGenshell_OptIndex;
  80. /** count of all options for genshellopt */
  81. #define GENSHELL_OPTION_CT 5
  82. /** genshellopt version */
  83. #define GENSHELLOPT_VERSION "1"
  84. /** Full genshellopt version text */
  85. #define GENSHELLOPT_FULL_VERSION "genshellopt 1"
  86. /**
  87. * Interface defines for all options. Replace "n" with the UPPER_CASED
  88. * option name (as in the teGenshell_OptIndex enumeration above).
  89. * e.g. HAVE_GENSHELL_OPT(SCRIPT)
  90. */
  91. #define GENSHELL_DESC(n) (genshelloptOptions.pOptDesc[INDEX_GENSHELL_OPT_## n])
  92. /** 'true' if an option has been specified in any way */
  93. #define HAVE_GENSHELL_OPT(n) (! UNUSED_OPT(& GENSHELL_DESC(n)))
  94. /** The string argument to an option. The argument type must be \"string\". */
  95. #define GENSHELL_OPT_ARG(n) (GENSHELL_DESC(n).optArg.argString)
  96. /** Mask the option state revealing how an option was specified.
  97. * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
  98. * \a OPTST_DEFINED, \a OPTST_RESET or zero.
  99. */
  100. #define STATE_GENSHELL_OPT(n) (GENSHELL_DESC(n).fOptState & OPTST_SET_MASK)
  101. /** Count of option's occurrances *on the command line*. */
  102. #define COUNT_GENSHELL_OPT(n) (GENSHELL_DESC(n).optOccCt)
  103. /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
  104. #define ISSEL_GENSHELL_OPT(n) (SELECTED_OPT(&GENSHELL_DESC(n)))
  105. /** 'true' if \a HAVE_OPT would yield 'false'. */
  106. #define ISUNUSED_GENSHELL_OPT(n) (UNUSED_OPT(& GENSHELL_DESC(n)))
  107. /** 'true' if OPTST_DISABLED bit not set. */
  108. #define ENABLED_GENSHELL_OPT(n) (! DISABLED_OPT(& GENSHELL_DESC(n)))
  109. /** number of stacked option arguments.
  110. * Valid only for stacked option arguments. */
  111. #define STACKCT_GENSHELL_OPT(n) (((tArgList*)(GENSHELL_DESC(n).optCookie))->useCt)
  112. /** stacked argument vector.
  113. * Valid only for stacked option arguments. */
  114. #define STACKLST_GENSHELL_OPT(n) (((tArgList*)(GENSHELL_DESC(n).optCookie))->apzArgs)
  115. /** Reset an option. */
  116. #define CLEAR_GENSHELL_OPT(n) STMTS( \
  117. GENSHELL_DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \
  118. if ((GENSHELL_DESC(n).fOptState & OPTST_INITENABLED) == 0) \
  119. GENSHELL_DESC(n).fOptState |= OPTST_DISABLED; \
  120. GENSHELL_DESC(n).optCookie = NULL )
  121. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  122. /**
  123. * Enumeration of genshellopt exit codes
  124. */
  125. typedef enum {
  126. GENSHELLOPT_EXIT_SUCCESS = 0,
  127. GENSHELLOPT_EXIT_FAILURE = 1,
  128. GENSHELLOPT_EXIT_USAGE_ERROR = 64,
  129. GENSHELLOPT_EXIT_LIBOPTS_FAILURE = 70
  130. } genshellopt_exit_code_t;
  131. /**
  132. * Interface defines for specific options.
  133. * @{
  134. */
  135. #define VALUE_GENSHELL_OPT_SCRIPT 'o'
  136. #define VALUE_GENSHELL_OPT_SHELL 's'
  137. /** option flag (value) for help-value option */
  138. #define VALUE_GENSHELL_OPT_HELP '?'
  139. /** option flag (value) for more-help-value option */
  140. #define VALUE_GENSHELL_OPT_MORE_HELP '!'
  141. /** option flag (value) for version-value option */
  142. #define VALUE_GENSHELL_OPT_VERSION 'v'
  143. /*
  144. * Interface defines not associated with particular options
  145. */
  146. #define ERRSKIP_GENSHELL_OPTERR STMTS(genshelloptOptions.fOptSet &= ~OPTPROC_ERRSTOP)
  147. #define ERRSTOP_GENSHELL_OPTERR STMTS(genshelloptOptions.fOptSet |= OPTPROC_ERRSTOP)
  148. #define RESTART_GENSHELL_OPT(n) STMTS( \
  149. genshelloptOptions.curOptIdx = (n); \
  150. genshelloptOptions.pzCurOpt = NULL )
  151. #define START_GENSHELL_OPT RESTART_GENSHELL_OPT(1)
  152. #define GENSHELL_USAGE(c) (*genshelloptOptions.pUsageProc)(&genshelloptOptions, c)
  153. #ifdef __cplusplus
  154. extern "C" {
  155. #endif
  156. /*
  157. * global exported definitions
  158. */
  159. #define ch_t unsigned char
  160. #define cc_t const unsigned char
  161. #define cch_t char const
  162. /* * * * * *
  163. *
  164. * Declare the genshellopt option descriptor.
  165. */
  166. extern tOptions genshelloptOptions;
  167. #if defined(ENABLE_NLS)
  168. # ifndef _
  169. # include <stdio.h>
  170. # ifndef HAVE_GETTEXT
  171. extern char * gettext(char const *);
  172. # else
  173. # include <libintl.h>
  174. # endif
  175. # ifndef ATTRIBUTE_FORMAT_ARG
  176. # define ATTRIBUTE_FORMAT_ARG(_a)
  177. # endif
  178. static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
  179. static inline char* aoGetsText(char const* pz) {
  180. if (pz == NULL) return NULL;
  181. return (char*)gettext(pz);
  182. }
  183. # define _(s) aoGetsText(s)
  184. # endif /* _() */
  185. # define OPT_NO_XLAT_CFG_NAMES STMTS(genshelloptOptions.fOptSet |= \
  186. OPTPROC_NXLAT_OPT_CFG;)
  187. # define OPT_NO_XLAT_OPT_NAMES STMTS(genshelloptOptions.fOptSet |= \
  188. OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
  189. # define OPT_XLAT_CFG_NAMES STMTS(genshelloptOptions.fOptSet &= \
  190. ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
  191. # define OPT_XLAT_OPT_NAMES STMTS(genshelloptOptions.fOptSet &= \
  192. ~OPTPROC_NXLAT_OPT;)
  193. #else /* ENABLE_NLS */
  194. # define OPT_NO_XLAT_CFG_NAMES
  195. # define OPT_NO_XLAT_OPT_NAMES
  196. # define OPT_XLAT_CFG_NAMES
  197. # define OPT_XLAT_OPT_NAMES
  198. # ifndef _
  199. # define _(_s) _s
  200. # endif
  201. #endif /* ENABLE_NLS */
  202. #ifdef __cplusplus
  203. }
  204. #endif
  205. #endif /* AUTOOPTS_GENSHELL_H_GUARD */
  206. /* genshell.h ends here */