options.h 34 KB

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