1
0

options.h 43 KB

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