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