📄 options.h
字号:
tAoUS const optMinCt; tAoUS const optMaxCt; tAoUS optOccCt; /* PUBLIC */ tAoUI fOptState; /* PUBLIC */ tAoUI reserved; optArgBucket_t optArg; /* PUBLIC */# define pzLastArg optArg.argString void* optCookie; /* PUBLIC */ const int * pOptMust; const int * pOptCant; tpOptProc pOptProc; char const* pzText; char const* pz_NAME; char const* pz_Name; char const* pz_DisableName; char const* pz_DisablePfx;};/* * Some options need special processing, so we store their * indexes in a known place: */typedef struct optSpecIndex tOptSpecIndex;struct optSpecIndex { const tAoUS more_help; const tAoUS save_opts; const tAoUS number_option; const tAoUS default_opt;};/* * The procedure generated for translating option text */typedef void (tOptionXlateProc)(void);struct options { int const structVersion; int origArgCt; char** origArgVect; unsigned int fOptSet; unsigned int curOptIdx; char* pzCurOpt; char const* pzProgPath; char const* pzProgName; char const* const pzPROGNAME; char const* const pzRcName; char const* const pzCopyright; char const* const pzCopyNotice; char const* const pzFullVersion; char const* const* const papzHomeList; char const* const pzUsageTitle; char const* const pzExplain; char const* const pzDetail; tOptDesc* const pOptDesc; char const* const pzBugAddr; void* pExtensions; void* pSavedState; tpUsageProc pUsageProc; tOptionXlateProc* pTransProc; tOptSpecIndex specOptIdx; int const optCt; int const presetOptCt;};/* * "token list" structure returned by "string_tokenize()" */typedef struct { unsigned long tkn_ct; unsigned char* tkn_list[1];} token_list_t;/* * Hide the interface - it pollutes a POSIX claim, but leave it for * anyone #include-ing this header */#define strneqvcmp option_strneqvcmp#define streqvcmp option_streqvcmp#define streqvmap option_streqvmap#define strequate option_strequate#define strtransform option_strtransform/* * This is an output only structure used by text_mmap and text_munmap. * Clients must not alter the contents and must provide it to both * the text_mmap and text_munmap procedures. BE ADVISED: if you are * mapping the file with PROT_WRITE the NUL byte at the end MIGHT NOT * BE WRITABLE. In any event, that byte is not be written back * to the source file. ALSO: if "txt_data" is valid and "txt_errno" * is not zero, then there *may* not be a terminating NUL. */typedef struct { void* txt_data; /* text file data */ size_t txt_size; /* actual file size */ size_t txt_full_size; /* mmaped mem size */ int txt_fd; /* file descriptor */ int txt_zero_fd; /* fd for /dev/zero */ int txt_errno; /* warning code */ int txt_prot; /* "prot" flags */ int txt_flags; /* mapping type */ int txt_alloc; /* if we malloced memory */} tmap_info_t;#define TEXT_MMAP_FAILED_ADDR(a) ((void*)(a) == (void*)MAP_FAILED)#ifdef __cplusplusextern "C" {#define CPLUSPLUS_CLOSER }#else#define CPLUSPLUS_CLOSER#endif/* * The following routines may be coded into AutoOpts client code: *//* From: tokenize.c line 115 * * ao_string_tokenize - tokenize an input string * * Arguments: * string string to be tokenized * * Returns: token_list_t* - pointer to a structure that lists each token * * This function will convert one input string into a list of strings. * The list of strings is derived by separating the input based on * white space separation. However, if the input contains either single * or double quote characters, then the text after that character up to * a matching quote will become the string in the list. * * The returned pointer should be deallocated with @code{free(3C)} when * are done using the data. The data are placed in a single block of * allocated memory. Do not deallocate individual token/strings. * * The structure pointed to will contain at least these two fields: * @table @samp * @item tkn_ct * The number of tokens found in the input string. * @item tok_list * An array of @code{tkn_ct + 1} pointers to substring tokens, with * the last pointer set to NULL. * @end table * * There are two types of quoted strings: single quoted (@code{'}) and * double quoted (@code{"}). Singly quoted strings are fairly raw in that * escape characters (@code{\\}) are simply another character, except when * preceding the following characters: * @example * @code{\\} double backslashes reduce to one * @code{'} incorporates the single quote into the string * @code{\n} suppresses both the backslash and newline character * @end example * * Double quote strings are formed according to the rules of string * constants in ANSI-C programs. */extern token_list_t* ao_string_tokenize( char const* );/* From: configfile.c line 113 * * configFileLoad - parse a configuration file * * Arguments: * pzFile the file to load * * Returns: const tOptionValue* - An allocated, compound value structure * * This routine will load a named configuration file and parse the * text as a hierarchically valued option. The option descriptor * created from an option definition file is not used via this interface. * The returned value is "named" with the input file name and is of * type "@code{OPARG_TYPE_HIERARCHY}". It may be used in calls to * @code{optionGetValue()}, @code{optionNextValue()} and * @code{optionUnloadNested()}. */extern const tOptionValue* configFileLoad( char const* );/* From: configfile.c line 883 * * optionFileLoad - Load the locatable config files, in order * * Arguments: * pOpts program options descriptor * pzProg program name * * Returns: int - 0 -> SUCCESS, -1 -> FAILURE * * This function looks in all the specified directories for a configuration * file ("rc" file or "ini" file) and processes any found twice. The first * time through, they are processed in reverse order (last file first). At * that time, only "immediate action" configurables are processed. For * example, if the last named file specifies not processing any more * configuration files, then no more configuration files will be processed. * Such an option in the @strong{first} named directory will have no effect. * * Once the immediate action configurables have been handled, then the * directories are handled in normal, forward order. In that way, later * config files can override the settings of earlier config files. * * See the AutoOpts documentation for a thorough discussion of the * config file format. * * Configuration files not found or not decipherable are simply ignored. */extern int optionFileLoad( tOptions*, char const* );/* From: configfile.c line 245 * * optionFindNextValue - find a hierarcicaly valued option instance * * Arguments: * pOptDesc an option with a nested arg type * pPrevVal the last entry * name name of value to find * value the matching value * * Returns: const tOptionValue* - a compound value structure * * This routine will find the next entry in a nested value option or * configurable. It will search through the list and return the next entry * that matches the criteria. */extern const tOptionValue* optionFindNextValue( const tOptDesc*, const tOptionValue*, char const*, char const* );/* From: configfile.c line 171 * * optionFindValue - find a hierarcicaly valued option instance * * Arguments: * pOptDesc an option with a nested arg type * name name of value to find * value the matching value * * Returns: const tOptionValue* - a compound value structure * * This routine will find an entry in a nested value option or configurable. * It will search through the list and return a matching entry. */extern const tOptionValue* optionFindValue( const tOptDesc*, char const*, char const* );/* From: restore.c line 188 * * optionFree - free allocated option processing memory * * Arguments: * pOpts program options descriptor * * AutoOpts sometimes allocates memory and puts pointers to it in the * option state structures. This routine deallocates all such memory. */extern void optionFree( tOptions* );/* From: configfile.c line 314 * * optionGetValue - get a specific value from a hierarcical list * * Arguments: * pOptValue a hierarchcal value * valueName name of value to get * * Returns: const tOptionValue* - a compound value structure * * This routine will find an entry in a nested value option or configurable. * If "valueName" is NULL, then the first entry is returned. Otherwise, * the first entry with a name that exactly matches the argument will be * returned. */extern const tOptionValue* optionGetValue( const tOptionValue*, char const* );/* From: load.c line 521 * * optionLoadLine - process a string for an option name and value * * Arguments: * pOpts program options descriptor * pzLine NUL-terminated text * * This is a client program callable routine for setting options from, for * example, the contents of a file that they read in. Only one option may * appear in the text. It will be treated as a normal (non-preset) option. * * When passed a pointer to the option struct and a string, it will find * the option named by the first token on the string and set the option * argument to the remainder of the string. The caller must NUL terminate * the string. Any embedded new lines will be included in the option * argument. If the input looks like one or more quoted strings, then the * input will be "cooked". The "cooking" is identical to the string * formation used in AutoGen definition files (@pxref{basic expression}), * except that you may not use backquotes. */extern void optionLoadLine( tOptions*, char const* );/* From: configfile.c line 373 * * optionNextValue - get the next value from a hierarchical list * * Arguments: * pOptValue a hierarchcal list value * pOldValue a value from this list * * Returns: const tOptionValue* - a compound value structure * * This routine will return the next entry after the entry passed in. At the * end of the list, NULL will be returned. If the entry is not found on the * list, NULL will be returned and "@var{errno}" will be set to EINVAL. * The "@var{pOldValue}" must have been gotten from a prior call to this * routine or to "@code{opitonGetValue()}". */extern const tOptionValue* optionNextValue( const tOptionValue*, const tOptionValue* );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -