genshell.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 41:1:16 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-2014 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. /**
  51. * Ensure that the library used for compiling this generated header is at
  52. * least as new as the version current when the header template was released
  53. * (not counting patch version increments). Also ensure that the oldest
  54. * tolerable version is at least as old as what was current when the header
  55. * template was released.
  56. */
  57. #define AO_TEMPLATE_VERSION 167937
  58. #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
  59. || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
  60. # error option template version mismatches autoopts/options.h header
  61. Choke Me.
  62. #endif
  63. /**
  64. * Enumeration of each option type for genshellopt
  65. */
  66. typedef enum {
  67. INDEX_GENSHELL_OPT_SCRIPT = 0,
  68. INDEX_GENSHELL_OPT_SHELL = 1,
  69. INDEX_GENSHELL_OPT_VERSION = 2,
  70. INDEX_GENSHELL_OPT_HELP = 3,
  71. INDEX_GENSHELL_OPT_MORE_HELP = 4
  72. } teGenshell_OptIndex;
  73. /** count of all options for genshellopt */
  74. #define GENSHELL_OPTION_CT 5
  75. /** genshellopt version */
  76. #define GENSHELLOPT_VERSION "1"
  77. /** Full genshellopt version text */
  78. #define GENSHELLOPT_FULL_VERSION "genshellopt 1"
  79. /**
  80. * Interface defines for all options. Replace "n" with the UPPER_CASED
  81. * option name (as in the teGenshell_OptIndex enumeration above).
  82. * e.g. HAVE_GENSHELL_OPT(SCRIPT)
  83. */
  84. #define GENSHELL_DESC(n) (genshelloptOptions.pOptDesc[INDEX_GENSHELL_OPT_## n])
  85. /** 'true' if an option has been specified in any way */
  86. #define HAVE_GENSHELL_OPT(n) (! UNUSED_OPT(& GENSHELL_DESC(n)))
  87. /** The string argument to an option. The argument type must be \"string\". */
  88. #define GENSHELL_OPT_ARG(n) (GENSHELL_DESC(n).optArg.argString)
  89. /** Mask the option state revealing how an option was specified.
  90. * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
  91. * \a OPTST_DEFINED, \a OPTST_RESET or zero.
  92. */
  93. #define STATE_GENSHELL_OPT(n) (GENSHELL_DESC(n).fOptState & OPTST_SET_MASK)
  94. /** Count of option's occurrances *on the command line*. */
  95. #define COUNT_GENSHELL_OPT(n) (GENSHELL_DESC(n).optOccCt)
  96. /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
  97. #define ISSEL_GENSHELL_OPT(n) (SELECTED_OPT(&GENSHELL_DESC(n)))
  98. /** 'true' if \a HAVE_OPT would yield 'false'. */
  99. #define ISUNUSED_GENSHELL_OPT(n) (UNUSED_OPT(& GENSHELL_DESC(n)))
  100. /** 'true' if OPTST_DISABLED bit not set. */
  101. #define ENABLED_GENSHELL_OPT(n) (! DISABLED_OPT(& GENSHELL_DESC(n)))
  102. /** number of stacked option arguments.
  103. * Valid only for stacked option arguments. */
  104. #define STACKCT_GENSHELL_OPT(n) (((tArgList*)(GENSHELL_DESC(n).optCookie))->useCt)
  105. /** stacked argument vector.
  106. * Valid only for stacked option arguments. */
  107. #define STACKLST_GENSHELL_OPT(n) (((tArgList*)(GENSHELL_DESC(n).optCookie))->apzArgs)
  108. /** Reset an option. */
  109. #define CLEAR_GENSHELL_OPT(n) STMTS( \
  110. GENSHELL_DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \
  111. if ((GENSHELL_DESC(n).fOptState & OPTST_INITENABLED) == 0) \
  112. GENSHELL_DESC(n).fOptState |= OPTST_DISABLED; \
  113. GENSHELL_DESC(n).optCookie = NULL )
  114. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  115. /**
  116. * Enumeration of genshellopt exit codes
  117. */
  118. typedef enum {
  119. GENSHELLOPT_EXIT_SUCCESS = 0,
  120. GENSHELLOPT_EXIT_FAILURE = 1,
  121. GENSHELLOPT_EXIT_USAGE_ERROR = 64,
  122. GENSHELLOPT_EXIT_LIBOPTS_FAILURE = 70
  123. } genshellopt_exit_code_t;
  124. /**
  125. * Interface defines for specific options.
  126. * @{
  127. */
  128. #define VALUE_GENSHELL_OPT_SCRIPT 'o'
  129. #define VALUE_GENSHELL_OPT_SHELL 's'
  130. /** option flag (value) for help-value option */
  131. #define VALUE_GENSHELL_OPT_HELP '?'
  132. /** option flag (value) for more-help-value option */
  133. #define VALUE_GENSHELL_OPT_MORE_HELP '!'
  134. /** option flag (value) for version-value option */
  135. #define VALUE_GENSHELL_OPT_VERSION 'v'
  136. /*
  137. * Interface defines not associated with particular options
  138. */
  139. #define ERRSKIP_GENSHELL_OPTERR STMTS(genshelloptOptions.fOptSet &= ~OPTPROC_ERRSTOP)
  140. #define ERRSTOP_GENSHELL_OPTERR STMTS(genshelloptOptions.fOptSet |= OPTPROC_ERRSTOP)
  141. #define RESTART_GENSHELL_OPT(n) STMTS( \
  142. genshelloptOptions.curOptIdx = (n); \
  143. genshelloptOptions.pzCurOpt = NULL )
  144. #define START_GENSHELL_OPT RESTART_GENSHELL_OPT(1)
  145. #define GENSHELL_USAGE(c) (*genshelloptOptions.pUsageProc)(&genshelloptOptions, c)
  146. #ifdef __cplusplus
  147. extern "C" {
  148. #endif
  149. /* * * * * *
  150. *
  151. * Declare the genshellopt option descriptor.
  152. */
  153. extern tOptions genshelloptOptions;
  154. #if defined(ENABLE_NLS)
  155. # ifndef _
  156. # include <stdio.h>
  157. # ifndef HAVE_GETTEXT
  158. extern char * gettext(char const *);
  159. # else
  160. # include <libintl.h>
  161. # endif
  162. # ifndef ATTRIBUTE_FORMAT_ARG
  163. # define ATTRIBUTE_FORMAT_ARG(_a)
  164. # endif
  165. static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
  166. static inline char* aoGetsText(char const* pz) {
  167. if (pz == NULL) return NULL;
  168. return (char*)gettext(pz);
  169. }
  170. # define _(s) aoGetsText(s)
  171. # endif /* _() */
  172. # define OPT_NO_XLAT_CFG_NAMES STMTS(genshelloptOptions.fOptSet |= \
  173. OPTPROC_NXLAT_OPT_CFG;)
  174. # define OPT_NO_XLAT_OPT_NAMES STMTS(genshelloptOptions.fOptSet |= \
  175. OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
  176. # define OPT_XLAT_CFG_NAMES STMTS(genshelloptOptions.fOptSet &= \
  177. ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
  178. # define OPT_XLAT_OPT_NAMES STMTS(genshelloptOptions.fOptSet &= \
  179. ~OPTPROC_NXLAT_OPT;)
  180. #else /* ENABLE_NLS */
  181. # define OPT_NO_XLAT_CFG_NAMES
  182. # define OPT_NO_XLAT_OPT_NAMES
  183. # define OPT_XLAT_CFG_NAMES
  184. # define OPT_XLAT_OPT_NAMES
  185. # ifndef _
  186. # define _(_s) _s
  187. # endif
  188. #endif /* ENABLE_NLS */
  189. #ifdef __cplusplus
  190. }
  191. #endif
  192. #endif /* AUTOOPTS_GENSHELL_H_GUARD */
  193. /* genshell.h ends here */