Deleted Added
full compact
options.h (302408) options.h (181834)
1/* -*- buffer-read-only: t -*- vi: set ro:
1/* -*- buffer-read-only: t -*- vi: set ro:
2 *
2 *
3 * DO NOT EDIT THIS FILE (options.h)
3 * DO NOT EDIT THIS FILE (options.h)
4 *
5 * It has been AutoGen-ed
4 *
5 * It has been AutoGen-ed Saturday May 5, 2007 at 12:02:34 PM PDT
6 * From the definitions funcs.def
7 * and the template file options_h
8 *
9 * This file defines all the global structures and special values
10 * used in the automated option processing library.
11 *
6 * From the definitions funcs.def
7 * and the template file options_h
8 *
9 * This file defines all the global structures and special values
10 * used in the automated option processing library.
11 *
12 * Automated Options Copyright (C) 1992-2015 by Bruce Korb
12 * Automated Options copyright 1992-Y Bruce Korb
13 *
13 *
14 * This file is part of AutoOpts, a companion to AutoGen.
15 * AutoOpts is free software.
16 * AutoOpts is Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
17 *
18 * AutoOpts is available under any one of two licenses. The license
19 * in use must be one of these two and the choice is under the control
20 * of the user of the license.
21 *
22 * The GNU Lesser General Public License, version 3 or later
23 * See the files "COPYING.lgplv3" and "COPYING.gplv3"
24 *
25 * The Modified Berkeley Software Distribution License
26 * See the file "COPYING.mbsd"
27 *
28 * These files have the following sha256 sums:
29 *
30 * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
31 * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
32 * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
14 * AutoOpts is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
18 *
19 * AutoOpts is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with AutoOpts. If not, write to:
26 * The Free Software Foundation, Inc.,
27 * 51 Franklin Street, Fifth Floor
28 * Boston, MA 02110-1301, USA.
33 */
34#ifndef AUTOOPTS_OPTIONS_H_GUARD
29 */
30#ifndef AUTOOPTS_OPTIONS_H_GUARD
35#define AUTOOPTS_OPTIONS_H_GUARD 1
36/** \file options.h
37 *
38 * @addtogroup autoopts
39 * @{
40 */
31#define AUTOOPTS_OPTIONS_H_GUARD
41#include <sys/types.h>
32#include <sys/types.h>
42#include <stdio.h>
43
33
44#ifndef COMPAT_H_GUARD
45/*
46 * This is needed for test compilations where the "compat.h"
47 * header is not usually available.
48 */
49# if defined(HAVE_STDINT_H)
50# include <stdint.h>
51# elif defined(HAVE_INTTYPES_H)
52# include <inttypes.h>
53# endif /* HAVE_STDINT/INTTYPES_H */
34#if defined(HAVE_STDINT_H)
35# include <stdint.h>
36#elif defined(HAVE_INTTYPES_H)
37# include <inttypes.h>
38#endif /* HAVE_STDINT/INTTYPES_H */
54
39
55# if defined(HAVE_LIMITS_H)
56# include <limits.h>
57# elif defined(HAVE_SYS_LIMITS_H)
58# include <sys/limits.h>
59# endif /* HAVE_LIMITS/SYS_LIMITS_H */
40#if defined(HAVE_LIMITS_H)
41# include
42#elif defined(HAVE_SYS_LIMITS_H)
43# include
44#endif /* HAVE_LIMITS/SYS_LIMITS_H */
60
45
61# if defined(HAVE_SYSEXITS_H)
62# include <sysexits.h>
63# endif /* HAVE_SYSEXITS_H */
46#if defined(HAVE_SYSEXITS_H)
47# include
48#endif /* HAVE_SYSEXITS_H */
64
49
65# if defined(HAVE_STDBOOL_H)
66# include <stdbool.h>
67# else
68 typedef enum { false = 0, true = 1 } _Bool;
69# define bool _Bool
50#ifndef EX_USAGE
51# define EX_USAGE 64
52#endif
70
53
71 /* The other macros must be usable in preprocessor directives. */
72# define false 0
73# define true 1
74# endif /* HAVE_SYSEXITS_H */
75#endif /* COMPAT_H_GUARD */
76// END-CONFIGURED-HEADERS
77
78/**
79 * Defined to abnormal value of EX_USAGE. Used to indicate that paged usage
80 * was requested. It is used to distinguish a --usage from a --help request.
81 * --usage is abbreviated and --help gives as much help as possible.
82 */
83#define AO_EXIT_REQ_USAGE 10064
84
85#undef VOIDP
86/**
87 * Coerce a value into a void pointer with no const or volatile attributes.
88 * Somewhere along the line, the above set of includes need to set up
89 * the "uintptr_t" type.
90 */
91#define VOIDP(_a) ((void *)(uintptr_t)(_a))
92
93/**
54/*
94 * PUBLIC DEFINES
95 *
96 * The following defines may be used in applications that need to test the
97 * state of an option. To test against these masks and values, a pointer
98 * to an option descriptor must be obtained. There are two ways:
99 *
100 * 1. inside an option processing procedure, it is the second argument,
55 * PUBLIC DEFINES
56 *
57 * The following defines may be used in applications that need to test the
58 * state of an option. To test against these masks and values, a pointer
59 * to an option descriptor must be obtained. There are two ways:
60 *
61 * 1. inside an option processing procedure, it is the second argument,
101 * conventionally "tOptDesc * pOD".
62 * conventionally "tOptDesc* pOD".
102 *
63 *
103 * 2. Outside of an option procedure (or to reference a different option
104 * descriptor), use either "&DESC( opt_name )" or "&pfx_DESC( opt_name )".
64 * 2. Outside of an option procedure (or to reference a different option
65 * descriptor), use either "&DESC( opt_name )" or "&pfx_DESC( opt_name )".
105 *
106 * See the relevant generated header file to determine which and what
107 * values for "opt_name" are available.
66 *
67 * See the relevant generated header file to determine which and what
68 * values for "opt_name" are available.
108 * @group version
109 * @{
110 */
69 */
111/// autoopts structure version
112#define OPTIONS_STRUCT_VERSION 167936
113/// autoopts structure version string
114#define OPTIONS_VERSION_STRING "41:0:16"
115/// minimum version the autoopts library supports
116#define OPTIONS_MINIMUM_VERSION 102400
117/// minimum version the autoopts library supports as a string
118#define OPTIONS_MIN_VER_STRING "25:0:0"
119/// the display version of the autoopts library, as a string
120#define OPTIONS_DOTTED_VERSION "41.0"
121/// convert a version/release number pair to an integer value
122#define OPTIONS_VER_TO_NUM(_v, _r) (((_v) * 4096) + (_r))
123/// @}
124
70
125/**
126 * Option argument types. This must fit in the OPTST_ARG_TYPE_MASK
127 * field of the fOptState field of an option descriptor (tOptDesc).
128 * It will be a problem to extend beyond 4 bits.
129 */
71#define OPTIONS_STRUCT_VERSION 118784
72#define OPTIONS_VERSION_STRING "29:0:4"
73#define OPTIONS_MINIMUM_VERSION 102400
74#define OPTIONS_MIN_VER_STRING "25:0:0"
75
130typedef enum {
76typedef enum {
131 OPARG_TYPE_NONE = 0, ///< does not take an argument
132 OPARG_TYPE_STRING = 1, ///< default type/ vanilla string
133 OPARG_TYPE_ENUMERATION = 2, ///< opt arg is an enum (keyword list)
134 OPARG_TYPE_BOOLEAN = 3, ///< opt arg is boolean-valued
135 OPARG_TYPE_MEMBERSHIP = 4, ///< opt arg sets set membership bits
136 OPARG_TYPE_NUMERIC = 5, ///< opt arg is a long int
137 OPARG_TYPE_HIERARCHY = 6, ///< option arg is hierarchical value
138 OPARG_TYPE_FILE = 7, ///< option arg names a file
139 OPARG_TYPE_TIME = 8, ///< opt arg is a time duration
140 OPARG_TYPE_FLOAT = 9, ///< opt arg is a floating point num
141 OPARG_TYPE_DOUBLE = 10, ///< opt arg is a double prec. float
142 OPARG_TYPE_LONG_DOUBLE = 11, ///< opt arg is a long double prec.
143 OPARG_TYPE_LONG_LONG = 12 ///< opt arg is a long long int
77 OPARG_TYPE_NONE = 0,
78 OPARG_TYPE_STRING = 1, /* default type/ vanilla string */
79 OPARG_TYPE_ENUMERATION = 2, /* opt arg is an enum (keyword list) */
80 OPARG_TYPE_BOOLEAN = 3, /* opt arg is boolean-valued */
81 OPARG_TYPE_MEMBERSHIP = 4, /* opt arg sets set membership bits */
82 OPARG_TYPE_NUMERIC = 5, /* opt arg has numeric value */
83 OPARG_TYPE_HIERARCHY = 6 /* option arg is hierarchical value */
144} teOptArgType;
145
84} teOptArgType;
85
146/**
147 * value descriptor for sub options
148 */
149typedef struct optionValue {
86typedef struct optionValue {
150 teOptArgType valType; ///< which argument type
151 char * pzName; ///< name of the sub-option
87 teOptArgType valType;
88 char* pzName;
152 union {
89 union {
153 char strVal[1]; ///< OPARG_TYPE_STRING
154 unsigned int enumVal; ///< OPARG_TYPE_ENUMERATION
155 unsigned int boolVal; ///< OPARG_TYPE_BOOLEAN
156 unsigned long setVal; ///< OPARG_TYPE_MEMBERSHIP
157 long longVal; ///< OPARG_TYPE_NUMERIC
158 void * nestVal; ///< OPARG_TYPE_HIERARCHY
90 char strVal[1]; /* OPARG_TYPE_STRING */
91 unsigned int enumVal; /* OPARG_TYPE_ENUMERATION */
92 unsigned int boolVal; /* OPARG_TYPE_BOOLEAN */
93 unsigned long setVal; /* OPARG_TYPE_MEMBERSHIP */
94 long longVal; /* OPARG_TYPE_NUMERIC */
95 void* nestVal; /* OPARG_TYPE_HIERARCHY */
159 } v;
160} tOptionValue;
161
96 } v;
97} tOptionValue;
98
162/**
163 * file argument state and handling.
99/*
100 * Bits in the fOptState option descriptor field.
164 */
165typedef enum {
101 */
102typedef enum {
166 FTYPE_MODE_MAY_EXIST = 0x00, ///< may or may not exist
167 FTYPE_MODE_MUST_EXIST = 0x01, ///< must pre-exist
168 FTYPE_MODE_MUST_NOT_EXIST = 0x02, ///< must *not* pre-exist
169 FTYPE_MODE_EXIST_MASK = 0x03, ///< mask for these bits
170 FTYPE_MODE_NO_OPEN = 0x00, ///< leave file closed
171 FTYPE_MODE_OPEN_FD = 0x10, ///< call open(2)
172 FTYPE_MODE_FOPEN_FP = 0x20, ///< call fopen(3)
173 FTYPE_MODE_OPEN_MASK = 0x30 ///< open/fopen/not open
174} teOptFileType;
103 OPTST_SET_ID = 0, /* Set via the "SET_OPT()" macro */
104 OPTST_PRESET_ID = 1, /* Set via an RC/INI file */
105 OPTST_DEFINED_ID = 2, /* Set via a command line option */
106 OPTST_EQUIVALENCE_ID = 4, /* selected by equiv'ed option */
107 OPTST_DISABLED_ID = 5, /* option is in disabled state */
108 OPTST_ALLOC_ARG_ID = 6, /* pzOptArg was allocated */
109 OPTST_NO_INIT_ID = 8, /* option cannot be preset */
110 OPTST_NUMBER_OPT_ID = 9, /* opt value (flag) is any digit */
111 OPTST_STACKED_ID = 10, /* opt uses optionStackArg proc */
112 OPTST_INITENABLED_ID = 11, /* option defaults to enabled */
113 OPTST_ARG_TYPE_1_ID = 12, /* bit 1 of arg type enum */
114 OPTST_ARG_TYPE_2_ID = 13, /* bit 2 of arg type enum */
115 OPTST_ARG_TYPE_3_ID = 14, /* bit 3 of arg type enum */
116 OPTST_ARG_TYPE_4_ID = 15, /* bit 4 of arg type enum */
117 OPTST_ARG_OPTIONAL_ID = 16, /* the option arg not required */
118 OPTST_IMM_ID = 17, /* process opt on first pass */
119 OPTST_DISABLE_IMM_ID = 18, /* process disablement immed. */
120 OPTST_OMITTED_ID = 19, /* compiled out of program */
121 OPTST_MUST_SET_ID = 20, /* must be set or pre-set */
122 OPTST_DOCUMENT_ID = 21, /* opt is for doc only */
123 OPTST_TWICE_ID = 22, /* process opt twice - imm + reg */
124 OPTST_DISABLE_TWICE_ID = 23 /* process disabled option twice */
125} opt_state_enum_t;
175
126
176/**
177 * the open flag bits or the mode string, depending on the open type.
178 */
179typedef union {
180 int file_flags; ///< open(2) flag bits
181 char const * file_mode; ///< fopen(3) mode string
182} tuFileMode;
127#define OPTST_INIT 0U
128#define OPTST_SET (1U << OPTST_SET_ID)
129#define OPTST_PRESET (1U << OPTST_PRESET_ID)
130#define OPTST_DEFINED (1U << OPTST_DEFINED_ID)
131#define OPTST_EQUIVALENCE (1U << OPTST_EQUIVALENCE_ID)
132#define OPTST_DISABLED (1U << OPTST_DISABLED_ID)
133#define OPTST_ALLOC_ARG (1U << OPTST_ALLOC_ARG_ID)
134#define OPTST_NO_INIT (1U << OPTST_NO_INIT_ID)
135#define OPTST_NUMBER_OPT (1U << OPTST_NUMBER_OPT_ID)
136#define OPTST_STACKED (1U << OPTST_STACKED_ID)
137#define OPTST_INITENABLED (1U << OPTST_INITENABLED_ID)
138#define OPTST_ARG_TYPE_1 (1U << OPTST_ARG_TYPE_1_ID)
139#define OPTST_ARG_TYPE_2 (1U << OPTST_ARG_TYPE_2_ID)
140#define OPTST_ARG_TYPE_3 (1U << OPTST_ARG_TYPE_3_ID)
141#define OPTST_ARG_TYPE_4 (1U << OPTST_ARG_TYPE_4_ID)
142#define OPTST_ARG_OPTIONAL (1U << OPTST_ARG_OPTIONAL_ID)
143#define OPTST_IMM (1U << OPTST_IMM_ID)
144#define OPTST_DISABLE_IMM (1U << OPTST_DISABLE_IMM_ID)
145#define OPTST_OMITTED (1U << OPTST_OMITTED_ID)
146#define OPTST_MUST_SET (1U << OPTST_MUST_SET_ID)
147#define OPTST_DOCUMENT (1U << OPTST_DOCUMENT_ID)
148#define OPTST_TWICE (1U << OPTST_TWICE_ID)
149#define OPTST_DISABLE_TWICE (1U << OPTST_DISABLE_TWICE_ID)
150#define OPT_STATE_MASK 0x00FFFF77U
183
151
184/// initial number of option argument holders to allocate
185#define MIN_ARG_ALLOC_CT 6
186/// amount by which to increment the argument holder allocation.
187#define INCR_ARG_ALLOC_CT 8
188/**
189 * an argument list. When an option appears multiple times and
190 * the values get "stacked". \a apzArgs holds 8 pointers initially
191 * and is incremented by \a INCR_ARG_ALLOC_CT as needed.
192 */
193typedef struct {
194 int useCt; ///< elements in use
152#define OPTST_SET_MASK ( \
153 OPTST_SET | \
154 OPTST_PRESET | \
155 OPTST_DEFINED )
195
156
196 /// allocated elements, mininum \a MIN_ARG_ALLOC_CT
197 /// steps by \a INCR_ARG_ALLOC_CT
198 int allocCt;
199 char const * apzArgs[MIN_ARG_ALLOC_CT]; ///< element array
200} tArgList;
157#define OPTST_MUTABLE_MASK ( \
158 OPTST_SET | \
159 OPTST_PRESET | \
160 OPTST_DEFINED | \
161 OPTST_EQUIVALENCE | \
162 OPTST_DISABLED | \
163 OPTST_ALLOC_ARG )
201
164
202/**
203 * Bits in the fOptState option descriptor field.
204 * @{
205 */
165#define OPTST_SELECTED_MASK ( \
166 OPTST_SET | \
167 OPTST_DEFINED )
206
168
207/** integral type for holding opt_state masks */
208typedef uint32_t opt_state_mask_t;
169#define OPTST_ARG_TYPE_MASK ( \
170 OPTST_ARG_TYPE_1 | \
171 OPTST_ARG_TYPE_2 | \
172 OPTST_ARG_TYPE_3 | \
173 OPTST_ARG_TYPE_4 )
209
174
210#define OPTST_ARG_TYPE_SHIFT 12
211/** bits defined for opt_state_mask_t */
212/** Set via the "SET_OPT()" macro */
213#define OPTST_SET 0x0000001U
214/** Set via an RC/INI file */
215#define OPTST_PRESET 0x0000002U
216/** Set via a command line option */
217#define OPTST_DEFINED 0x0000004U
218/** Reset via command line option */
219#define OPTST_RESET 0x0000008U
220/** selected by equiv'ed option */
221#define OPTST_EQUIVALENCE 0x0000010U
222/** option is in disabled state */
223#define OPTST_DISABLED 0x0000020U
224/** pzOptArg was allocated */
225#define OPTST_ALLOC_ARG 0x0000040U
226/** option cannot be preset */
227#define OPTST_NO_INIT 0x0000100U
228/** opt value (flag) is any digit */
229#define OPTST_NUMBER_OPT 0x0000200U
230/** opt uses optionStackArg proc */
231#define OPTST_STACKED 0x0000400U
232/** option defaults to enabled */
233#define OPTST_INITENABLED 0x0000800U
234/** bit 1 of arg type enum */
235#define OPTST_ARG_TYPE_1 0x0001000U
236/** bit 2 of arg type enum */
237#define OPTST_ARG_TYPE_2 0x0002000U
238/** bit 3 of arg type enum */
239#define OPTST_ARG_TYPE_3 0x0004000U
240/** bit 4 of arg type enum */
241#define OPTST_ARG_TYPE_4 0x0008000U
242/** the option arg not required */
243#define OPTST_ARG_OPTIONAL 0x0010000U
244/** process opt on first pass */
245#define OPTST_IMM 0x0020000U
246/** process disablement immed. */
247#define OPTST_DISABLE_IMM 0x0040000U
248/** compiled out of program */
249#define OPTST_OMITTED 0x0080000U
250/** must be set or pre-set */
251#define OPTST_MUST_SET 0x0100000U
252/** opt is for doc only */
253#define OPTST_DOCUMENT 0x0200000U
254/** process opt twice - imm + reg */
255#define OPTST_TWICE 0x0400000U
256/** process disabled option twice */
257#define OPTST_DISABLE_TWICE 0x0800000U
258/** scaled integer value */
259#define OPTST_SCALED_NUM 0x1000000U
260/** disable from cmd line */
261#define OPTST_NO_COMMAND 0x2000000U
262/** support is being removed */
263#define OPTST_DEPRECATED 0x4000000U
264/** alias for other option */
265#define OPTST_ALIAS 0x8000000U
266
267/** bits in SET mask:
268 * set preset reset defined */
269#define OPTST_SET_MASK 0x000000FU
270
271/** bits in MUTABLE mask:
272 * set preset reset defined equivalence disabled
273 * alloc_arg */
274#define OPTST_MUTABLE_MASK 0x000007FU
275
276/** bits omitted from PERSISTENT mask:
277 * mutable_mask */
278#define OPTST_PERSISTENT_MASK 0xFFFFF00U
279
280/** bits in SELECTED mask:
281 * set defined */
282#define OPTST_SELECTED_MASK 0x0000005U
283
284/** bits in ARG_TYPE mask:
285 * arg_type_1 arg_type_2 arg_type_3 arg_type_4 */
286#define OPTST_ARG_TYPE_MASK 0x000F000U
287
288/** bits in NO_USAGE mask:
289 * omitted no_command deprecated */
290#define OPTST_NO_USAGE_MASK 0x6080000U
291
292/** bits in IMMUTABLE mask:
293 * document omitted */
294#define OPTST_IMMUTABLE_MASK 0x0280000U
295
296/** bits in DO_NOT_SAVE mask:
297 * document omitted no_init */
298#define OPTST_DO_NOT_SAVE_MASK 0x0280100U
299
300/** bits in NO_OUTPUT mask:
301 * document omitted alias */
302#define OPTST_NO_OUTPUT_MASK 0x8280000U
303
304/** all bits in opt_state_mask_t masks */
305#define OPTST_MASK_ALL 0xFFFFF7FU
306
307/** no bits in opt_state_mask_t */
308#define OPTST_INIT 0x0000000U
309/** @} */
310
311#ifdef NO_OPTIONAL_OPT_ARGS
312# undef OPTST_ARG_OPTIONAL
313# define OPTST_ARG_OPTIONAL 0
314#endif
315
175#ifdef NO_OPTIONAL_OPT_ARGS
176# undef OPTST_ARG_OPTIONAL
177# define OPTST_ARG_OPTIONAL 0
178#endif
179
316#define VENDOR_OPTION_VALUE 'W'
180#define OPTST_PERSISTENT_MASK (~OPTST_MUTABLE_MASK)
317
181
318#define SELECTED_OPT(_od) ((_od)->fOptState & OPTST_SELECTED_MASK)
319#define UNUSED_OPT( _od) (((_od)->fOptState & OPTST_SET_MASK) == 0)
320#define DISABLED_OPT(_od) ((_od)->fOptState & OPTST_DISABLED)
321#define OPTION_STATE(_od) ((_od)->fOptState)
322#define OPTST_SET_ARGTYPE(_n) ((_n) << OPTST_ARG_TYPE_SHIFT)
323#define OPTST_GET_ARGTYPE(_f) \
324 (((_f)&OPTST_ARG_TYPE_MASK) >> OPTST_ARG_TYPE_SHIFT)
182#define SELECTED_OPT( pod ) ((pod)->fOptState & OPTST_SELECTED_MASK)
183#define UNUSED_OPT( pod ) (((pod)->fOptState & OPTST_SET_MASK) == 0)
184#define DISABLED_OPT( pod ) ((pod)->fOptState & OPTST_DISABLED)
185#define OPTION_STATE( pod ) ((pod)->fOptState)
325
186
326/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
327 *
187#define OPTST_SET_ARGTYPE(n) ((n) << OPTST_ARG_TYPE_1_ID)
188#define OPTST_GET_ARGTYPE(f) (((f) & OPTST_ARG_TYPE_MASK)>>OPTST_ARG_TYPE_1_ID)
189
190/*
328 * PRIVATE INTERFACES
329 *
330 * The following values are used in the generated code to communicate
331 * with the option library procedures. They are not for public use
332 * and may be subject to change.
333 */
334
191 * PRIVATE INTERFACES
192 *
193 * The following values are used in the generated code to communicate
194 * with the option library procedures. They are not for public use
195 * and may be subject to change.
196 */
197
335/**
198/*
336 * Define the processing state flags
199 * Define the processing state flags
337 * @{
338 */
200 */
201typedef enum {
202 OPTPROC_LONGOPT_ID = 0, /* Process long style options */
203 OPTPROC_SHORTOPT_ID = 1, /* Process short style "flags" */
204 OPTPROC_ERRSTOP_ID = 2, /* Stop on argument errors */
205 OPTPROC_DISABLEDOPT_ID = 3, /* Current option is disabled */
206 OPTPROC_NO_REQ_OPT_ID = 4, /* no options are required */
207 OPTPROC_NUM_OPT_ID = 5, /* there is a number option */
208 OPTPROC_INITDONE_ID = 6, /* have initializations been done? */
209 OPTPROC_NEGATIONS_ID = 7, /* any negation options? */
210 OPTPROC_ENVIRON_ID = 8, /* check environment? */
211 OPTPROC_NO_ARGS_ID = 9, /* Disallow remaining arguments */
212 OPTPROC_ARGS_REQ_ID = 10, /* Require arguments after options */
213 OPTPROC_REORDER_ID = 11, /* reorder operands after options */
214 OPTPROC_GNUUSAGE_ID = 12, /* emit usage in GNU style */
215 OPTPROC_TRANSLATE_ID = 13, /* Translate strings in tOptions */
216 OPTPROC_HAS_IMMED_ID = 14, /* program defines immed options */
217 OPTPROC_PRESETTING_ID = 19 /* opt processing in preset state */
218} optproc_state_enum_t;
339
219
340/** integral type for holding proc_state masks */
341typedef uint32_t proc_state_mask_t;
220#define OPTPROC_NONE 0U
221#define OPTPROC_LONGOPT (1U << OPTPROC_LONGOPT_ID)
222#define OPTPROC_SHORTOPT (1U << OPTPROC_SHORTOPT_ID)
223#define OPTPROC_ERRSTOP (1U << OPTPROC_ERRSTOP_ID)
224#define OPTPROC_DISABLEDOPT (1U << OPTPROC_DISABLEDOPT_ID)
225#define OPTPROC_NO_REQ_OPT (1U << OPTPROC_NO_REQ_OPT_ID)
226#define OPTPROC_NUM_OPT (1U << OPTPROC_NUM_OPT_ID)
227#define OPTPROC_INITDONE (1U << OPTPROC_INITDONE_ID)
228#define OPTPROC_NEGATIONS (1U << OPTPROC_NEGATIONS_ID)
229#define OPTPROC_ENVIRON (1U << OPTPROC_ENVIRON_ID)
230#define OPTPROC_NO_ARGS (1U << OPTPROC_NO_ARGS_ID)
231#define OPTPROC_ARGS_REQ (1U << OPTPROC_ARGS_REQ_ID)
232#define OPTPROC_REORDER (1U << OPTPROC_REORDER_ID)
233#define OPTPROC_GNUUSAGE (1U << OPTPROC_GNUUSAGE_ID)
234#define OPTPROC_TRANSLATE (1U << OPTPROC_TRANSLATE_ID)
235#define OPTPROC_HAS_IMMED (1U << OPTPROC_HAS_IMMED_ID)
236#define OPTPROC_PRESETTING (1U << OPTPROC_PRESETTING_ID)
237#define OPTPROC_STATE_MASK 0x00087FFFU
342
238
343/** bits defined for proc_state_mask_t */
344/** Process long style options */
345#define OPTPROC_LONGOPT 0x000001U
346/** Process short style "flags" */
347#define OPTPROC_SHORTOPT 0x000002U
348/** Stop on argument errors */
349#define OPTPROC_ERRSTOP 0x000004U
350/** Current option is disabled */
351#define OPTPROC_DISABLEDOPT 0x000008U
352/** no options are required */
353#define OPTPROC_NO_REQ_OPT 0x000010U
354/** there is a number option */
355#define OPTPROC_NUM_OPT 0x000020U
356/** have inits been done? */
357#define OPTPROC_INITDONE 0x000040U
358/** any negation options? */
359#define OPTPROC_NEGATIONS 0x000080U
360/** check environment? */
361#define OPTPROC_ENVIRON 0x000100U
362/** Disallow remaining arguments */
363#define OPTPROC_NO_ARGS 0x000200U
364/** Require args after options */
365#define OPTPROC_ARGS_REQ 0x000400U
366/** reorder operands after opts */
367#define OPTPROC_REORDER 0x000800U
368/** emit usage in GNU style */
369#define OPTPROC_GNUUSAGE 0x001000U
370/** Translate strings in tOptions */
371#define OPTPROC_TRANSLATE 0x002000U
372/** no usage on usage error */
373#define OPTPROC_MISUSE 0x004000U
374/** immediate options active */
375#define OPTPROC_IMMEDIATE 0x008000U
376/** suppress for config only */
377#define OPTPROC_NXLAT_OPT_CFG 0x010000U
378/** suppress xlation always */
379#define OPTPROC_NXLAT_OPT 0x020000U
380/** vendor options active */
381#define OPTPROC_VENDOR_OPT 0x040000U
382/** opt processing in preset state */
383#define OPTPROC_PRESETTING 0x080000U
384/** Ignore pzFullUsage, compute usage text */
385#define OPTPROC_COMPUTE 0x100000U
386/** Program outputs digested option state for shell scripts. Usage text
387 * always written to stderr */
388#define OPTPROC_SHELL_OUTPUT 0x200000U
239#define STMTS(s) do { s; } while (0)
389
240
390/** bits in NO_XLAT mask:
391 * nxlat_opt_cfg nxlat_opt */
392#define OPTPROC_NO_XLAT_MASK 0x030000U
393
394/** all bits in proc_state_mask_t masks */
395#define OPTPROC_MASK_ALL 0x3FFFFFU
396
397/** no bits in proc_state_mask_t */
398#define OPTPROC_NONE 0x000000U
399/** @} */
400
401#define STMTS(s) do { s; } while (false)
402
403/**
404 * Abbreviation for const memory character.
241/*
242 * The following must be #defined instead of typedef-ed
243 * because "static const" cannot both be applied to a type,
244 * tho each individually can...so they all are
405 */
245 */
246#define tSCC static char const
406#define tCC char const
247#define tCC char const
248#define tAoSC static char
249#define tAoUC unsigned char
250#define tAoUI unsigned int
251#define tAoUL unsigned long
252#define tAoUS unsigned short
407
253
408/**
409 * Magical values for the program's option pointer
410 * @{
254/*
255 * It is so disgusting that there must be so many ways
256 * of specifying TRUE and FALSE.
411 */
257 */
412typedef enum {
413 OP_VAL_EMIT_USAGE = 1, ///< request for usage
414 OP_VAL_EMIT_SHELL = 2, ///< emit value for Bourne shell evaluation
415 OP_VAL_RETURN_VALNAME = 3, ///< return the value as a string
416 OP_VAL_EMIT_LIMIT = 15 ///< limit for magic values
417} opt_proc_vals_t;
258typedef enum { AG_FALSE = 0, AG_TRUE } ag_bool;
418
259
419/// \a OPT_VAL_EMIT_USAGE cast as a pointer
420#define OPTPROC_EMIT_USAGE ((tOptions *)OP_VAL_EMIT_USAGE)
421
422/// \a OPT_VAL_EMIT_SHELL cast as a pointer
423#define OPTPROC_EMIT_SHELL ((tOptions *)OP_VAL_EMIT_SHELL)
424
425/// \a OPT_VAL_RETURN_VALNAME cast as a pointer
426#define OPTPROC_RETURN_VALNAME ((tOptions *)OP_VAL_RETURN_VALNAME)
427
428/// \a OPT_VAL_EMIT_LIMIT cast as a pointer
429#define OPTPROC_EMIT_LIMIT ((tOptions *)OP_VAL_EMIT_LIMIT)
430/** @} */
431
432/** group option processing procedure types
433 * @{
260/*
261 * Define a structure that describes each option and
262 * a pointer to the procedure that handles it.
263 * The argument is the count of this flag previously seen.
434 */
264 */
435/** forward declaration for tOptDesc */
436typedef struct opt_desc tOptDesc;
437/** forward declaration for tOptiond */
438typedef struct options tOptions;
265typedef struct options tOptions;
266typedef struct optDesc tOptDesc;
267typedef struct optNames tOptNames;
439
268
440/**
269/*
441 * The option procedures do the special processing for each
442 * option flag that needs it.
443 */
270 * The option procedures do the special processing for each
271 * option flag that needs it.
272 */
444typedef void (tOptProc)(tOptions * pOpts, tOptDesc * pOptDesc);
273typedef void (tOptProc)( tOptions* pOpts, tOptDesc* pOptDesc );
274typedef tOptProc* tpOptProc;
445
275
446/**
447 * a pointer to an option processing procedure
448 */
449typedef tOptProc * tpOptProc;
450
451/**
276/*
452 * The usage procedure will never return. It calls "exit(2)"
453 * with the "exitCode" argument passed to it.
454 */
277 * The usage procedure will never return. It calls "exit(2)"
278 * with the "exitCode" argument passed to it.
279 */
455// coverity[+kill]
456typedef void (tUsageProc)(tOptions * pOpts, int exitCode);
280typedef void (tUsageProc)( tOptions* pOpts, int exitCode );
281typedef tUsageProc* tpUsageProc;
457
282
458/**
459 * a pointer to a procedure that prints usage and exits.
460 */
461typedef tUsageProc * tpUsageProc;
462/** @} */
463
464/**
283/*
465 * Special definitions. "NOLIMIT" is the 'max' value to use when
466 * a flag may appear multiple times without limit. "NO_EQUIVALENT"
467 * is an illegal value for 'optIndex' (option description index).
284 * Special definitions. "NOLIMIT" is the 'max' value to use when
285 * a flag may appear multiple times without limit. "NO_EQUIVALENT"
286 * is an illegal value for 'optIndex' (option description index).
468 * @{
469 */
287 */
470#define NOLIMIT USHRT_MAX ///< no occurrance count limit
471#define OPTION_LIMIT SHRT_MAX ///< maximum number of option types
472/// option index to indicate no equivalance or alias
288#define NOLIMIT USHRT_MAX
289#define OPTION_LIMIT SHRT_MAX
473#define NO_EQUIVALENT (OPTION_LIMIT+1)
290#define NO_EQUIVALENT (OPTION_LIMIT+1)
474/** @} */
475
291
476/**
477 * Option argument value. Which is valid is determined by:
478 * (fOptState & OPTST_ARG_TYPE_MASK) >> OPTST_ARG_TYPE_SHIFT
479 * which will yield one of the teOptArgType values.
292/*
293 * Special values for optValue. It must not be generatable from the
294 * computation "optIndex +96". Since "optIndex" is limited to 100, ...
480 */
295 */
481typedef union {
482 char const * argString; ///< as a string
483 uintptr_t argEnum; ///< as an enumeration value
484 uintptr_t argIntptr; ///< as an integer big enough to hold pointer
485 long argInt; ///< as a long integer
486 unsigned long argUint; ///< as an unsigned long ingeger
487 unsigned int argBool; ///< as a boolean value
488 FILE * argFp; ///< as a FILE * pointer
489 int argFd; ///< as a file descriptor (int)
490} opt_arg_union_t;
296#define NUMBER_OPTION '#'
491
297
492/// Compatibility define: \a pzLastArg is now \a optArg.argString
493#define pzLastArg optArg.argString
494/// The old amorphous argument bucket is now the opt_arg_union_t union.
495#define optArgBucket_t opt_arg_union_t
298typedef struct argList tArgList;
299#define MIN_ARG_ALLOC_CT 6
300#define INCR_ARG_ALLOC_CT 8
301struct argList {
302 int useCt;
303 int allocCt;
304 tCC* apzArgs[ MIN_ARG_ALLOC_CT ];
305};
496
306
497/**
498 * Enumeration of AutoOpts defined options. The enumeration is used in
499 * marking each option that is defined by AutoOpts so libopts can find
500 * the correct descriptor. This renders \a option_spec_idx_t redundant.
501 */
502typedef enum {
503 AOUSE_USER_DEFINED = 0, ///< user specified option
504 AOUSE_RESET_OPTION, ///< reset option state option
505 AOUSE_VERSION, ///< request version
506 AOUSE_HELP, ///< request usage help
507 AOUSE_MORE_HELP, ///< request paged usage
508 AOUSE_USAGE, ///< request short usage
509 AOUSE_SAVE_OPTS, ///< save option state
510 AOUSE_LOAD_OPTS, ///< load options from file
511 AOUSE_VENDOR_OPT ///< specify a vendor option
512} opt_usage_t;
307typedef union {
308 char const * argString;
309 uintptr_t argEnum;
310 uintptr_t argIntptr;
311 long argInt;
312 unsigned long argUint;
313 unsigned int argBool;
314} optArgBucket_t;
513
315
514/**
316/*
515 * Descriptor structure for each option.
516 * Only the fields marked "PUBLIC" are for public use.
517 */
317 * Descriptor structure for each option.
318 * Only the fields marked "PUBLIC" are for public use.
319 */
518struct opt_desc {
519 /// Public, the index of this descriptor
520 uint16_t const optIndex;
521 /// Public, the flag character (value)
522 uint16_t const optValue;
523 /// Public, the index of the option used to activate option
524 uint16_t optActualIndex;
525 /// Public, the flag character of the activating option
526 uint16_t optActualValue;
320struct optDesc {
321 tAoUS const optIndex; /* PUBLIC */
322 tAoUS const optValue; /* PUBLIC */
323 tAoUS optActualIndex; /* PUBLIC */
324 tAoUS optActualValue; /* PUBLIC */
527
325
528 /// Public, the index of the equivalenced-to option.
529 /// This is NO_EQUIVALENT unless activated.
530 uint16_t const optEquivIndex;
531 /// Private, the minimum occurrance count
532 uint16_t const optMinCt;
533 /// Private, the maximum occurrance count (NOLIMIT, if unlimited)
534 uint16_t const optMaxCt;
535 /// Public, the actual occurrance count
536 uint16_t optOccCt;
326 tAoUS const optEquivIndex; /* PUBLIC */
327 tAoUS const optMinCt;
328 tAoUS const optMaxCt;
329 tAoUS optOccCt; /* PUBLIC */
537
330
538 /// Public, the option processing state
539 opt_state_mask_t fOptState;
540 /// Private, how the option is used (opt_usage_t)
541 uint32_t optUsage;
542 /// Public, The current option argument value
543 opt_arg_union_t optArg;
544 /// Public, data that is actually private to the code that handles
545 /// this particular option. It is public IFF you have your own
546 /// handling function.
547 void * optCookie;
331 tAoUI fOptState; /* PUBLIC */
332 tAoUI reserved;
333 optArgBucket_t optArg; /* PUBLIC */
334# define pzLastArg optArg.argString
335 void* optCookie; /* PUBLIC */
548
336
549 /// Private, a list of options that must be specified when this option
550 /// has been specified
551 int const * const pOptMust;
337 const int * pOptMust;
338 const int * pOptCant;
339 tpOptProc pOptProc;
340 char const* pzText;
552
341
553 /// Private, a list of options that cannot be specified when this option
554 /// has been specified
555 int const * const pOptCant;
556
557 /// Private, the function to call for handling this option
558 tpOptProc const pOptProc;
559
560 /// Private, usage information about this option
561 char const * const pzText;
562
563 /// Public, the UPPER CASE, shell variable name syntax name of the option
564 char const * const pz_NAME;
565
566 /// the unmodified name of the option
567 char const * const pz_Name;
568
569 /// the option name to use to disable the option. Long options names
570 /// must be active.
571 char const * const pz_DisableName;
572
573 /// the special prefix that makes the normal option name become the
574 /// disablement name.
575 char const * const pz_DisablePfx;
342 char const* pz_NAME;
343 char const* pz_Name;
344 char const* pz_DisableName;
345 char const* pz_DisablePfx;
576};
577
346};
347
578/**
348/*
579 * Some options need special processing, so we store their
349 * Some options need special processing, so we store their
580 * indexes in a known place.
350 * indexes in a known place:
581 */
351 */
582typedef struct {
583 uint16_t const more_help; ///< passes help text through pager
584 uint16_t const save_opts; ///< stores option state to a file
585 uint16_t const number_option; ///< the option "name" is an integer
586 /// all arguments are options, this is the default option that must
587 /// take an argument. That argument is the unrecognized option.
588 uint16_t const default_opt;
589} option_spec_idx_t;
352typedef struct optSpecIndex tOptSpecIndex;
353struct optSpecIndex {
354 const tAoUS more_help;
355 const tAoUS save_opts;
356 const tAoUS number_option;
357 const tAoUS default_opt;
358};
590
359
591/**
360/*
592 * The procedure generated for translating option text
593 */
594typedef void (tOptionXlateProc)(void);
595
361 * The procedure generated for translating option text
362 */
363typedef void (tOptionXlateProc)(void);
364
596/**
597 * Everything marked "PUBLIC" is also marked "const". Public access is not
598 * a license to modify. Other fields are used and modified by the library.
599 * They are also subject to change without any notice.
600 * Do not even look at these outside of libopts.
601 */
602struct options {
365struct options {
603 int const structVersion; ///< The version of this struct
604 unsigned int origArgCt; ///< program argument count
605 char ** origArgVect; ///< program argument vector
606 proc_state_mask_t fOptSet; ///< option proc. state flags
607 unsigned int curOptIdx; ///< current option index
608 char * pzCurOpt; ///< current option text
366 int const structVersion;
367 int origArgCt;
368 char** origArgVect;
369 unsigned int fOptSet;
370 unsigned int curOptIdx;
371 char* pzCurOpt;
609
372
610 /// Public, the full path of the program
611 char const * const pzProgPath;
612 /// Public, the name of the executable, without any path
613 char const * const pzProgName;
614 /// Public, the upper-cased, shell variable syntax-ed program name
615 char const * const pzPROGNAME;
616 /// the name of the "rc file" (configuration file)
617 char const * const pzRcName;
618 /// the copyright text
619 char const * const pzCopyright;
620 /// the full copyright notice
621 char const * const pzCopyNotice;
622 /// a string with the program name, project name and version
623 char const * const pzFullVersion;
624 /// a list of pointers to directories to search for the config file
625 char const * const * const papzHomeList;
626 /// the title line for usage
627 char const * const pzUsageTitle;
628 /// some added explanation for what this program is trying to do
629 char const * const pzExplain;
630 /// a detailed explanation of the program's purpose, for use when
631 /// full help has been requested
632 char const * const pzDetail;
633 /// The public array of option descriptors
634 tOptDesc * const pOptDesc;
635 /// the email address for reporting bugs
636 char const * const pzBugAddr;
373 char const* pzProgPath;
374 char const* pzProgName;
375 char const* const pzPROGNAME;
376 char const* const pzRcName;
377 char const* const pzCopyright;
378 char const* const pzCopyNotice;
379 char const* const pzFullVersion;
380 char const* const* const papzHomeList;
381 char const* const pzUsageTitle;
382 char const* const pzExplain;
383 char const* const pzDetail;
384 tOptDesc* const pOptDesc;
385 char const* const pzBugAddr;
637
386
638 /// Reserved for future use
639 void * pExtensions;
640 /// A copy of the option state when optionSaveState was called.
641 void * pSavedState;
387 void* pExtensions;
388 void* pSavedState;
642
389
643 /// The procedure to call to print usage text
644 // coverity[+kill]
645 tpUsageProc pUsageProc;
646 /// The procedure to call to translate translatable option messages
647 tOptionXlateProc * pTransProc;
390 tpUsageProc pUsageProc;
391 tOptionXlateProc* pTransProc;
648
392
649 /// Special option indexes.
650 option_spec_idx_t specOptIdx;
651 /// the total number of options for the program
652 int const optCt;
653 /// The number of "presettable" options, though some may be marked
654 /// "no-preset". Includes all user specified options, plus a few
655 /// that are specified by AutoOpts.
656 int const presetOptCt;
657 /// user specified full usage text
658 char const * pzFullUsage;
659 /// user specifed short usage (usage error triggered) message
660 char const * pzShortUsage;
661 /// The option argument settings active when optionSaveState was called
662 opt_arg_union_t const * const originalOptArgArray;
663 /// any saved cookie value
664 void * const * const originalOptArgCookie;
665 /// the package data directory (e.g. global configuration files)
666 char const * const pzPkgDataDir;
667 /// email address of the project packager
668 char const * const pzPackager;
393 tOptSpecIndex specOptIdx;
394 int const optCt;
395 int const presetOptCt;
669};
670
671/*
396};
397
398/*
672 * Versions where in various fields first appear:
673 * ($AO_CURRENT * 4096 + $AO_REVISION, but $AO_REVISION must be zero)
674 */
675/**
676 * The version that first stored the original argument vector
677 */
678#define originalOptArgArray_STRUCT_VERSION 0x20000 /* AO_CURRENT = 32 */
679#define HAS_originalOptArgArray(_opt) \
680 ((_opt)->structVersion >= originalOptArgArray_STRUCT_VERSION)
681
682/**
683 * The version that first stored the package data directory
684 */
685#define pzPkgDataDir_STRUCT_VERSION 0x22000 /* AO_CURRENT = 34 */
686#define HAS_pzPkgDataDir(_opt) \
687 ((_opt)->structVersion >= pzPkgDataDir_STRUCT_VERSION)
688
689/**
690 * The version that first stored the option usage in each option descriptor
691 */
692#define opt_usage_t_STRUCT_VERSION 0x26000 /* AO_CURRENT = 38 */
693#define HAS_opt_usage_t(_opt) \
694 ((_opt)->structVersion >= opt_usage_t_STRUCT_VERSION)
695
696/**
697 * "token list" structure returned by "string_tokenize()"
698 */
699typedef struct {
399 * "token list" structure returned by "string_tokenize()"
400 */
401typedef struct {
700 unsigned long tkn_ct; ///< number of tokens found
701 unsigned char * tkn_list[1]; ///< array of pointers to tokens
402 unsigned long tkn_ct;
403 unsigned char* tkn_list[1];
702} token_list_t;
703
704/*
705 * Hide the interface - it pollutes a POSIX claim, but leave it for
706 * anyone #include-ing this header
707 */
708#define strneqvcmp option_strneqvcmp
709#define streqvcmp option_streqvcmp
710#define streqvmap option_streqvmap
711#define strequate option_strequate
712#define strtransform option_strtransform
713
404} token_list_t;
405
406/*
407 * Hide the interface - it pollutes a POSIX claim, but leave it for
408 * anyone #include-ing this header
409 */
410#define strneqvcmp option_strneqvcmp
411#define streqvcmp option_streqvcmp
412#define streqvmap option_streqvmap
413#define strequate option_strequate
414#define strtransform option_strtransform
415
714/**
715 * Everything needed to be known about an mmap-ed file.
716 *
416/*
717 * This is an output only structure used by text_mmap and text_munmap.
718 * Clients must not alter the contents and must provide it to both
719 * the text_mmap and text_munmap procedures. BE ADVISED: if you are
720 * mapping the file with PROT_WRITE the NUL byte at the end MIGHT NOT
721 * BE WRITABLE. In any event, that byte is not be written back
722 * to the source file. ALSO: if "txt_data" is valid and "txt_errno"
723 * is not zero, then there *may* not be a terminating NUL.
724 */
725typedef struct {
417 * This is an output only structure used by text_mmap and text_munmap.
418 * Clients must not alter the contents and must provide it to both
419 * the text_mmap and text_munmap procedures. BE ADVISED: if you are
420 * mapping the file with PROT_WRITE the NUL byte at the end MIGHT NOT
421 * BE WRITABLE. In any event, that byte is not be written back
422 * to the source file. ALSO: if "txt_data" is valid and "txt_errno"
423 * is not zero, then there *may* not be a terminating NUL.
424 */
425typedef struct {
726 void * txt_data; ///< text file data
727 size_t txt_size; ///< actual file size
728 size_t txt_full_size; ///< mmaped mem size
729 int txt_fd; ///< file descriptor
730 int txt_zero_fd; ///< fd for /dev/zero
731 int txt_errno; ///< warning code
732 int txt_prot; ///< "prot" flags
733 int txt_flags; ///< mapping type
426 void* txt_data; /* text file data */
427 size_t txt_size; /* actual file size */
428 size_t txt_full_size; /* mmaped mem size */
429 int txt_fd; /* file descriptor */
430 int txt_zero_fd; /* fd for /dev/zero */
431 int txt_errno; /* warning code */
432 int txt_prot; /* "prot" flags */
433 int txt_flags; /* mapping type */
434 int txt_alloc; /* if we malloced memory */
734} tmap_info_t;
735
435} tmap_info_t;
436
736/**
737 * mmap result wrapper that yields "true" when mmap has failed.
738 */
739#define TEXT_MMAP_FAILED_ADDR(a) (VOIDP(a) == VOIDP(MAP_FAILED))
437#define TEXT_MMAP_FAILED_ADDR(a) ((void*)(a) == (void*)MAP_FAILED)
740
741#ifdef __cplusplus
438
439#ifdef __cplusplus
742#define CPLUSPLUS_OPENER extern "C" {
743CPLUSPLUS_OPENER
440extern "C" {
744#define CPLUSPLUS_CLOSER }
745#else
746#define CPLUSPLUS_CLOSER
747#endif
748
441#define CPLUSPLUS_CLOSER }
442#else
443#define CPLUSPLUS_CLOSER
444#endif
445
749/**
446/*
750 * The following routines may be coded into AutoOpts client code:
751 */
752
447 * The following routines may be coded into AutoOpts client code:
448 */
449
753/**
450/* From: tokenize.c line 115
451 *
754 * ao_string_tokenize - tokenize an input string
755 *
452 * ao_string_tokenize - tokenize an input string
453 *
454 * Arguments:
455 * string string to be tokenized
456 *
457 * Returns: token_list_t* - pointer to a structure that lists each token
458 *
756 * This function will convert one input string into a list of strings.
757 * The list of strings is derived by separating the input based on
758 * white space separation. However, if the input contains either single
759 * or double quote characters, then the text after that character up to
760 * a matching quote will become the string in the list.
459 * This function will convert one input string into a list of strings.
460 * The list of strings is derived by separating the input based on
461 * white space separation. However, if the input contains either single
462 * or double quote characters, then the text after that character up to
463 * a matching quote will become the string in the list.
761 *
464 *
762 * The returned pointer should be deallocated with @code{free(3C)} when
763 * are done using the data. The data are placed in a single block of
764 * allocated memory. Do not deallocate individual token/strings.
465 * The returned pointer should be deallocated with @code{free(3C)} when
466 * are done using the data. The data are placed in a single block of
467 * allocated memory. Do not deallocate individual token/strings.
765 *
468 *
766 * The structure pointed to will contain at least these two fields:
767 * @table @samp
768 * @item tkn_ct
769 * The number of tokens found in the input string.
770 * @item tok_list
771 * An array of @code{tkn_ct + 1} pointers to substring tokens, with
772 * the last pointer set to NULL.
773 * @end table
469 * The structure pointed to will contain at least these two fields:
470 * @table @samp
471 * @item tkn_ct
472 * The number of tokens found in the input string.
473 * @item tok_list
474 * An array of @code{tkn_ct + 1} pointers to substring tokens, with
475 * the last pointer set to NULL.
476 * @end table
774 *
477 *
775 * There are two types of quoted strings: single quoted (@code{'}) and
776 * double quoted (@code{"}). Singly quoted strings are fairly raw in that
777 * escape characters (@code{\\}) are simply another character, except when
778 * preceding the following characters:
779 * @example
780 * @code{\\} double backslashes reduce to one
781 * @code{'} incorporates the single quote into the string
782 * @code{\n} suppresses both the backslash and newline character
783 * @end example
478 * There are two types of quoted strings: single quoted (@code{'}) and
479 * double quoted (@code{"}). Singly quoted strings are fairly raw in that
480 * escape characters (@code{\\}) are simply another character, except when
481 * preceding the following characters:
482 * @example
483 * @code{\\} double backslashes reduce to one
484 * @code{'} incorporates the single quote into the string
485 * @code{\n} suppresses both the backslash and newline character
486 * @end example
784 *
487 *
785 * Double quote strings are formed according to the rules of string
786 * constants in ANSI-C programs.
488 * Double quote strings are formed according to the rules of string
489 * constants in ANSI-C programs.
787 *
788 * @param string string to be tokenized
789 *
790 * @return token_list_t * - pointer to a structure that lists each token
791 */
490 */
792extern token_list_t * ao_string_tokenize(char const *);
491extern token_list_t* ao_string_tokenize( char const* );
793
794
492
493
795/**
494/* From: configfile.c line 113
495 *
796 * configFileLoad - parse a configuration file
797 *
496 * configFileLoad - parse a configuration file
497 *
498 * Arguments:
499 * pzFile the file to load
500 *
501 * Returns: const tOptionValue* - An allocated, compound value structure
502 *
798 * This routine will load a named configuration file and parse the
799 * text as a hierarchically valued option. The option descriptor
800 * created from an option definition file is not used via this interface.
801 * The returned value is "named" with the input file name and is of
802 * type "@code{OPARG_TYPE_HIERARCHY}". It may be used in calls to
803 * @code{optionGetValue()}, @code{optionNextValue()} and
804 * @code{optionUnloadNested()}.
503 * This routine will load a named configuration file and parse the
504 * text as a hierarchically valued option. The option descriptor
505 * created from an option definition file is not used via this interface.
506 * The returned value is "named" with the input file name and is of
507 * type "@code{OPARG_TYPE_HIERARCHY}". It may be used in calls to
508 * @code{optionGetValue()}, @code{optionNextValue()} and
509 * @code{optionUnloadNested()}.
805 *
806 * @param fname the file to load
807 *
808 * @return const tOptionValue * - An allocated, compound value structure
809 */
510 */
810extern const tOptionValue * configFileLoad(char const *);
511extern const tOptionValue* configFileLoad( char const* );
811
812
512
513
813/**
514/* From: configfile.c line 883
515 *
814 * optionFileLoad - Load the locatable config files, in order
815 *
516 * optionFileLoad - Load the locatable config files, in order
517 *
518 * Arguments:
519 * pOpts program options descriptor
520 * pzProg program name
521 *
522 * Returns: int - 0 -> SUCCESS, -1 -> FAILURE
523 *
816 * This function looks in all the specified directories for a configuration
817 * file ("rc" file or "ini" file) and processes any found twice. The first
818 * time through, they are processed in reverse order (last file first). At
819 * that time, only "immediate action" configurables are processed. For
820 * example, if the last named file specifies not processing any more
821 * configuration files, then no more configuration files will be processed.
822 * Such an option in the @strong{first} named directory will have no effect.
524 * This function looks in all the specified directories for a configuration
525 * file ("rc" file or "ini" file) and processes any found twice. The first
526 * time through, they are processed in reverse order (last file first). At
527 * that time, only "immediate action" configurables are processed. For
528 * example, if the last named file specifies not processing any more
529 * configuration files, then no more configuration files will be processed.
530 * Such an option in the @strong{first} named directory will have no effect.
823 *
531 *
824 * Once the immediate action configurables have been handled, then the
825 * directories are handled in normal, forward order. In that way, later
826 * config files can override the settings of earlier config files.
532 * Once the immediate action configurables have been handled, then the
533 * directories are handled in normal, forward order. In that way, later
534 * config files can override the settings of earlier config files.
827 *
535 *
828 * See the AutoOpts documentation for a thorough discussion of the
829 * config file format.
536 * See the AutoOpts documentation for a thorough discussion of the
537 * config file format.
830 *
538 *
831 * Configuration files not found or not decipherable are simply ignored.
539 * Configuration files not found or not decipherable are simply ignored.
832 *
833 * @param opts program options descriptor
834 * @param prog program name
835 *
836 * @return int - 0 -> SUCCESS, -1 -> FAILURE
837 */
540 */
838extern int optionFileLoad(tOptions *, char const *);
541extern int optionFileLoad( tOptions*, char const* );
839
840
542
543
841/**
544/* From: configfile.c line 245
545 *
842 * optionFindNextValue - find a hierarcicaly valued option instance
843 *
546 * optionFindNextValue - find a hierarcicaly valued option instance
547 *
548 * Arguments:
549 * pOptDesc an option with a nested arg type
550 * pPrevVal the last entry
551 * name name of value to find
552 * value the matching value
553 *
554 * Returns: const tOptionValue* - a compound value structure
555 *
844 * This routine will find the next entry in a nested value option or
845 * configurable. It will search through the list and return the next entry
846 * that matches the criteria.
556 * This routine will find the next entry in a nested value option or
557 * configurable. It will search through the list and return the next entry
558 * that matches the criteria.
847 *
848 * @param odesc an option with a nested arg type
849 * @param pPrevVal the last entry
850 * @param name name of value to find
851 * @param value the matching value
852 *
853 * @return const tOptionValue * - a compound value structure
854 */
559 */
855extern const tOptionValue * optionFindNextValue(const tOptDesc *, const tOptionValue *, char const *, char const *);
560extern const tOptionValue* optionFindNextValue( const tOptDesc*, const tOptionValue*, char const*, char const* );
856
857
561
562
858/**
563/* From: configfile.c line 171
564 *
859 * optionFindValue - find a hierarcicaly valued option instance
860 *
565 * optionFindValue - find a hierarcicaly valued option instance
566 *
861 * This routine will find an entry in a nested value option or configurable.
862 * It will search through the list and return a matching entry.
567 * Arguments:
568 * pOptDesc an option with a nested arg type
569 * name name of value to find
570 * value the matching value
863 *
571 *
864 * @param odesc an option with a nested arg type
865 * @param name name of value to find
866 * @param val the matching value
572 * Returns: const tOptionValue* - a compound value structure
867 *
573 *
868 * @return const tOptionValue * - a compound value structure
574 * This routine will find an entry in a nested value option or configurable.
575 * It will search through the list and return a matching entry.
869 */
576 */
870extern const tOptionValue * optionFindValue(const tOptDesc *, char const *, char const *);
577extern const tOptionValue* optionFindValue( const tOptDesc*, char const*, char const* );
871
872
578
579
873/**
580/* From: restore.c line 188
581 *
874 * optionFree - free allocated option processing memory
875 *
582 * optionFree - free allocated option processing memory
583 *
584 * Arguments:
585 * pOpts program options descriptor
586 *
876 * AutoOpts sometimes allocates memory and puts pointers to it in the
877 * option state structures. This routine deallocates all such memory.
587 * AutoOpts sometimes allocates memory and puts pointers to it in the
588 * option state structures. This routine deallocates all such memory.
878 *
879 * @param pOpts program options descriptor
880 */
589 */
881extern void optionFree(tOptions *);
590extern void optionFree( tOptions* );
882
883
591
592
884/**
593/* From: configfile.c line 314
594 *
885 * optionGetValue - get a specific value from a hierarcical list
886 *
595 * optionGetValue - get a specific value from a hierarcical list
596 *
597 * Arguments:
598 * pOptValue a hierarchcal value
599 * valueName name of value to get
600 *
601 * Returns: const tOptionValue* - a compound value structure
602 *
887 * This routine will find an entry in a nested value option or configurable.
888 * If "valueName" is NULL, then the first entry is returned. Otherwise,
889 * the first entry with a name that exactly matches the argument will be
603 * This routine will find an entry in a nested value option or configurable.
604 * If "valueName" is NULL, then the first entry is returned. Otherwise,
605 * the first entry with a name that exactly matches the argument will be
890 * returned. If there is no matching value, NULL is returned and errno is
891 * set to ENOENT. If the provided option value is not a hierarchical value,
892 * NULL is also returned and errno is set to EINVAL.
893 *
894 * @param pOptValue a hierarchcal value
895 * @param valueName name of value to get
896 *
897 * @return const tOptionValue * - a compound value structure
606 * returned.
898 */
607 */
899extern const tOptionValue * optionGetValue(const tOptionValue *, char const *);
608extern const tOptionValue* optionGetValue( const tOptionValue*, char const* );
900
901
609
610
902/**
611/* From: load.c line 521
612 *
903 * optionLoadLine - process a string for an option name and value
904 *
613 * optionLoadLine - process a string for an option name and value
614 *
615 * Arguments:
616 * pOpts program options descriptor
617 * pzLine NUL-terminated text
618 *
905 * This is a client program callable routine for setting options from, for
906 * example, the contents of a file that they read in. Only one option may
907 * appear in the text. It will be treated as a normal (non-preset) option.
619 * This is a client program callable routine for setting options from, for
620 * example, the contents of a file that they read in. Only one option may
621 * appear in the text. It will be treated as a normal (non-preset) option.
908 *
622 *
909 * When passed a pointer to the option struct and a string, it will find
910 * the option named by the first token on the string and set the option
911 * argument to the remainder of the string. The caller must NUL terminate
623 * When passed a pointer to the option struct and a string, it will find
624 * the option named by the first token on the string and set the option
625 * argument to the remainder of the string. The caller must NUL terminate
912 * the string. The caller need not skip over any introductory hyphens.
913 * Any embedded new lines will be included in the option
626 * the string. Any embedded new lines will be included in the option
914 * argument. If the input looks like one or more quoted strings, then the
915 * input will be "cooked". The "cooking" is identical to the string
916 * formation used in AutoGen definition files (@pxref{basic expression}),
917 * except that you may not use backquotes.
627 * argument. If the input looks like one or more quoted strings, then the
628 * input will be "cooked". The "cooking" is identical to the string
629 * formation used in AutoGen definition files (@pxref{basic expression}),
630 * except that you may not use backquotes.
918 *
919 * @param opts program options descriptor
920 * @param line NUL-terminated text
921 */
631 */
922extern void optionLoadLine(tOptions *, char const *);
632extern void optionLoadLine( tOptions*, char const* );
923
924
633
634
925/**
926 * optionMemberList - Get the list of members of a bit mask set
635/* From: configfile.c line 373
927 *
636 *
928 * This converts the OPT_VALUE_name mask value to a allocated string.
929 * It is the caller's responsibility to free the string.
637 * optionNextValue - get the next value from a hierarchical list
930 *
638 *
931 * @param od the set membership option description
639 * Arguments:
640 * pOptValue a hierarchcal list value
641 * pOldValue a value from this list
932 *
642 *
933 * @return char * - the names of the set bits
934 */
935extern char * optionMemberList(tOptDesc *);
936
937
938/**
939 * optionNextValue - get the next value from a hierarchical list
643 * Returns: const tOptionValue* - a compound value structure
940 *
941 * This routine will return the next entry after the entry passed in. At the
942 * end of the list, NULL will be returned. If the entry is not found on the
943 * list, NULL will be returned and "@var{errno}" will be set to EINVAL.
944 * The "@var{pOldValue}" must have been gotten from a prior call to this
945 * routine or to "@code{opitonGetValue()}".
644 *
645 * This routine will return the next entry after the entry passed in. At the
646 * end of the list, NULL will be returned. If the entry is not found on the
647 * list, NULL will be returned and "@var{errno}" will be set to EINVAL.
648 * The "@var{pOldValue}" must have been gotten from a prior call to this
649 * routine or to "@code{opitonGetValue()}".
946 *
947 * @param pOptValue a hierarchcal list value
948 * @param pOldValue a value from this list
949 *
950 * @return const tOptionValue * - a compound value structure
951 */
650 */
952extern const tOptionValue * optionNextValue(const tOptionValue *, const tOptionValue *);
651extern const tOptionValue* optionNextValue( const tOptionValue*, const tOptionValue* );
953
954
652
653
955/**
654/* From: usage.c line 128
655 *
956 * optionOnlyUsage - Print usage text for just the options
957 *
656 * optionOnlyUsage - Print usage text for just the options
657 *
658 * Arguments:
659 * pOpts program options descriptor
660 * ex_code exit code for calling exit(3)
661 *
958 * This routine will print only the usage for each option.
959 * This function may be used when the emitted usage must incorporate
960 * information not available to AutoOpts.
662 * This routine will print only the usage for each option.
663 * This function may be used when the emitted usage must incorporate
664 * information not available to AutoOpts.
961 *
962 * @param pOpts program options descriptor
963 * @param ex_code exit code for calling exit(3)
964 */
665 */
965extern void optionOnlyUsage(tOptions *, int);
666extern void optionOnlyUsage( tOptions*, int );
966
967
667
668
968/**
969 * optionPrintVersion - Print the program version
669/* From: autoopts.c line 1012
970 *
670 *
971 * This routine will print the version to stdout.
671 * optionProcess - this is the main option processing routine
972 *
672 *
973 * @param opts program options descriptor
974 * @param od the descriptor for this arg
975 */
976extern void optionPrintVersion(tOptions *, tOptDesc *);
977
978
979/**
980 * optionPrintVersionAndReturn - Print the program version
673 * Arguments:
674 * pOpts program options descriptor
675 * argc program arg count
676 * argv program arg vector
981 *
677 *
982 * This routine will print the version to stdout and return
983 * instead of exiting. Please see the source for the
984 * @code{print_ver} funtion for details on selecting how
985 * verbose to be after this function returns.
678 * Returns: int - the count of the arguments processed
986 *
679 *
987 * @param opts program options descriptor
988 * @param od the descriptor for this arg
989 */
990extern void optionPrintVersionAndReturn(tOptions *, tOptDesc *);
991
992
993/**
994 * optionProcess - this is the main option processing routine
995 *
996 * This is the main entry point for processing options. It is intended
997 * that this procedure be called once at the beginning of the execution of
998 * a program. Depending on options selected earlier, it is sometimes
999 * necessary to stop and restart option processing, or to select completely
1000 * different sets of options. This can be done easily, but you generally
1001 * do not want to do this.
680 * This is the main entry point for processing options. It is intended
681 * that this procedure be called once at the beginning of the execution of
682 * a program. Depending on options selected earlier, it is sometimes
683 * necessary to stop and restart option processing, or to select completely
684 * different sets of options. This can be done easily, but you generally
685 * do not want to do this.
1002 *
686 *
1003 * The number of arguments processed always includes the program name.
1004 * If one of the arguments is "--", then it is counted and the processing
1005 * stops. If an error was encountered and errors are to be tolerated, then
1006 * the returned value is the index of the argument causing the error.
1007 * A hyphen by itself ("-") will also cause processing to stop and will
1008 * @emph{not} be counted among the processed arguments. A hyphen by itself
1009 * is treated as an operand. Encountering an operand stops option
1010 * processing.
687 * The number of arguments processed always includes the program name.
688 * If one of the arguments is "--", then it is counted and the processing
689 * stops. If an error was encountered and errors are to be tolerated, then
690 * the returned value is the index of the argument causing the error.
691 * A hyphen by itself ("-") will also cause processing to stop and will
692 * @emph{not} be counted among the processed arguments. A hyphen by itself
693 * is treated as an operand. Encountering an operand stops option
694 * processing.
1011 *
1012 * @param opts program options descriptor
1013 * @param a_ct program arg count
1014 * @param a_v program arg vector
1015 *
1016 * @return int - the count of the arguments processed
1017 */
695 */
1018extern int optionProcess(tOptions *, int, char **);
696extern int optionProcess( tOptions*, int, char** );
1019
1020
697
698
1021/**
699/* From: restore.c line 145
700 *
1022 * optionRestore - restore option state from memory copy
1023 *
701 * optionRestore - restore option state from memory copy
702 *
703 * Arguments:
704 * pOpts program options descriptor
705 *
1024 * Copy back the option state from saved memory.
1025 * The allocated memory is left intact, so this routine can be
1026 * called repeatedly without having to call optionSaveState again.
1027 * If you are restoring a state that was saved before the first call
1028 * to optionProcess(3AO), then you may change the contents of the
1029 * argc/argv parameters to optionProcess.
706 * Copy back the option state from saved memory.
707 * The allocated memory is left intact, so this routine can be
708 * called repeatedly without having to call optionSaveState again.
709 * If you are restoring a state that was saved before the first call
710 * to optionProcess(3AO), then you may change the contents of the
711 * argc/argv parameters to optionProcess.
1030 *
1031 * @param pOpts program options descriptor
1032 */
712 */
1033extern void optionRestore(tOptions *);
713extern void optionRestore( tOptions* );
1034
1035
714
715
1036/**
716/* From: save.c line 334
717 *
1037 * optionSaveFile - saves the option state to a file
1038 *
718 * optionSaveFile - saves the option state to a file
719 *
720 * Arguments:
721 * pOpts program options descriptor
722 *
1039 * This routine will save the state of option processing to a file. The name
1040 * of that file can be specified with the argument to the @code{--save-opts}
1041 * option, or by appending the @code{rcfile} attribute to the last
1042 * @code{homerc} attribute. If no @code{rcfile} attribute was specified, it
1043 * will default to @code{.@i{programname}rc}. If you wish to specify another
723 * This routine will save the state of option processing to a file. The name
724 * of that file can be specified with the argument to the @code{--save-opts}
725 * option, or by appending the @code{rcfile} attribute to the last
726 * @code{homerc} attribute. If no @code{rcfile} attribute was specified, it
727 * will default to @code{.@i{programname}rc}. If you wish to specify another
1044 * file, you should invoke the @code{SET_OPT_SAVE_OPTS(@i{filename})} macro.
1045 *
1046 * The recommend usage is as follows:
1047 * @example
1048 * optionProcess(&progOptions, argc, argv);
1049 * if (i_want_a_non_standard_place_for_this)
1050 * SET_OPT_SAVE_OPTS("myfilename");
1051 * optionSaveFile(&progOptions);
1052 * @end example
1053 *
1054 * @param opts program options descriptor
728 * file, you should invoke the @code{SET_OPT_SAVE_OPTS( @i{filename} )} macro.
1055 */
729 */
1056extern void optionSaveFile(tOptions *);
730extern void optionSaveFile( tOptions* );
1057
1058
731
732
1059/**
733/* From: restore.c line 93
734 *
1060 * optionSaveState - saves the option state to memory
1061 *
735 * optionSaveState - saves the option state to memory
736 *
737 * Arguments:
738 * pOpts program options descriptor
739 *
1062 * This routine will allocate enough memory to save the current option
1063 * processing state. If this routine has been called before, that memory
1064 * will be reused. You may only save one copy of the option state. This
1065 * routine may be called before optionProcess(3AO). If you do call it
1066 * before the first call to optionProcess, then you may also change the
1067 * contents of argc/argv after you call optionRestore(3AO)
740 * This routine will allocate enough memory to save the current option
741 * processing state. If this routine has been called before, that memory
742 * will be reused. You may only save one copy of the option state. This
743 * routine may be called before optionProcess(3AO). If you do call it
744 * before the first call to optionProcess, then you may also change the
745 * contents of argc/argv after you call optionRestore(3AO)
1068 *
746 *
1069 * In fact, more strongly put: it is safest to only use this function
1070 * before having processed any options. In particular, the saving and
1071 * restoring of stacked string arguments and hierarchical values is
1072 * disabled. The values are not saved.
747 * In fact, more strongly put: it is safest to only use this function
748 * before having processed any options. In particular, the saving and
749 * restoring of stacked string arguments and hierarchical values is
750 * disabled. The values are not saved.
1073 *
1074 * @param pOpts program options descriptor
1075 */
751 */
1076extern void optionSaveState(tOptions *);
752extern void optionSaveState( tOptions* );
1077
1078
753
754
1079/**
755/* From: nested.c line 559
756 *
1080 * optionUnloadNested - Deallocate the memory for a nested value
1081 *
757 * optionUnloadNested - Deallocate the memory for a nested value
758 *
759 * Arguments:
760 * pOptVal the hierarchical value
761 *
1082 * A nested value needs to be deallocated. The pointer passed in should
1083 * have been gotten from a call to @code{configFileLoad()} (See
1084 * @pxref{libopts-configFileLoad}).
762 * A nested value needs to be deallocated. The pointer passed in should
763 * have been gotten from a call to @code{configFileLoad()} (See
764 * @pxref{libopts-configFileLoad}).
1085 *
1086 * @param pOptVal the hierarchical value
1087 */
765 */
1088extern void optionUnloadNested(tOptionValue const *);
766extern void optionUnloadNested( tOptionValue const * );
1089
1090
767
768
1091/**
769/* From: version.c line 58
770 *
1092 * optionVersion - return the compiled AutoOpts version number
1093 *
771 * optionVersion - return the compiled AutoOpts version number
772 *
773 * Returns: char const* - the version string in constant memory
774 *
1094 * Returns the full version string compiled into the library.
1095 * The returned string cannot be modified.
775 * Returns the full version string compiled into the library.
776 * The returned string cannot be modified.
777 */
778extern char const* optionVersion( void );
779
780
781/* From: ../compat/pathfind.c line 34
1096 *
782 *
1097 * @return char const * - the version string in constant memory
783 * pathfind - fild a file in a list of directories
784 *
785 * Arguments:
786 * path colon separated list of search directories
787 * file the name of the file to look for
788 * mode the mode bits that must be set to match
789 *
790 * Returns: char* - the path to the located file
791 *
792 * the pathfind function is available only if HAVE_PATHFIND is not defined
793 *
794 * pathfind looks for a a file with name "FILE" and "MODE" access
795 * along colon delimited "PATH", and returns the full pathname as a
796 * string, or NULL if not found. If "FILE" contains a slash, then
797 * it is treated as a relative or absolute path and "PATH" is ignored.
798 *
799 * @strong{NOTE}: this function is compiled into @file{libopts} only if
800 * it is not natively supplied.
801 *
802 * The "MODE" argument is a string of option letters chosen from the
803 * list below:
804 * @example
805 * Letter Meaning
806 * r readable
807 * w writable
808 * x executable
809 * f normal file (NOT IMPLEMENTED)
810 * b block special (NOT IMPLEMENTED)
811 * c character special (NOT IMPLEMENTED)
812 * d directory (NOT IMPLEMENTED)
813 * p FIFO (pipe) (NOT IMPLEMENTED)
814 * u set user ID bit (NOT IMPLEMENTED)
815 * g set group ID bit (NOT IMPLEMENTED)
816 * k sticky bit (NOT IMPLEMENTED)
817 * s size nonzero (NOT IMPLEMENTED)
818 * @end example
1098 */
819 */
1099extern char const * optionVersion(void);
820#ifndef HAVE_PATHFIND
821extern char* pathfind( char const*, char const*, char const* );
822#endif /* HAVE_PATHFIND */
1100
1101
823
824
1102/**
825/* From: streqvcmp.c line 233
826 *
1103 * strequate - map a list of characters to the same value
1104 *
827 * strequate - map a list of characters to the same value
828 *
829 * Arguments:
830 * ch_list characters to equivalence
831 *
1105 * Each character in the input string get mapped to the first character
1106 * in the string.
1107 * This function name is mapped to option_strequate so as to not conflict
1108 * with the POSIX name space.
832 * Each character in the input string get mapped to the first character
833 * in the string.
834 * This function name is mapped to option_strequate so as to not conflict
835 * with the POSIX name space.
1109 *
1110 * @param ch_list characters to equivalence
1111 */
836 */
1112extern void strequate(char const *);
837extern void strequate( char const* );
1113
1114
838
839
1115/**
840/* From: streqvcmp.c line 143
841 *
1116 * streqvcmp - compare two strings with an equivalence mapping
1117 *
842 * streqvcmp - compare two strings with an equivalence mapping
843 *
844 * Arguments:
845 * str1 first string
846 * str2 second string
847 *
848 * Returns: int - the difference between two differing characters
849 *
1118 * Using a character mapping, two strings are compared for "equivalence".
1119 * Each input character is mapped to a comparison character and the
1120 * mapped-to characters are compared for the two NUL terminated input strings.
1121 * This function name is mapped to option_streqvcmp so as to not conflict
1122 * with the POSIX name space.
850 * Using a character mapping, two strings are compared for "equivalence".
851 * Each input character is mapped to a comparison character and the
852 * mapped-to characters are compared for the two NUL terminated input strings.
853 * This function name is mapped to option_streqvcmp so as to not conflict
854 * with the POSIX name space.
1123 *
1124 * @param str1 first string
1125 * @param str2 second string
1126 *
1127 * @return int - the difference between two differing characters
1128 */
855 */
1129extern int streqvcmp(char const *, char const *);
856extern int streqvcmp( char const*, char const* );
1130
1131
857
858
1132/**
859/* From: streqvcmp.c line 180
860 *
1133 * streqvmap - Set the character mappings for the streqv functions
1134 *
861 * streqvmap - Set the character mappings for the streqv functions
862 *
863 * Arguments:
864 * From Input character
865 * To Mapped-to character
866 * ct compare length
867 *
1135 * Set the character mapping. If the count (@code{ct}) is set to zero, then
1136 * the map is cleared by setting all entries in the map to their index
1137 * value. Otherwise, the "@code{From}" character is mapped to the "@code{To}"
1138 * character. If @code{ct} is greater than 1, then @code{From} and @code{To}
1139 * are incremented and the process repeated until @code{ct} entries have been
1140 * set. For example,
1141 * @example
868 * Set the character mapping. If the count (@code{ct}) is set to zero, then
869 * the map is cleared by setting all entries in the map to their index
870 * value. Otherwise, the "@code{From}" character is mapped to the "@code{To}"
871 * character. If @code{ct} is greater than 1, then @code{From} and @code{To}
872 * are incremented and the process repeated until @code{ct} entries have been
873 * set. For example,
874 * @example
1142 * streqvmap('a', 'A', 26);
875 * streqvmap( 'a', 'A', 26 );
1143 * @end example
1144 * @noindent
1145 * will alter the mapping so that all English lower case letters
1146 * will map to upper case.
876 * @end example
877 * @noindent
878 * will alter the mapping so that all English lower case letters
879 * will map to upper case.
1147 *
880 *
1148 * This function name is mapped to option_streqvmap so as to not conflict
1149 * with the POSIX name space.
881 * This function name is mapped to option_streqvmap so as to not conflict
882 * with the POSIX name space.
1150 *
1151 * @param from Input character
1152 * @param to Mapped-to character
1153 * @param ct compare length
1154 */
883 */
1155extern void streqvmap(char, char, int);
884extern void streqvmap( char, char, int );
1156
1157
885
886
1158/**
887/* From: streqvcmp.c line 102
888 *
1159 * strneqvcmp - compare two strings with an equivalence mapping
1160 *
889 * strneqvcmp - compare two strings with an equivalence mapping
890 *
891 * Arguments:
892 * str1 first string
893 * str2 second string
894 * ct compare length
895 *
896 * Returns: int - the difference between two differing characters
897 *
1161 * Using a character mapping, two strings are compared for "equivalence".
1162 * Each input character is mapped to a comparison character and the
1163 * mapped-to characters are compared for the two NUL terminated input strings.
1164 * The comparison is limited to @code{ct} bytes.
1165 * This function name is mapped to option_strneqvcmp so as to not conflict
1166 * with the POSIX name space.
898 * Using a character mapping, two strings are compared for "equivalence".
899 * Each input character is mapped to a comparison character and the
900 * mapped-to characters are compared for the two NUL terminated input strings.
901 * The comparison is limited to @code{ct} bytes.
902 * This function name is mapped to option_strneqvcmp so as to not conflict
903 * with the POSIX name space.
1167 *
1168 * @param str1 first string
1169 * @param str2 second string
1170 * @param ct compare length
1171 *
1172 * @return int - the difference between two differing characters
1173 */
904 */
1174extern int strneqvcmp(char const *, char const *, int);
905extern int strneqvcmp( char const*, char const*, int );
1175
1176
906
907
1177/**
908/* From: streqvcmp.c line 259
909 *
1178 * strtransform - convert a string into its mapped-to value
1179 *
910 * strtransform - convert a string into its mapped-to value
911 *
912 * Arguments:
913 * dest output string
914 * src input string
915 *
1180 * Each character in the input string is mapped and the mapped-to
1181 * character is put into the output.
1182 * This function name is mapped to option_strtransform so as to not conflict
1183 * with the POSIX name space.
916 * Each character in the input string is mapped and the mapped-to
917 * character is put into the output.
918 * This function name is mapped to option_strtransform so as to not conflict
919 * with the POSIX name space.
1184 *
1185 * The source and destination may be the same.
1186 *
1187 * @param dest output string
1188 * @param src input string
1189 */
920 */
1190extern void strtransform(char *, char const *);
921extern void strtransform( char*, char const* );
1191
1192/* AutoOpts PRIVATE FUNCTIONS: */
1193tOptProc optionStackArg, optionUnstackArg, optionBooleanVal, optionNumericVal;
1194
922
923/* AutoOpts PRIVATE FUNCTIONS: */
924tOptProc optionStackArg, optionUnstackArg, optionBooleanVal, optionNumericVal;
925
1195extern char * ao_string_cook(char *, int *);
926extern char* ao_string_cook( char*, int* );
1196
927
1197extern unsigned int ao_string_cook_escape_char(char const *, char *, unsigned int);
928extern unsigned int ao_string_cook_escape_char( char const*, char*, unsigned int );
1198
929
1199extern void genshelloptUsage(tOptions *, int);
930extern void export_options_to_guile( tOptions* );
1200
931
1201extern int optionAlias(tOptions *, tOptDesc *, unsigned int);
932extern void genshelloptUsage( tOptions*, int );
1202
933
1203extern void optionBooleanVal(tOptions *, tOptDesc *);
934extern void optionBooleanVal( tOptions*, tOptDesc* );
1204
935
1205extern uintptr_t optionEnumerationVal(tOptions *, tOptDesc *, char const * const *, unsigned int);
936extern uintptr_t optionEnumerationVal( tOptions*, tOptDesc*, char const * const *, unsigned int );
1206
937
1207extern void optionFileCheck(tOptions *, tOptDesc *, teOptFileType, tuFileMode);
938extern char const* optionKeywordName( tOptDesc*, unsigned int );
1208
939
1209extern char const * optionKeywordName(tOptDesc *, unsigned int);
940extern void optionLoadOpt( tOptions*, tOptDesc* );
1210
941
1211extern void optionLoadOpt(tOptions *, tOptDesc *);
942extern ag_bool optionMakePath( char*, int, char const*, char const* );
1212
943
1213extern bool optionMakePath(char *, int, char const *, char const *);
944extern void optionNestedVal( tOptions*, tOptDesc* );
1214
945
1215extern void optionNestedVal(tOptions *, tOptDesc *);
946extern void optionNumericVal( tOptions*, tOptDesc* );
1216
947
1217extern void optionNumericVal(tOptions *, tOptDesc *);
948extern void optionPagedUsage( tOptions*, tOptDesc* );
1218
949
1219extern void optionPagedUsage(tOptions *, tOptDesc *);
950extern void optionParseShell( tOptions* );
1220
951
1221extern void optionParseShell(tOptions *);
952extern void optionPrintVersion( tOptions*, tOptDesc* );
1222
953
1223extern void optionPrintParagraphs(char const *, bool, FILE *);
954extern void optionPutShell( tOptions* );
1224
955
1225extern void optionPutShell(tOptions *);
956extern void optionSetMembers( tOptions*, tOptDesc*, char const * const *, unsigned int );
1226
957
1227extern char const * optionQuoteString(char const *, char const *);
958extern void optionStackArg( tOptions*, tOptDesc* );
1228
959
1229extern void optionResetOpt(tOptions *, tOptDesc *);
960extern void optionUnstackArg( tOptions*, tOptDesc* );
1230
961
1231extern void optionSetMembers(tOptions *, tOptDesc *, char const * const *, unsigned int);
962extern void optionUsage( tOptions*, int );
1232
963
1233extern void optionShowRange(tOptions *, tOptDesc *, void *, int);
964extern void optionVersionStderr( tOptions*, tOptDesc* );
1234
965
1235extern void optionStackArg(tOptions *, tOptDesc *);
966extern void* text_mmap( char const*, int, int, tmap_info_t* );
1236
967
1237extern void optionTimeDate(tOptions *, tOptDesc *);
968extern int text_munmap( tmap_info_t* );
1238
969
1239extern void optionTimeVal(tOptions *, tOptDesc *);
1240
1241extern void optionUnstackArg(tOptions *, tOptDesc *);
1242
1243extern void optionUsage(tOptions *, int);
1244
1245extern void optionVendorOption(tOptions *, tOptDesc *);
1246
1247extern void optionVersionStderr(tOptions *, tOptDesc *);
1248
1249extern void * text_mmap(char const *, int, int, tmap_info_t *);
1250
1251extern int text_munmap(tmap_info_t *);
1252
1253CPLUSPLUS_CLOSER
1254#endif /* AUTOOPTS_OPTIONS_H_GUARD */
970CPLUSPLUS_CLOSER
971#endif /* AUTOOPTS_OPTIONS_H_GUARD */
1255/** @}
1256 *
972/*
1257 * Local Variables:
1258 * c-file-style: "stroustrup"
1259 * indent-tabs-mode: nil
1260 * End:
1261 * options.h ends here */
973 * Local Variables:
974 * c-file-style: "stroustrup"
975 * indent-tabs-mode: nil
976 * End:
977 * options.h ends here */