1 /*   -*- buffer-read-only: t -*- vi: set ro:
2  *
3  *  DO NOT EDIT THIS FILE   (unshar-opts.h)
4  *
5  *  It has been AutoGen-ed
6  *  From the definitions    unshar-opts.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 unshar 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 unshar program is copyrighted and licensed
20  * under the following terms:
21  *
22  *  Copyright (C) 1994-2015 Free Software Foundation, Inc., all rights reserved.
23  *  This is free software. It is licensed for use, modification and
24  *  redistribution under the terms of the GNU General Public License,
25  *  version 3 or later <http://gnu.org/licenses/gpl.html>
26  *
27  *  unshar is free software: you can redistribute it and/or modify it
28  *  under the terms of the GNU General Public License as published by the
29  *  Free Software Foundation, either version 3 of the License, or
30  *  (at your option) any later version.
31  *
32  *  unshar 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 General Public License for more details.
36  *
37  *  You should have received a copy of the GNU General Public License along
38  *  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 unshar 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_UNSHAR_OPTS_H_GUARD
47 #define AUTOOPTS_UNSHAR_OPTS_H_GUARD 1
48 #include "config.h"
49 #include <autoopts/options.h>
50 #include <stdarg.h>
51 
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 167937
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 
66 /**
67  *  Enumeration of each option type for unshar
68  */
69 typedef enum {
70     INDEX_OPT_DIRECTORY   =  0,
71     INDEX_OPT_OVERWRITE   =  1,
72     INDEX_OPT_FORCE       =  2,
73     INDEX_OPT_SPLIT_AT    =  3,
74     INDEX_OPT_EXIT_0      =  4,
75     INDEX_OPT_DEBUG       =  5,
76     INDEX_OPT_VERSION     =  6,
77     INDEX_OPT_HELP        =  7,
78     INDEX_OPT_MORE_HELP   =  8,
79     INDEX_OPT_SAVE_OPTS   =  9,
80     INDEX_OPT_LOAD_OPTS   = 10
81 } teOptIndex;
82 /** count of all options for unshar */
83 #define OPTION_CT    11
84 /** unshar version */
85 #define UNSHAR_VERSION       "4.15.2"
86 /** Full unshar version text */
87 #define UNSHAR_FULL_VERSION  "unshar (GNU sharutils) 4.15.2"
88 
89 /**
90  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
91  *  option name (as in the teOptIndex enumeration above).
92  *  e.g. HAVE_OPT(DIRECTORY)
93  */
94 #define         DESC(n) (unsharOptions.pOptDesc[INDEX_OPT_## n])
95 /** 'true' if an option has been specified in any way */
96 #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
97 /** The string argument to an option. The argument type must be \"string\". */
98 #define      OPT_ARG(n) (DESC(n).optArg.argString)
99 /** Mask the option state revealing how an option was specified.
100  *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
101  * \a OPTST_DEFINED, \a OPTST_RESET or zero.
102  */
103 #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
104 /** Count of option's occurrances *on the command line*. */
105 #define    COUNT_OPT(n) (DESC(n).optOccCt)
106 /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
107 #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
108 /** 'true' if \a HAVE_OPT would yield 'false'. */
109 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
110 /** 'true' if OPTST_DISABLED bit not set. */
111 #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
112 /** number of stacked option arguments.
113  *  Valid only for stacked option arguments. */
114 #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
115 /** stacked argument vector.
116  *  Valid only for stacked option arguments. */
117 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
118 /** Reset an option. */
119 #define    CLEAR_OPT(n) STMTS( \
120                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
121                 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
122                     DESC(n).fOptState |= OPTST_DISABLED; \
123                 DESC(n).optCookie = NULL )
124 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
125 /**
126  *  Enumeration of unshar exit codes
127  */
128 typedef enum {
129     UNSHAR_EXIT_SUCCESS         = 0,
130     UNSHAR_EXIT_FAILURE         = 1,
131     UNSHAR_EXIT_POPEN_PROBLEM   = 2,
132     UNSHAR_EXIT_CANNOT_CREATE   = 3,
133     UNSHAR_EXIT_BAD_DIRECTORY   = 4,
134     UNSHAR_EXIT_NOMEM           = 5,
135     UNSHAR_EXIT_INVALID         = 6,
136     UNSHAR_EXIT_USAGE_ERROR     = 64,
137     UNSHAR_EXIT_NO_CONFIG_INPUT = 66,
138     UNSHAR_EXIT_LIBOPTS_FAILURE = 70
139 }   unshar_exit_code_t;
140 /**
141  *  Interface defines for specific options.
142  * @{
143  */
144 #define VALUE_OPT_DIRECTORY      'd'
145 #define VALUE_OPT_OVERWRITE      'c'
146 #define VALUE_OPT_FORCE          'f'
147 #define VALUE_OPT_SPLIT_AT       'E'
148 
149 #define SET_OPT_SPLIT_AT(a)   STMTS( \
150         DESC(SPLIT_AT).optActualIndex = 3; \
151         DESC(SPLIT_AT).optActualValue = VALUE_OPT_SPLIT_AT; \
152         DESC(SPLIT_AT).fOptState &= OPTST_PERSISTENT_MASK; \
153         DESC(SPLIT_AT).fOptState |= OPTST_SET; \
154         DESC(SPLIT_AT).optArg.argString = (a); \
155         (*(DESC(SPLIT_AT).pOptProc))(&unsharOptions, \
156                 unsharOptions.pOptDesc + 3); )
157 #define VALUE_OPT_EXIT_0         'e'
158 #define VALUE_OPT_DEBUG          'D'
159 /** option flag (value) for help-value option */
160 #define VALUE_OPT_HELP          'h'
161 /** option flag (value) for more-help-value option */
162 #define VALUE_OPT_MORE_HELP     '!'
163 /** option flag (value) for version-value option */
164 #define VALUE_OPT_VERSION       'v'
165 /** option flag (value) for save-opts-value option */
166 #define VALUE_OPT_SAVE_OPTS     'R'
167 /** option flag (value) for load-opts-value option */
168 #define VALUE_OPT_LOAD_OPTS     'r'
169 #define SET_OPT_SAVE_OPTS(a)   STMTS( \
170         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
171         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
172         DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
173 /*
174  *  Interface defines not associated with particular options
175  */
176 #define ERRSKIP_OPTERR  STMTS(unsharOptions.fOptSet &= ~OPTPROC_ERRSTOP)
177 #define ERRSTOP_OPTERR  STMTS(unsharOptions.fOptSet |= OPTPROC_ERRSTOP)
178 #define RESTART_OPT(n)  STMTS( \
179                 unsharOptions.curOptIdx = (n); \
180                 unsharOptions.pzCurOpt  = NULL )
181 #define START_OPT       RESTART_OPT(1)
182 #define USAGE(c)        (*unsharOptions.pUsageProc)(&unsharOptions, c)
183 
184 #ifdef  __cplusplus
185 extern "C" {
186 #endif
187 /*
188  *  global exported definitions
189  */
190 #include <stddef.h>
191 
192 extern size_t       separator_str_len;
193 
194 #include "local.h"
195 
196 
197 /* * * * * *
198  *
199  *  Declare the unshar option descriptor.
200  */
201 extern tOptions unsharOptions;
202 
203 #if defined(ENABLE_NLS)
204 # ifndef _
205 #   include <stdio.h>
206 #   ifndef HAVE_GETTEXT
207       extern char * gettext(char const *);
208 #   else
209 #     include <libintl.h>
210 #   endif
211 
212 # ifndef ATTRIBUTE_FORMAT_ARG
213 #   define ATTRIBUTE_FORMAT_ARG(_a)
214 # endif
215 
216 static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
aoGetsText(char const * pz)217 static inline char* aoGetsText(char const* pz) {
218     if (pz == NULL) return NULL;
219     return (char*)gettext(pz);
220 }
221 #   define _(s)  aoGetsText(s)
222 # endif /* _() */
223 
224 # define OPT_NO_XLAT_CFG_NAMES  STMTS(unsharOptions.fOptSet |= \
225                                     OPTPROC_NXLAT_OPT_CFG;)
226 # define OPT_NO_XLAT_OPT_NAMES  STMTS(unsharOptions.fOptSet |= \
227                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
228 
229 # define OPT_XLAT_CFG_NAMES     STMTS(unsharOptions.fOptSet &= \
230                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
231 # define OPT_XLAT_OPT_NAMES     STMTS(unsharOptions.fOptSet &= \
232                                   ~OPTPROC_NXLAT_OPT;)
233 
234 #else   /* ENABLE_NLS */
235 # define OPT_NO_XLAT_CFG_NAMES
236 # define OPT_NO_XLAT_OPT_NAMES
237 
238 # define OPT_XLAT_CFG_NAMES
239 # define OPT_XLAT_OPT_NAMES
240 
241 # ifndef _
242 #   define _(_s)  _s
243 # endif
244 #endif  /* ENABLE_NLS */
245 
246 extern void vusage_message(char const * fmt, va_list ap);
247 extern void usage_message(char const * fmt, ...);
248 extern void vdie( int exit_code, char const * fmt, va_list);
249 extern void die(  int exit_code, char const * fmt, ...);
250 extern void fserr(int exit_code, char const * op, char const * fn);
251 
252 /**
253  * Print a UNSHAR_EXIT_NOMEM fatal error message and die.
254  *
255  * @param[in] sz     the object size that was not allocated
256  * @param[in] what   what that object was going to be
257  * @noreturn
258  */
259 static inline void
nomem_err(size_t sz,char const * what)260 nomem_err(size_t sz, char const * what)
261 {
262     char const * fmt = _("could not allocate %zu bytes for %s\n");
263     die(UNSHAR_EXIT_NOMEM, fmt, sz, what);
264 }
265 #ifdef  __cplusplus
266 }
267 #endif
268 #endif /* AUTOOPTS_UNSHAR_OPTS_H_GUARD */
269 
270 /* unshar-opts.h ends here */
271