1 /*   -*- buffer-read-only: t -*- vi: set ro:
2  *
3  *  DO NOT EDIT THIS FILE   (uudecode-opts.h)
4  *
5  *  It has been AutoGen-ed
6  *  From the definitions    uudecode-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 uudecode 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 uudecode 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  *  uudecode 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  *  uudecode 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 uudecode 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_UUDECODE_OPTS_H_GUARD
47 #define AUTOOPTS_UUDECODE_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 uudecode
68  */
69 typedef enum {
70     INDEX_OPT_OUTPUT_FILE   =  0,
71     INDEX_OPT_IGNORE_CHMOD  =  1,
72     INDEX_OPT_VERSION       =  2,
73     INDEX_OPT_HELP          =  3,
74     INDEX_OPT_MORE_HELP     =  4,
75     INDEX_OPT_SAVE_OPTS     =  5,
76     INDEX_OPT_LOAD_OPTS     =  6
77 } teOptIndex;
78 /** count of all options for uudecode */
79 #define OPTION_CT    7
80 /** uudecode version */
81 #define UUDECODE_VERSION       "4.15.2"
82 /** Full uudecode version text */
83 #define UUDECODE_FULL_VERSION  "uudecode (GNU sharutils) 4.15.2"
84 
85 /**
86  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
87  *  option name (as in the teOptIndex enumeration above).
88  *  e.g. HAVE_OPT(OUTPUT_FILE)
89  */
90 #define         DESC(n) (uudecodeOptions.pOptDesc[INDEX_OPT_## n])
91 /** 'true' if an option has been specified in any way */
92 #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
93 /** The string argument to an option. The argument type must be \"string\". */
94 #define      OPT_ARG(n) (DESC(n).optArg.argString)
95 /** Mask the option state revealing how an option was specified.
96  *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
97  * \a OPTST_DEFINED, \a OPTST_RESET or zero.
98  */
99 #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
100 /** Count of option's occurrances *on the command line*. */
101 #define    COUNT_OPT(n) (DESC(n).optOccCt)
102 /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
103 #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
104 /** 'true' if \a HAVE_OPT would yield 'false'. */
105 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
106 /** 'true' if OPTST_DISABLED bit not set. */
107 #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
108 /** number of stacked option arguments.
109  *  Valid only for stacked option arguments. */
110 #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
111 /** stacked argument vector.
112  *  Valid only for stacked option arguments. */
113 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
114 /** Reset an option. */
115 #define    CLEAR_OPT(n) STMTS( \
116                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
117                 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
118                     DESC(n).fOptState |= OPTST_DISABLED; \
119                 DESC(n).optCookie = NULL )
120 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
121 /**
122  *  Enumeration of uudecode exit codes
123  */
124 typedef enum {
125     UUDECODE_EXIT_SUCCESS         = 0,
126     UUDECODE_EXIT_OPTION_ERROR    = 1,
127     UUDECODE_EXIT_INVALID         = 2,
128     UUDECODE_EXIT_NO_INPUT        = 4,
129     UUDECODE_EXIT_NO_OUTPUT       = 8,
130     UUDECODE_EXIT_NO_MEM          = 9,
131     UUDECODE_EXIT_USAGE_ERROR     = 64,
132     UUDECODE_EXIT_NO_CONFIG_INPUT = 66,
133     UUDECODE_EXIT_LIBOPTS_FAILURE = 70
134 }   uudecode_exit_code_t;
135 /**
136  *  Interface defines for specific options.
137  * @{
138  */
139 #define VALUE_OPT_OUTPUT_FILE    'o'
140 #define VALUE_OPT_IGNORE_CHMOD   'c'
141 /** option flag (value) for help-value option */
142 #define VALUE_OPT_HELP          'h'
143 /** option flag (value) for more-help-value option */
144 #define VALUE_OPT_MORE_HELP     '!'
145 /** option flag (value) for version-value option */
146 #define VALUE_OPT_VERSION       'v'
147 /** option flag (value) for save-opts-value option */
148 #define VALUE_OPT_SAVE_OPTS     'R'
149 /** option flag (value) for load-opts-value option */
150 #define VALUE_OPT_LOAD_OPTS     'r'
151 #define SET_OPT_SAVE_OPTS(a)   STMTS( \
152         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
153         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
154         DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
155 /*
156  *  Interface defines not associated with particular options
157  */
158 #define ERRSKIP_OPTERR  STMTS(uudecodeOptions.fOptSet &= ~OPTPROC_ERRSTOP)
159 #define ERRSTOP_OPTERR  STMTS(uudecodeOptions.fOptSet |= OPTPROC_ERRSTOP)
160 #define RESTART_OPT(n)  STMTS( \
161                 uudecodeOptions.curOptIdx = (n); \
162                 uudecodeOptions.pzCurOpt  = NULL )
163 #define START_OPT       RESTART_OPT(1)
164 #define USAGE(c)        (*uudecodeOptions.pUsageProc)(&uudecodeOptions, c)
165 
166 #ifdef  __cplusplus
167 extern "C" {
168 #endif
169 /*
170  *  global exported definitions
171  */
172 #include "local.h"
173 
174 
175 /* * * * * *
176  *
177  *  Declare the uudecode option descriptor.
178  */
179 extern tOptions uudecodeOptions;
180 
181 #if defined(ENABLE_NLS)
182 # ifndef _
183 #   include <stdio.h>
184 #   ifndef HAVE_GETTEXT
185       extern char * gettext(char const *);
186 #   else
187 #     include <libintl.h>
188 #   endif
189 
190 # ifndef ATTRIBUTE_FORMAT_ARG
191 #   define ATTRIBUTE_FORMAT_ARG(_a)
192 # endif
193 
194 static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
aoGetsText(char const * pz)195 static inline char* aoGetsText(char const* pz) {
196     if (pz == NULL) return NULL;
197     return (char*)gettext(pz);
198 }
199 #   define _(s)  aoGetsText(s)
200 # endif /* _() */
201 
202 # define OPT_NO_XLAT_CFG_NAMES  STMTS(uudecodeOptions.fOptSet |= \
203                                     OPTPROC_NXLAT_OPT_CFG;)
204 # define OPT_NO_XLAT_OPT_NAMES  STMTS(uudecodeOptions.fOptSet |= \
205                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
206 
207 # define OPT_XLAT_CFG_NAMES     STMTS(uudecodeOptions.fOptSet &= \
208                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
209 # define OPT_XLAT_OPT_NAMES     STMTS(uudecodeOptions.fOptSet &= \
210                                   ~OPTPROC_NXLAT_OPT;)
211 
212 #else   /* ENABLE_NLS */
213 # define OPT_NO_XLAT_CFG_NAMES
214 # define OPT_NO_XLAT_OPT_NAMES
215 
216 # define OPT_XLAT_CFG_NAMES
217 # define OPT_XLAT_OPT_NAMES
218 
219 # ifndef _
220 #   define _(_s)  _s
221 # endif
222 #endif  /* ENABLE_NLS */
223 
224 extern void vusage_message(char const * fmt, va_list ap);
225 extern void usage_message(char const * fmt, ...);
226 extern void vdie( int exit_code, char const * fmt, va_list);
227 extern void die(  int exit_code, char const * fmt, ...);
228 extern void fserr(int exit_code, char const * op, char const * fn);
229 
230 /**
231  * Print a UUDECODE_EXIT_NO_MEM fatal error message and die.
232  *
233  * @param[in] sz     the object size that was not allocated
234  * @param[in] what   what that object was going to be
235  * @noreturn
236  */
237 static inline void
nomem_err(size_t sz,char const * what)238 nomem_err(size_t sz, char const * what)
239 {
240     char const * fmt = _("could not allocate %zu bytes for %s\n");
241     die(UUDECODE_EXIT_NO_MEM, fmt, sz, what);
242 }
243 #ifdef  __cplusplus
244 }
245 #endif
246 #endif /* AUTOOPTS_UUDECODE_OPTS_H_GUARD */
247 
248 /* uudecode-opts.h ends here */
249