options.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977
  1. /* -*- buffer-read-only: t -*- vi: set ro:
  2. *
  3. * DO NOT EDIT THIS FILE (options.h)
  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. *
  12. * Automated Options copyright 1992-Y Bruce Korb
  13. *
  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.
  29. */
  30. #ifndef AUTOOPTS_OPTIONS_H_GUARD
  31. #define AUTOOPTS_OPTIONS_H_GUARD
  32. #include <sys/types.h>
  33. #if defined(HAVE_STDINT_H)
  34. # include <stdint.h>
  35. #elif defined(HAVE_INTTYPES_H)
  36. # include <inttypes.h>
  37. #endif /* HAVE_STDINT/INTTYPES_H */
  38. #if defined(HAVE_LIMITS_H)
  39. # include <limits.h>
  40. #elif defined(HAVE_SYS_LIMITS_H)
  41. # include <sys/limits.h>
  42. #endif /* HAVE_LIMITS/SYS_LIMITS_H */
  43. #if defined(HAVE_SYSEXITS_H)
  44. # include <sysexits.h>
  45. #endif /* HAVE_SYSEXITS_H */
  46. #ifndef EX_USAGE
  47. # define EX_USAGE 64
  48. #endif
  49. /*
  50. * PUBLIC DEFINES
  51. *
  52. * The following defines may be used in applications that need to test the
  53. * state of an option. To test against these masks and values, a pointer
  54. * to an option descriptor must be obtained. There are two ways:
  55. *
  56. * 1. inside an option processing procedure, it is the second argument,
  57. * conventionally "tOptDesc* pOD".
  58. *
  59. * 2. Outside of an option procedure (or to reference a different option
  60. * descriptor), use either "&DESC( opt_name )" or "&pfx_DESC( opt_name )".
  61. *
  62. * See the relevant generated header file to determine which and what
  63. * values for "opt_name" are available.
  64. */
  65. #define OPTIONS_STRUCT_VERSION 118784
  66. #define OPTIONS_VERSION_STRING "29:0:4"
  67. #define OPTIONS_MINIMUM_VERSION 102400
  68. #define OPTIONS_MIN_VER_STRING "25:0:0"
  69. typedef enum {
  70. OPARG_TYPE_NONE = 0,
  71. OPARG_TYPE_STRING = 1, /* default type/ vanilla string */
  72. OPARG_TYPE_ENUMERATION = 2, /* opt arg is an enum (keyword list) */
  73. OPARG_TYPE_BOOLEAN = 3, /* opt arg is boolean-valued */
  74. OPARG_TYPE_MEMBERSHIP = 4, /* opt arg sets set membership bits */
  75. OPARG_TYPE_NUMERIC = 5, /* opt arg has numeric value */
  76. OPARG_TYPE_HIERARCHY = 6 /* option arg is hierarchical value */
  77. } teOptArgType;
  78. typedef struct optionValue {
  79. teOptArgType valType;
  80. char* pzName;
  81. union {
  82. char strVal[1]; /* OPARG_TYPE_STRING */
  83. unsigned int enumVal; /* OPARG_TYPE_ENUMERATION */
  84. unsigned int boolVal; /* OPARG_TYPE_BOOLEAN */
  85. unsigned long setVal; /* OPARG_TYPE_MEMBERSHIP */
  86. long longVal; /* OPARG_TYPE_NUMERIC */
  87. void* nestVal; /* OPARG_TYPE_HIERARCHY */
  88. } v;
  89. } tOptionValue;
  90. /*
  91. * Bits in the fOptState option descriptor field.
  92. */
  93. typedef enum {
  94. OPTST_SET_ID = 0, /* Set via the "SET_OPT()" macro */
  95. OPTST_PRESET_ID = 1, /* Set via an RC/INI file */
  96. OPTST_DEFINED_ID = 2, /* Set via a command line option */
  97. OPTST_EQUIVALENCE_ID = 4, /* selected by equiv'ed option */
  98. OPTST_DISABLED_ID = 5, /* option is in disabled state */
  99. OPTST_ALLOC_ARG_ID = 6, /* pzOptArg was allocated */
  100. OPTST_NO_INIT_ID = 8, /* option cannot be preset */
  101. OPTST_NUMBER_OPT_ID = 9, /* opt value (flag) is any digit */
  102. OPTST_STACKED_ID = 10, /* opt uses optionStackArg proc */
  103. OPTST_INITENABLED_ID = 11, /* option defaults to enabled */
  104. OPTST_ARG_TYPE_1_ID = 12, /* bit 1 of arg type enum */
  105. OPTST_ARG_TYPE_2_ID = 13, /* bit 2 of arg type enum */
  106. OPTST_ARG_TYPE_3_ID = 14, /* bit 3 of arg type enum */
  107. OPTST_ARG_TYPE_4_ID = 15, /* bit 4 of arg type enum */
  108. OPTST_ARG_OPTIONAL_ID = 16, /* the option arg not required */
  109. OPTST_IMM_ID = 17, /* process opt on first pass */
  110. OPTST_DISABLE_IMM_ID = 18, /* process disablement immed. */
  111. OPTST_OMITTED_ID = 19, /* compiled out of program */
  112. OPTST_MUST_SET_ID = 20, /* must be set or pre-set */
  113. OPTST_DOCUMENT_ID = 21, /* opt is for doc only */
  114. OPTST_TWICE_ID = 22, /* process opt twice - imm + reg */
  115. OPTST_DISABLE_TWICE_ID = 23 /* process disabled option twice */
  116. } opt_state_enum_t;
  117. #define OPTST_INIT 0U
  118. #define OPTST_SET (1U << OPTST_SET_ID)
  119. #define OPTST_PRESET (1U << OPTST_PRESET_ID)
  120. #define OPTST_DEFINED (1U << OPTST_DEFINED_ID)
  121. #define OPTST_EQUIVALENCE (1U << OPTST_EQUIVALENCE_ID)
  122. #define OPTST_DISABLED (1U << OPTST_DISABLED_ID)
  123. #define OPTST_ALLOC_ARG (1U << OPTST_ALLOC_ARG_ID)
  124. #define OPTST_NO_INIT (1U << OPTST_NO_INIT_ID)
  125. #define OPTST_NUMBER_OPT (1U << OPTST_NUMBER_OPT_ID)
  126. #define OPTST_STACKED (1U << OPTST_STACKED_ID)
  127. #define OPTST_INITENABLED (1U << OPTST_INITENABLED_ID)
  128. #define OPTST_ARG_TYPE_1 (1U << OPTST_ARG_TYPE_1_ID)
  129. #define OPTST_ARG_TYPE_2 (1U << OPTST_ARG_TYPE_2_ID)
  130. #define OPTST_ARG_TYPE_3 (1U << OPTST_ARG_TYPE_3_ID)
  131. #define OPTST_ARG_TYPE_4 (1U << OPTST_ARG_TYPE_4_ID)
  132. #define OPTST_ARG_OPTIONAL (1U << OPTST_ARG_OPTIONAL_ID)
  133. #define OPTST_IMM (1U << OPTST_IMM_ID)
  134. #define OPTST_DISABLE_IMM (1U << OPTST_DISABLE_IMM_ID)
  135. #define OPTST_OMITTED (1U << OPTST_OMITTED_ID)
  136. #define OPTST_MUST_SET (1U << OPTST_MUST_SET_ID)
  137. #define OPTST_DOCUMENT (1U << OPTST_DOCUMENT_ID)
  138. #define OPTST_TWICE (1U << OPTST_TWICE_ID)
  139. #define OPTST_DISABLE_TWICE (1U << OPTST_DISABLE_TWICE_ID)
  140. #define OPT_STATE_MASK 0x00FFFF77U
  141. #define OPTST_SET_MASK ( \
  142. OPTST_SET | \
  143. OPTST_PRESET | \
  144. OPTST_DEFINED )
  145. #define OPTST_MUTABLE_MASK ( \
  146. OPTST_SET | \
  147. OPTST_PRESET | \
  148. OPTST_DEFINED | \
  149. OPTST_EQUIVALENCE | \
  150. OPTST_DISABLED | \
  151. OPTST_ALLOC_ARG )
  152. #define OPTST_SELECTED_MASK ( \
  153. OPTST_SET | \
  154. OPTST_DEFINED )
  155. #define OPTST_ARG_TYPE_MASK ( \
  156. OPTST_ARG_TYPE_1 | \
  157. OPTST_ARG_TYPE_2 | \
  158. OPTST_ARG_TYPE_3 | \
  159. OPTST_ARG_TYPE_4 )
  160. #ifdef NO_OPTIONAL_OPT_ARGS
  161. # undef OPTST_ARG_OPTIONAL
  162. # define OPTST_ARG_OPTIONAL 0
  163. #endif
  164. #define OPTST_PERSISTENT_MASK (~OPTST_MUTABLE_MASK)
  165. #define SELECTED_OPT( pod ) ((pod)->fOptState & OPTST_SELECTED_MASK)
  166. #define UNUSED_OPT( pod ) (((pod)->fOptState & OPTST_SET_MASK) == 0)
  167. #define DISABLED_OPT( pod ) ((pod)->fOptState & OPTST_DISABLED)
  168. #define OPTION_STATE( pod ) ((pod)->fOptState)
  169. #define OPTST_SET_ARGTYPE(n) ((n) << OPTST_ARG_TYPE_1_ID)
  170. #define OPTST_GET_ARGTYPE(f) (((f) & OPTST_ARG_TYPE_MASK)>>OPTST_ARG_TYPE_1_ID)
  171. /*
  172. * PRIVATE INTERFACES
  173. *
  174. * The following values are used in the generated code to communicate
  175. * with the option library procedures. They are not for public use
  176. * and may be subject to change.
  177. */
  178. /*
  179. * Define the processing state flags
  180. */
  181. typedef enum {
  182. OPTPROC_LONGOPT_ID = 0, /* Process long style options */
  183. OPTPROC_SHORTOPT_ID = 1, /* Process short style "flags" */
  184. OPTPROC_ERRSTOP_ID = 2, /* Stop on argument errors */
  185. OPTPROC_DISABLEDOPT_ID = 3, /* Current option is disabled */
  186. OPTPROC_NO_REQ_OPT_ID = 4, /* no options are required */
  187. OPTPROC_NUM_OPT_ID = 5, /* there is a number option */
  188. OPTPROC_INITDONE_ID = 6, /* have initializations been done? */
  189. OPTPROC_NEGATIONS_ID = 7, /* any negation options? */
  190. OPTPROC_ENVIRON_ID = 8, /* check environment? */
  191. OPTPROC_NO_ARGS_ID = 9, /* Disallow remaining arguments */
  192. OPTPROC_ARGS_REQ_ID = 10, /* Require arguments after options */
  193. OPTPROC_REORDER_ID = 11, /* reorder operands after options */
  194. OPTPROC_GNUUSAGE_ID = 12, /* emit usage in GNU style */
  195. OPTPROC_TRANSLATE_ID = 13, /* Translate strings in tOptions */
  196. OPTPROC_HAS_IMMED_ID = 14, /* program defines immed options */
  197. OPTPROC_PRESETTING_ID = 19 /* opt processing in preset state */
  198. } optproc_state_enum_t;
  199. #define OPTPROC_NONE 0U
  200. #define OPTPROC_LONGOPT (1U << OPTPROC_LONGOPT_ID)
  201. #define OPTPROC_SHORTOPT (1U << OPTPROC_SHORTOPT_ID)
  202. #define OPTPROC_ERRSTOP (1U << OPTPROC_ERRSTOP_ID)
  203. #define OPTPROC_DISABLEDOPT (1U << OPTPROC_DISABLEDOPT_ID)
  204. #define OPTPROC_NO_REQ_OPT (1U << OPTPROC_NO_REQ_OPT_ID)
  205. #define OPTPROC_NUM_OPT (1U << OPTPROC_NUM_OPT_ID)
  206. #define OPTPROC_INITDONE (1U << OPTPROC_INITDONE_ID)
  207. #define OPTPROC_NEGATIONS (1U << OPTPROC_NEGATIONS_ID)
  208. #define OPTPROC_ENVIRON (1U << OPTPROC_ENVIRON_ID)
  209. #define OPTPROC_NO_ARGS (1U << OPTPROC_NO_ARGS_ID)
  210. #define OPTPROC_ARGS_REQ (1U << OPTPROC_ARGS_REQ_ID)
  211. #define OPTPROC_REORDER (1U << OPTPROC_REORDER_ID)
  212. #define OPTPROC_GNUUSAGE (1U << OPTPROC_GNUUSAGE_ID)
  213. #define OPTPROC_TRANSLATE (1U << OPTPROC_TRANSLATE_ID)
  214. #define OPTPROC_HAS_IMMED (1U << OPTPROC_HAS_IMMED_ID)
  215. #define OPTPROC_PRESETTING (1U << OPTPROC_PRESETTING_ID)
  216. #define OPTPROC_STATE_MASK 0x00087FFFU
  217. #define STMTS(s) do { s; } while (0)
  218. /*
  219. * The following must be #defined instead of typedef-ed
  220. * because "static const" cannot both be applied to a type,
  221. * tho each individually can...so they all are
  222. */
  223. #define tSCC static char const
  224. #define tCC char const
  225. #define tAoSC static char
  226. #define tAoUC unsigned char
  227. #define tAoUI unsigned int
  228. #define tAoUL unsigned long
  229. #define tAoUS unsigned short
  230. /*
  231. * It is so disgusting that there must be so many ways
  232. * of specifying TRUE and FALSE.
  233. */
  234. typedef enum { AG_FALSE = 0, AG_TRUE } ag_bool;
  235. /*
  236. * Define a structure that describes each option and
  237. * a pointer to the procedure that handles it.
  238. * The argument is the count of this flag previously seen.
  239. */
  240. typedef struct options tOptions;
  241. typedef struct optDesc tOptDesc;
  242. typedef struct optNames tOptNames;
  243. /*
  244. * The option procedures do the special processing for each
  245. * option flag that needs it.
  246. */
  247. typedef void (tOptProc)( tOptions* pOpts, tOptDesc* pOptDesc );
  248. typedef tOptProc* tpOptProc;
  249. /*
  250. * The usage procedure will never return. It calls "exit(2)"
  251. * with the "exitCode" argument passed to it.
  252. */
  253. typedef void (tUsageProc)( tOptions* pOpts, int exitCode );
  254. typedef tUsageProc* tpUsageProc;
  255. /*
  256. * Special definitions. "NOLIMIT" is the 'max' value to use when
  257. * a flag may appear multiple times without limit. "NO_EQUIVALENT"
  258. * is an illegal value for 'optIndex' (option description index).
  259. */
  260. #define NOLIMIT USHRT_MAX
  261. #define OPTION_LIMIT SHRT_MAX
  262. #define NO_EQUIVALENT (OPTION_LIMIT+1)
  263. /*
  264. * Special values for optValue. It must not be generatable from the
  265. * computation "optIndex +96". Since "optIndex" is limited to 100, ...
  266. */
  267. #define NUMBER_OPTION '#'
  268. typedef struct argList tArgList;
  269. #define MIN_ARG_ALLOC_CT 6
  270. #define INCR_ARG_ALLOC_CT 8
  271. struct argList {
  272. int useCt;
  273. int allocCt;
  274. tCC* apzArgs[ MIN_ARG_ALLOC_CT ];
  275. };
  276. typedef union {
  277. char const * argString;
  278. uintptr_t argEnum;
  279. uintptr_t argIntptr;
  280. long argInt;
  281. unsigned long argUint;
  282. unsigned int argBool;
  283. } optArgBucket_t;
  284. /*
  285. * Descriptor structure for each option.
  286. * Only the fields marked "PUBLIC" are for public use.
  287. */
  288. struct optDesc {
  289. tAoUS const optIndex; /* PUBLIC */
  290. tAoUS const optValue; /* PUBLIC */
  291. tAoUS optActualIndex; /* PUBLIC */
  292. tAoUS optActualValue; /* PUBLIC */
  293. tAoUS const optEquivIndex; /* PUBLIC */
  294. tAoUS const optMinCt;
  295. tAoUS const optMaxCt;
  296. tAoUS optOccCt; /* PUBLIC */
  297. tAoUI fOptState; /* PUBLIC */
  298. tAoUI reserved;
  299. optArgBucket_t optArg; /* PUBLIC */
  300. # define pzLastArg optArg.argString
  301. void* optCookie; /* PUBLIC */
  302. const int * pOptMust;
  303. const int * pOptCant;
  304. tpOptProc pOptProc;
  305. char const* pzText;
  306. char const* pz_NAME;
  307. char const* pz_Name;
  308. char const* pz_DisableName;
  309. char const* pz_DisablePfx;
  310. };
  311. /*
  312. * Some options need special processing, so we store their
  313. * indexes in a known place:
  314. */
  315. typedef struct optSpecIndex tOptSpecIndex;
  316. struct optSpecIndex {
  317. const tAoUS more_help;
  318. const tAoUS save_opts;
  319. const tAoUS number_option;
  320. const tAoUS default_opt;
  321. };
  322. /*
  323. * The procedure generated for translating option text
  324. */
  325. typedef void (tOptionXlateProc)(void);
  326. struct options {
  327. int const structVersion;
  328. int origArgCt;
  329. char** origArgVect;
  330. unsigned int fOptSet;
  331. unsigned int curOptIdx;
  332. char* pzCurOpt;
  333. char const* pzProgPath;
  334. char const* pzProgName;
  335. char const* const pzPROGNAME;
  336. char const* const pzRcName;
  337. char const* const pzCopyright;
  338. char const* const pzCopyNotice;
  339. char const* const pzFullVersion;
  340. char const* const* const papzHomeList;
  341. char const* const pzUsageTitle;
  342. char const* const pzExplain;
  343. char const* const pzDetail;
  344. tOptDesc* const pOptDesc;
  345. char const* const pzBugAddr;
  346. void* pExtensions;
  347. void* pSavedState;
  348. tpUsageProc pUsageProc;
  349. tOptionXlateProc* pTransProc;
  350. tOptSpecIndex specOptIdx;
  351. int const optCt;
  352. int const presetOptCt;
  353. };
  354. /*
  355. * "token list" structure returned by "string_tokenize()"
  356. */
  357. typedef struct {
  358. unsigned long tkn_ct;
  359. unsigned char* tkn_list[1];
  360. } token_list_t;
  361. /*
  362. * Hide the interface - it pollutes a POSIX claim, but leave it for
  363. * anyone #include-ing this header
  364. */
  365. #define strneqvcmp option_strneqvcmp
  366. #define streqvcmp option_streqvcmp
  367. #define streqvmap option_streqvmap
  368. #define strequate option_strequate
  369. #define strtransform option_strtransform
  370. /*
  371. * This is an output only structure used by text_mmap and text_munmap.
  372. * Clients must not alter the contents and must provide it to both
  373. * the text_mmap and text_munmap procedures. BE ADVISED: if you are
  374. * mapping the file with PROT_WRITE the NUL byte at the end MIGHT NOT
  375. * BE WRITABLE. In any event, that byte is not be written back
  376. * to the source file. ALSO: if "txt_data" is valid and "txt_errno"
  377. * is not zero, then there *may* not be a terminating NUL.
  378. */
  379. typedef struct {
  380. void* txt_data; /* text file data */
  381. size_t txt_size; /* actual file size */
  382. size_t txt_full_size; /* mmaped mem size */
  383. int txt_fd; /* file descriptor */
  384. int txt_zero_fd; /* fd for /dev/zero */
  385. int txt_errno; /* warning code */
  386. int txt_prot; /* "prot" flags */
  387. int txt_flags; /* mapping type */
  388. int txt_alloc; /* if we malloced memory */
  389. } tmap_info_t;
  390. #define TEXT_MMAP_FAILED_ADDR(a) ((void*)(a) == (void*)MAP_FAILED)
  391. #ifdef __cplusplus
  392. extern "C" {
  393. #define CPLUSPLUS_CLOSER }
  394. #else
  395. #define CPLUSPLUS_CLOSER
  396. #endif
  397. /*
  398. * The following routines may be coded into AutoOpts client code:
  399. */
  400. /* From: tokenize.c line 115
  401. *
  402. * ao_string_tokenize - tokenize an input string
  403. *
  404. * Arguments:
  405. * string string to be tokenized
  406. *
  407. * Returns: token_list_t* - pointer to a structure that lists each token
  408. *
  409. * This function will convert one input string into a list of strings.
  410. * The list of strings is derived by separating the input based on
  411. * white space separation. However, if the input contains either single
  412. * or double quote characters, then the text after that character up to
  413. * a matching quote will become the string in the list.
  414. *
  415. * The returned pointer should be deallocated with @code{free(3C)} when
  416. * are done using the data. The data are placed in a single block of
  417. * allocated memory. Do not deallocate individual token/strings.
  418. *
  419. * The structure pointed to will contain at least these two fields:
  420. * @table @samp
  421. * @item tkn_ct
  422. * The number of tokens found in the input string.
  423. * @item tok_list
  424. * An array of @code{tkn_ct + 1} pointers to substring tokens, with
  425. * the last pointer set to NULL.
  426. * @end table
  427. *
  428. * There are two types of quoted strings: single quoted (@code{'}) and
  429. * double quoted (@code{"}). Singly quoted strings are fairly raw in that
  430. * escape characters (@code{\\}) are simply another character, except when
  431. * preceding the following characters:
  432. * @example
  433. * @code{\\} double backslashes reduce to one
  434. * @code{'} incorporates the single quote into the string
  435. * @code{\n} suppresses both the backslash and newline character
  436. * @end example
  437. *
  438. * Double quote strings are formed according to the rules of string
  439. * constants in ANSI-C programs.
  440. */
  441. extern token_list_t* ao_string_tokenize( char const* );
  442. /* From: configfile.c line 113
  443. *
  444. * configFileLoad - parse a configuration file
  445. *
  446. * Arguments:
  447. * pzFile the file to load
  448. *
  449. * Returns: const tOptionValue* - An allocated, compound value structure
  450. *
  451. * This routine will load a named configuration file and parse the
  452. * text as a hierarchically valued option. The option descriptor
  453. * created from an option definition file is not used via this interface.
  454. * The returned value is "named" with the input file name and is of
  455. * type "@code{OPARG_TYPE_HIERARCHY}". It may be used in calls to
  456. * @code{optionGetValue()}, @code{optionNextValue()} and
  457. * @code{optionUnloadNested()}.
  458. */
  459. extern const tOptionValue* configFileLoad( char const* );
  460. /* From: configfile.c line 883
  461. *
  462. * optionFileLoad - Load the locatable config files, in order
  463. *
  464. * Arguments:
  465. * pOpts program options descriptor
  466. * pzProg program name
  467. *
  468. * Returns: int - 0 -> SUCCESS, -1 -> FAILURE
  469. *
  470. * This function looks in all the specified directories for a configuration
  471. * file ("rc" file or "ini" file) and processes any found twice. The first
  472. * time through, they are processed in reverse order (last file first). At
  473. * that time, only "immediate action" configurables are processed. For
  474. * example, if the last named file specifies not processing any more
  475. * configuration files, then no more configuration files will be processed.
  476. * Such an option in the @strong{first} named directory will have no effect.
  477. *
  478. * Once the immediate action configurables have been handled, then the
  479. * directories are handled in normal, forward order. In that way, later
  480. * config files can override the settings of earlier config files.
  481. *
  482. * See the AutoOpts documentation for a thorough discussion of the
  483. * config file format.
  484. *
  485. * Configuration files not found or not decipherable are simply ignored.
  486. */
  487. extern int optionFileLoad( tOptions*, char const* );
  488. /* From: configfile.c line 245
  489. *
  490. * optionFindNextValue - find a hierarcicaly valued option instance
  491. *
  492. * Arguments:
  493. * pOptDesc an option with a nested arg type
  494. * pPrevVal the last entry
  495. * name name of value to find
  496. * value the matching value
  497. *
  498. * Returns: const tOptionValue* - a compound value structure
  499. *
  500. * This routine will find the next entry in a nested value option or
  501. * configurable. It will search through the list and return the next entry
  502. * that matches the criteria.
  503. */
  504. extern const tOptionValue* optionFindNextValue( const tOptDesc*, const tOptionValue*, char const*, char const* );
  505. /* From: configfile.c line 171
  506. *
  507. * optionFindValue - find a hierarcicaly valued option instance
  508. *
  509. * Arguments:
  510. * pOptDesc an option with a nested arg type
  511. * name name of value to find
  512. * value the matching value
  513. *
  514. * Returns: const tOptionValue* - a compound value structure
  515. *
  516. * This routine will find an entry in a nested value option or configurable.
  517. * It will search through the list and return a matching entry.
  518. */
  519. extern const tOptionValue* optionFindValue( const tOptDesc*, char const*, char const* );
  520. /* From: restore.c line 188
  521. *
  522. * optionFree - free allocated option processing memory
  523. *
  524. * Arguments:
  525. * pOpts program options descriptor
  526. *
  527. * AutoOpts sometimes allocates memory and puts pointers to it in the
  528. * option state structures. This routine deallocates all such memory.
  529. */
  530. extern void optionFree( tOptions* );
  531. /* From: configfile.c line 314
  532. *
  533. * optionGetValue - get a specific value from a hierarcical list
  534. *
  535. * Arguments:
  536. * pOptValue a hierarchcal value
  537. * valueName name of value to get
  538. *
  539. * Returns: const tOptionValue* - a compound value structure
  540. *
  541. * This routine will find an entry in a nested value option or configurable.
  542. * If "valueName" is NULL, then the first entry is returned. Otherwise,
  543. * the first entry with a name that exactly matches the argument will be
  544. * returned.
  545. */
  546. extern const tOptionValue* optionGetValue( const tOptionValue*, char const* );
  547. /* From: load.c line 521
  548. *
  549. * optionLoadLine - process a string for an option name and value
  550. *
  551. * Arguments:
  552. * pOpts program options descriptor
  553. * pzLine NUL-terminated text
  554. *
  555. * This is a client program callable routine for setting options from, for
  556. * example, the contents of a file that they read in. Only one option may
  557. * appear in the text. It will be treated as a normal (non-preset) option.
  558. *
  559. * When passed a pointer to the option struct and a string, it will find
  560. * the option named by the first token on the string and set the option
  561. * argument to the remainder of the string. The caller must NUL terminate
  562. * the string. Any embedded new lines will be included in the option
  563. * argument. If the input looks like one or more quoted strings, then the
  564. * input will be "cooked". The "cooking" is identical to the string
  565. * formation used in AutoGen definition files (@pxref{basic expression}),
  566. * except that you may not use backquotes.
  567. */
  568. extern void optionLoadLine( tOptions*, char const* );
  569. /* From: configfile.c line 373
  570. *
  571. * optionNextValue - get the next value from a hierarchical list
  572. *
  573. * Arguments:
  574. * pOptValue a hierarchcal list value
  575. * pOldValue a value from this list
  576. *
  577. * Returns: const tOptionValue* - a compound value structure
  578. *
  579. * This routine will return the next entry after the entry passed in. At the
  580. * end of the list, NULL will be returned. If the entry is not found on the
  581. * list, NULL will be returned and "@var{errno}" will be set to EINVAL.
  582. * The "@var{pOldValue}" must have been gotten from a prior call to this
  583. * routine or to "@code{opitonGetValue()}".
  584. */
  585. extern const tOptionValue* optionNextValue( const tOptionValue*, const tOptionValue* );
  586. /* From: usage.c line 128
  587. *
  588. * optionOnlyUsage - Print usage text for just the options
  589. *
  590. * Arguments:
  591. * pOpts program options descriptor
  592. * ex_code exit code for calling exit(3)
  593. *
  594. * This routine will print only the usage for each option.
  595. * This function may be used when the emitted usage must incorporate
  596. * information not available to AutoOpts.
  597. */
  598. extern void optionOnlyUsage( tOptions*, int );
  599. /* From: autoopts.c line 1012
  600. *
  601. * optionProcess - this is the main option processing routine
  602. *
  603. * Arguments:
  604. * pOpts program options descriptor
  605. * argc program arg count
  606. * argv program arg vector
  607. *
  608. * Returns: int - the count of the arguments processed
  609. *
  610. * This is the main entry point for processing options. It is intended
  611. * that this procedure be called once at the beginning of the execution of
  612. * a program. Depending on options selected earlier, it is sometimes
  613. * necessary to stop and restart option processing, or to select completely
  614. * different sets of options. This can be done easily, but you generally
  615. * do not want to do this.
  616. *
  617. * The number of arguments processed always includes the program name.
  618. * If one of the arguments is "--", then it is counted and the processing
  619. * stops. If an error was encountered and errors are to be tolerated, then
  620. * the returned value is the index of the argument causing the error.
  621. * A hyphen by itself ("-") will also cause processing to stop and will
  622. * @emph{not} be counted among the processed arguments. A hyphen by itself
  623. * is treated as an operand. Encountering an operand stops option
  624. * processing.
  625. */
  626. extern int optionProcess( tOptions*, int, char** );
  627. /* From: restore.c line 145
  628. *
  629. * optionRestore - restore option state from memory copy
  630. *
  631. * Arguments:
  632. * pOpts program options descriptor
  633. *
  634. * Copy back the option state from saved memory.
  635. * The allocated memory is left intact, so this routine can be
  636. * called repeatedly without having to call optionSaveState again.
  637. * If you are restoring a state that was saved before the first call
  638. * to optionProcess(3AO), then you may change the contents of the
  639. * argc/argv parameters to optionProcess.
  640. */
  641. extern void optionRestore( tOptions* );
  642. /* From: save.c line 334
  643. *
  644. * optionSaveFile - saves the option state to a file
  645. *
  646. * Arguments:
  647. * pOpts program options descriptor
  648. *
  649. * This routine will save the state of option processing to a file. The name
  650. * of that file can be specified with the argument to the @code{--save-opts}
  651. * option, or by appending the @code{rcfile} attribute to the last
  652. * @code{homerc} attribute. If no @code{rcfile} attribute was specified, it
  653. * will default to @code{.@i{programname}rc}. If you wish to specify another
  654. * file, you should invoke the @code{SET_OPT_SAVE_OPTS( @i{filename} )} macro.
  655. */
  656. extern void optionSaveFile( tOptions* );
  657. /* From: restore.c line 93
  658. *
  659. * optionSaveState - saves the option state to memory
  660. *
  661. * Arguments:
  662. * pOpts program options descriptor
  663. *
  664. * This routine will allocate enough memory to save the current option
  665. * processing state. If this routine has been called before, that memory
  666. * will be reused. You may only save one copy of the option state. This
  667. * routine may be called before optionProcess(3AO). If you do call it
  668. * before the first call to optionProcess, then you may also change the
  669. * contents of argc/argv after you call optionRestore(3AO)
  670. *
  671. * In fact, more strongly put: it is safest to only use this function
  672. * before having processed any options. In particular, the saving and
  673. * restoring of stacked string arguments and hierarchical values is
  674. * disabled. The values are not saved.
  675. */
  676. extern void optionSaveState( tOptions* );
  677. /* From: nested.c line 559
  678. *
  679. * optionUnloadNested - Deallocate the memory for a nested value
  680. *
  681. * Arguments:
  682. * pOptVal the hierarchical value
  683. *
  684. * A nested value needs to be deallocated. The pointer passed in should
  685. * have been gotten from a call to @code{configFileLoad()} (See
  686. * @pxref{libopts-configFileLoad}).
  687. */
  688. extern void optionUnloadNested( tOptionValue const * );
  689. /* From: version.c line 58
  690. *
  691. * optionVersion - return the compiled AutoOpts version number
  692. *
  693. * Returns: char const* - the version string in constant memory
  694. *
  695. * Returns the full version string compiled into the library.
  696. * The returned string cannot be modified.
  697. */
  698. extern char const* optionVersion( void );
  699. /* From: ../compat/pathfind.c line 34
  700. *
  701. * pathfind - fild a file in a list of directories
  702. *
  703. * Arguments:
  704. * path colon separated list of search directories
  705. * file the name of the file to look for
  706. * mode the mode bits that must be set to match
  707. *
  708. * Returns: char* - the path to the located file
  709. *
  710. * the pathfind function is available only if HAVE_PATHFIND is not defined
  711. *
  712. * pathfind looks for a a file with name "FILE" and "MODE" access
  713. * along colon delimited "PATH", and returns the full pathname as a
  714. * string, or NULL if not found. If "FILE" contains a slash, then
  715. * it is treated as a relative or absolute path and "PATH" is ignored.
  716. *
  717. * @strong{NOTE}: this function is compiled into @file{libopts} only if
  718. * it is not natively supplied.
  719. *
  720. * The "MODE" argument is a string of option letters chosen from the
  721. * list below:
  722. * @example
  723. * Letter Meaning
  724. * r readable
  725. * w writable
  726. * x executable
  727. * f normal file (NOT IMPLEMENTED)
  728. * b block special (NOT IMPLEMENTED)
  729. * c character special (NOT IMPLEMENTED)
  730. * d directory (NOT IMPLEMENTED)
  731. * p FIFO (pipe) (NOT IMPLEMENTED)
  732. * u set user ID bit (NOT IMPLEMENTED)
  733. * g set group ID bit (NOT IMPLEMENTED)
  734. * k sticky bit (NOT IMPLEMENTED)
  735. * s size nonzero (NOT IMPLEMENTED)
  736. * @end example
  737. */
  738. #ifndef HAVE_PATHFIND
  739. extern char* pathfind( char const*, char const*, char const* );
  740. #endif /* HAVE_PATHFIND */
  741. /* From: streqvcmp.c line 233
  742. *
  743. * strequate - map a list of characters to the same value
  744. *
  745. * Arguments:
  746. * ch_list characters to equivalence
  747. *
  748. * Each character in the input string get mapped to the first character
  749. * in the string.
  750. * This function name is mapped to option_strequate so as to not conflict
  751. * with the POSIX name space.
  752. */
  753. extern void strequate( char const* );
  754. /* From: streqvcmp.c line 143
  755. *
  756. * streqvcmp - compare two strings with an equivalence mapping
  757. *
  758. * Arguments:
  759. * str1 first string
  760. * str2 second string
  761. *
  762. * Returns: int - the difference between two differing characters
  763. *
  764. * Using a character mapping, two strings are compared for "equivalence".
  765. * Each input character is mapped to a comparison character and the
  766. * mapped-to characters are compared for the two NUL terminated input strings.
  767. * This function name is mapped to option_streqvcmp so as to not conflict
  768. * with the POSIX name space.
  769. */
  770. extern int streqvcmp( char const*, char const* );
  771. /* From: streqvcmp.c line 180
  772. *
  773. * streqvmap - Set the character mappings for the streqv functions
  774. *
  775. * Arguments:
  776. * From Input character
  777. * To Mapped-to character
  778. * ct compare length
  779. *
  780. * Set the character mapping. If the count (@code{ct}) is set to zero, then
  781. * the map is cleared by setting all entries in the map to their index
  782. * value. Otherwise, the "@code{From}" character is mapped to the "@code{To}"
  783. * character. If @code{ct} is greater than 1, then @code{From} and @code{To}
  784. * are incremented and the process repeated until @code{ct} entries have been
  785. * set. For example,
  786. * @example
  787. * streqvmap( 'a', 'A', 26 );
  788. * @end example
  789. * @noindent
  790. * will alter the mapping so that all English lower case letters
  791. * will map to upper case.
  792. *
  793. * This function name is mapped to option_streqvmap so as to not conflict
  794. * with the POSIX name space.
  795. */
  796. extern void streqvmap( char, char, int );
  797. /* From: streqvcmp.c line 102
  798. *
  799. * strneqvcmp - compare two strings with an equivalence mapping
  800. *
  801. * Arguments:
  802. * str1 first string
  803. * str2 second string
  804. * ct compare length
  805. *
  806. * Returns: int - the difference between two differing characters
  807. *
  808. * Using a character mapping, two strings are compared for "equivalence".
  809. * Each input character is mapped to a comparison character and the
  810. * mapped-to characters are compared for the two NUL terminated input strings.
  811. * The comparison is limited to @code{ct} bytes.
  812. * This function name is mapped to option_strneqvcmp so as to not conflict
  813. * with the POSIX name space.
  814. */
  815. extern int strneqvcmp( char const*, char const*, int );
  816. /* From: streqvcmp.c line 259
  817. *
  818. * strtransform - convert a string into its mapped-to value
  819. *
  820. * Arguments:
  821. * dest output string
  822. * src input string
  823. *
  824. * Each character in the input string is mapped and the mapped-to
  825. * character is put into the output.
  826. * This function name is mapped to option_strtransform so as to not conflict
  827. * with the POSIX name space.
  828. */
  829. extern void strtransform( char*, char const* );
  830. /* AutoOpts PRIVATE FUNCTIONS: */
  831. tOptProc optionStackArg, optionUnstackArg, optionBooleanVal, optionNumericVal;
  832. extern char* ao_string_cook( char*, int* );
  833. extern unsigned int ao_string_cook_escape_char( char const*, char*, unsigned int );
  834. extern void export_options_to_guile( tOptions* );
  835. extern void genshelloptUsage( tOptions*, int );
  836. extern void optionBooleanVal( tOptions*, tOptDesc* );
  837. extern uintptr_t optionEnumerationVal( tOptions*, tOptDesc*, char const * const *, unsigned int );
  838. extern char const* optionKeywordName( tOptDesc*, unsigned int );
  839. extern void optionLoadOpt( tOptions*, tOptDesc* );
  840. extern ag_bool optionMakePath( char*, int, char const*, char const* );
  841. extern void optionNestedVal( tOptions*, tOptDesc* );
  842. extern void optionNumericVal( tOptions*, tOptDesc* );
  843. extern void optionPagedUsage( tOptions*, tOptDesc* );
  844. extern void optionParseShell( tOptions* );
  845. extern void optionPrintVersion( tOptions*, tOptDesc* );
  846. extern void optionPutShell( tOptions* );
  847. extern void optionSetMembers( tOptions*, tOptDesc*, char const * const *, unsigned int );
  848. extern void optionStackArg( tOptions*, tOptDesc* );
  849. extern void optionUnstackArg( tOptions*, tOptDesc* );
  850. extern void optionUsage( tOptions*, int );
  851. extern void optionVersionStderr( tOptions*, tOptDesc* );
  852. extern void* text_mmap( char const*, int, int, tmap_info_t* );
  853. extern int text_munmap( tmap_info_t* );
  854. CPLUSPLUS_CLOSER
  855. #endif /* AUTOOPTS_OPTIONS_H_GUARD */
  856. /*
  857. * Local Variables:
  858. * c-file-style: "stroustrup"
  859. * indent-tabs-mode: nil
  860. * End:
  861. * options.h ends here */