⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 argp.h

📁 此工具是arm-linux-GCC交叉编译工具(cross-3.4.4)
💻 H
📖 第 1 页 / 共 2 页
字号:
/* Hierarchial argument parsing, layered over getopt.   Copyright (C) 1995-1999,2003,2004 Free Software Foundation, Inc.   This file is part of the GNU C Library.   Written by Miles Bader <miles@gnu.ai.mit.edu>.   The GNU C Library is free software; you can redistribute it and/or   modify it under the terms of the GNU Lesser General Public   License as published by the Free Software Foundation; either   version 2.1 of the License, or (at your option) any later version.   The GNU C Library is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   Lesser General Public License for more details.   You should have received a copy of the GNU Lesser General Public   License along with the GNU C Library; if not, write to the Free   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   02111-1307 USA.  */#ifndef _ARGP_H#define _ARGP_H#include <stdio.h>#include <ctype.h>#include <getopt.h>#define __need_error_t#include <errno.h>#ifndef __const# define __const const#endif#ifndef __THROW# define __THROW#endif#ifndef __NTH# define __NTH(fct) fct __THROW#endif#ifndef __attribute__/* This feature is available in gcc versions 2.5 and later.  */# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__#  define __attribute__(Spec) /* empty */# endif/* The __-protected variants of `format' and `printf' attributes   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || __STRICT_ANSI__#  define __format__ format#  define __printf__ printf# endif#endif/* GCC 2.95 and later have "__restrict"; C99 compilers have   "restrict", and "configure" may have defined "restrict".  */#ifndef __restrict# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))#  if defined restrict || 199901L <= __STDC_VERSION__#   define __restrict restrict#  else#   define __restrict#  endif# endif#endif#ifndef __error_t_definedtypedef int error_t;# define __error_t_defined#endif#ifdef  __cplusplusextern "C" {#endif/* A description of a particular option.  A pointer to an array of   these is passed in the OPTIONS field of an argp structure.  Each option   entry can correspond to one long option and/or one short option; more   names for the same option can be added by following an entry in an option   array with options having the OPTION_ALIAS flag set.  */struct argp_option{  /* The long option name.  For more than one name for the same option, you     can use following options with the OPTION_ALIAS flag set.  */  __const char *name;  /* What key is returned for this option.  If > 0 and printable, then it's     also accepted as a short option.  */  int key;  /* If non-NULL, this is the name of the argument associated with this     option, which is required unless the OPTION_ARG_OPTIONAL flag is set. */  __const char *arg;  /* OPTION_ flags.  */  int flags;  /* The doc string for this option.  If both NAME and KEY are 0, This string     will be printed outdented from the normal option column, making it     useful as a group header (it will be the first thing printed in its     group); in this usage, it's conventional to end the string with a `:'.  */  __const char *doc;  /* The group this option is in.  In a long help message, options are sorted     alphabetically within each group, and the groups presented in the order     0, 1, 2, ..., n, -m, ..., -2, -1.  Every entry in an options array with     if this field 0 will inherit the group number of the previous entry, or     zero if it's the first one, unless its a group header (NAME and KEY both     0), in which case, the previous entry + 1 is the default.  Automagic     options such as --help are put into group -1.  */  int group;};/* The argument associated with this option is optional.  */#define OPTION_ARG_OPTIONAL	0x1/* This option isn't displayed in any help messages.  */#define OPTION_HIDDEN	       	0x2/* This option is an alias for the closest previous non-alias option.  This   means that it will be displayed in the same help entry, and will inherit   fields other than NAME and KEY from the aliased option.  */#define OPTION_ALIAS		0x4/* This option isn't actually an option (and so should be ignored by the   actual option parser), but rather an arbitrary piece of documentation that   should be displayed in much the same manner as the options.  If this flag   is set, then the option NAME field is displayed unmodified (e.g., no `--'   prefix is added) at the left-margin (where a *short* option would normally   be displayed), and the documentation string in the normal place.  For   purposes of sorting, any leading whitespace and punctuation is ignored,   except that if the first non-whitespace character is not `-', this entry   is displayed after all options (and OPTION_DOC entries with a leading `-')   in the same group.  */#define OPTION_DOC		0x8/* This option shouldn't be included in `long' usage messages (but is still   included in help messages).  This is mainly intended for options that are   completely documented in an argp's ARGS_DOC field, in which case including   the option in the generic usage list would be redundant.  For instance,   if ARGS_DOC is "FOO BAR\n-x BLAH", and the `-x' option's purpose is to   distinguish these two cases, -x should probably be marked   OPTION_NO_USAGE.  */#define OPTION_NO_USAGE		0x10struct argp;			/* fwd declare this type */struct argp_state;		/* " */struct argp_child;		/* " *//* The type of a pointer to an argp parsing function.  */typedef error_t (*argp_parser_t) (int key, char *arg,				  struct argp_state *state);/* What to return for unrecognized keys.  For special ARGP_KEY_ keys, such   returns will simply be ignored.  For user keys, this error will be turned   into EINVAL (if the call to argp_parse is such that errors are propagated   back to the user instead of exiting); returning EINVAL itself would result   in an immediate stop to parsing in *all* cases.  */#define ARGP_ERR_UNKNOWN	E2BIG /* Hurd should never need E2BIG.  XXX *//* Special values for the KEY argument to an argument parsing function.   ARGP_ERR_UNKNOWN should be returned if they aren't understood.   The sequence of keys to a parsing function is either (where each   uppercased word should be prefixed by `ARGP_KEY_' and opt is a user key):       INIT opt... NO_ARGS END SUCCESS  -- No non-option arguments at all   or  INIT (opt | ARG)... END SUCCESS  -- All non-option args parsed   or  INIT (opt | ARG)... SUCCESS      -- Some non-option arg unrecognized   The third case is where every parser returned ARGP_KEY_UNKNOWN for an   argument, in which case parsing stops at that argument (returning the   unparsed arguments to the caller of argp_parse if requested, or stopping   with an error message if not).   If an error occurs (either detected by argp, or because the parsing   function returned an error value), then the parser is called with   ARGP_KEY_ERROR, and no further calls are made.  *//* This is not an option at all, but rather a command line argument.  If a   parser receiving this key returns success, the fact is recorded, and the   ARGP_KEY_NO_ARGS case won't be used.  HOWEVER, if while processing the   argument, a parser function decrements the NEXT field of the state it's   passed, the option won't be considered processed; this is to allow you to   actually modify the argument (perhaps into an option), and have it   processed again.  */#define ARGP_KEY_ARG		0/* There are remaining arguments not parsed by any parser, which may be found   starting at (STATE->argv + STATE->next).  If success is returned, but   STATE->next left untouched, it's assumed that all arguments were consume,   otherwise, the parser should adjust STATE->next to reflect any arguments   consumed.  */#define ARGP_KEY_ARGS		0x1000006/* There are no more command line arguments at all.  */#define ARGP_KEY_END		0x1000001/* Because it's common to want to do some special processing if there aren't   any non-option args, user parsers are called with this key if they didn't   successfully process any non-option arguments.  Called just before   ARGP_KEY_END (where more general validity checks on previously parsed   arguments can take place).  */#define ARGP_KEY_NO_ARGS	0x1000002/* Passed in before any parsing is done.  Afterwards, the values of each   element of the CHILD_INPUT field, if any, in the state structure is   copied to each child's state to be the initial value of the INPUT field.  */#define ARGP_KEY_INIT		0x1000003/* Use after all other keys, including SUCCESS & END.  */#define ARGP_KEY_FINI		0x1000007/* Passed in when parsing has successfully been completed (even if there are   still arguments remaining).  */#define ARGP_KEY_SUCCESS	0x1000004/* Passed in if an error occurs.  */#define ARGP_KEY_ERROR		0x1000005/* An argp structure contains a set of options declarations, a function to   deal with parsing one, documentation string, a possible vector of child   argp's, and perhaps a function to filter help output.  When actually   parsing options, getopt is called with the union of all the argp   structures chained together through their CHILD pointers, with conflicts   being resolved in favor of the first occurrence in the chain.  */struct argp{  /* An array of argp_option structures, terminated by an entry with both     NAME and KEY having a value of 0.  */  __const struct argp_option *options;  /* What to do with an option from this structure.  KEY is the key     associated with the option, and ARG is any associated argument (NULL if     none was supplied).  If KEY isn't understood, ARGP_ERR_UNKNOWN should be     returned.  If a non-zero, non-ARGP_ERR_UNKNOWN value is returned, then     parsing is stopped immediately, and that value is returned from     argp_parse().  For special (non-user-supplied) values of KEY, see the     ARGP_KEY_ definitions below.  */  argp_parser_t parser;  /* A string describing what other arguments are wanted by this program.  It     is only used by argp_usage to print the `Usage:' message.  If it     contains newlines, the strings separated by them are considered     alternative usage patterns, and printed on separate lines (lines after     the first are prefix by `  or: ' instead of `Usage:').  */  __const char *args_doc;  /* If non-NULL, a string containing extra text to be printed before and     after the options in a long help message (separated by a vertical tab     `\v' character).  */  __const char *doc;  /* A vector of argp_children structures, terminated by a member with a 0     argp field, pointing to child argps should be parsed with this one.  Any     conflicts are resolved in favor of this argp, or early argps in the     CHILDREN list.  This field is useful if you use libraries that supply     their own argp structure, which you want to use in conjunction with your     own.  */  __const struct argp_child *children;  /* If non-zero, this should be a function to filter the output of help     messages.  KEY is either a key from an option, in which case TEXT is     that option's help text, or a special key from the ARGP_KEY_HELP_     defines, below, describing which other help text TEXT is.  The function     should return either TEXT, if it should be used as-is, a replacement     string, which should be malloced, and will be freed by argp, or NULL,     meaning `print nothing'.  The value for TEXT is *after* any translation     has been done, so if any of the replacement text also needs translation,     that should be done by the filter function.  INPUT is either the input     supplied to argp_parse, or NULL, if argp_help was called directly.  */  char *(*help_filter) (int __key, __const char *__text, void *__input);  /* If non-zero the strings used in the argp library are translated using     the domain described by this string.  Otherwise the currently installed     default domain is used.  */  const char *argp_domain;};/* Possible KEY arguments to a help filter function.  */#define ARGP_KEY_HELP_PRE_DOC	0x2000001 /* Help text preceeding options. */#define ARGP_KEY_HELP_POST_DOC	0x2000002 /* Help text following options. */#define ARGP_KEY_HELP_HEADER	0x2000003 /* Option header string. */#define ARGP_KEY_HELP_EXTRA	0x2000004 /* After all other documentation;					     TEXT is NULL for this key.  *//* Explanatory note emitted when duplicate option arguments have been   suppressed.  */#define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005#define ARGP_KEY_HELP_ARGS_DOC	0x2000006 /* Argument doc string.  *//* When an argp has a non-zero CHILDREN field, it should point to a vector of   argp_child structures, each of which describes a subsidiary argp.  */struct argp_child{  /* The child parser.  */  __const struct argp *argp;  /* Flags for this child.  */  int flags;  /* If non-zero, an optional header to be printed in help output before the     child options.  As a side-effect, a non-zero value forces the child     options to be grouped together; to achieve this effect without actually     printing a header string, use a value of "".  */  __const char *header;  /* Where to group the child options relative to the other (`consolidated')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -