📄 svn_opt.h
字号:
/** * @copyright * ==================================================================== * Copyright (c) 2000-2004 CollabNet. All rights reserved. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://subversion.tigris.org/license-1.html. * If newer versions of this license are posted there, you may use a * newer version instead, at your option. * * This software consists of voluntary contributions made by many * individuals. For exact contribution history, see the revision * history and logs, available at http://subversion.tigris.org/. * ==================================================================== * @endcopyright * * @file svn_opt.h * @brief Option and argument parsing for Subversion command lines */#ifndef SVN_OPTS_H#define SVN_OPTS_H#include <apr.h>#include <apr_pools.h>#include <apr_getopt.h>#include "svn_types.h"#include "svn_error.h"#ifdef __cplusplusextern "C" {#endif /* __cplusplus *//** * All subcommand procedures in Subversion conform to this prototype. * * @a os is the apr option state after getopt processing has been run; in * other words, it still contains the non-option arguments following * the subcommand. See @a os->argv and @a os->ind. * * @a baton is anything you need it to be. * * @a pool is used for allocating errors, and for any other allocation * unless the instance is explicitly documented to allocate from a * pool in @a baton. */typedef svn_error_t *(svn_opt_subcommand_t) (apr_getopt_t *os, void *baton, apr_pool_t *pool);/** The maximum number of aliases a subcommand can have. */#define SVN_OPT_MAX_ALIASES 3/** The maximum number of options that can be accepted by a subcommand. */#define SVN_OPT_MAX_OPTIONS 50/** Options that have no short option char should use an identifying * integer equal to or greater than this. */#define SVN_OPT_FIRST_LONGOPT_ID 256/** One element of a subcommand dispatch table. * * @since New in 1.4. */typedef struct svn_opt_subcommand_desc2_t{ /** The full name of this command. */ const char *name; /** The function this command invokes. */ svn_opt_subcommand_t *cmd_func; /** A list of alias names for this command (e.g., 'up' for 'update'). */ const char *aliases[SVN_OPT_MAX_ALIASES]; /** A brief string describing this command, for usage messages. */ const char *help; /** A list of options accepted by this command. Each value in the * array is a unique enum (the 2nd field in apr_getopt_option_t) */ int valid_options[SVN_OPT_MAX_OPTIONS]; /** A list of option help descriptions, keyed by the option unique enum * (the 2nd field in apr_getopt_option_t), which override the generic * descriptions given in an apr_getopt_option_t on a per-subcommand basis. */ struct { int optch; const char *desc; } desc_overrides[SVN_OPT_MAX_OPTIONS];} svn_opt_subcommand_desc2_t;/** One element of a subcommand dispatch table. * * @deprecated Provided for backward compatibility with the 1.3 API. * * Like #svn_opt_subcommand_desc2_t but lacking the @c desc_overrides * member. */typedef struct svn_opt_subcommand_desc_t{ /** The full name of this command. */ const char *name; /** The function this command invokes. */ svn_opt_subcommand_t *cmd_func; /** A list of alias names for this command (e.g., 'up' for 'update'). */ const char *aliases[SVN_OPT_MAX_ALIASES]; /** A brief string describing this command, for usage messages. */ const char *help; /** A list of options accepted by this command. Each value in the * array is a unique enum (the 2nd field in apr_getopt_option_t) */ int valid_options[SVN_OPT_MAX_OPTIONS];} svn_opt_subcommand_desc_t;/** * Return the entry in @a table whose name matches @a cmd_name, or @c NULL if * none. @a cmd_name may be an alias. * * @since New in 1.4. */ const svn_opt_subcommand_desc2_t *svn_opt_get_canonical_subcommand2(const svn_opt_subcommand_desc2_t *table, const char *cmd_name);/** * Return the entry in @a table whose name matches @a cmd_name, or @c NULL if * none. @a cmd_name may be an alias. * * Same as svn_opt_get_canonical_subcommand2(), but acts on * #svn_opt_subcommand_desc_t. * * @deprecated Provided for backward compatibility with the 1.3 API. */ const svn_opt_subcommand_desc_t *svn_opt_get_canonical_subcommand(const svn_opt_subcommand_desc_t *table, const char *cmd_name);/** * Return pointer to an @c apr_getopt_option_t for the option whose * option code is @a code, or @c NULL if no match. @a option_table must end * with an element whose every field is zero. If @c command is non-NULL, * then the subcommand-specific option description instead of the generic one, * if a specific description is defined. * * The returned value may be statically allocated, or allocated in @a pool. * * @since New in 1.4. */const apr_getopt_option_t *svn_opt_get_option_from_code2(int code, const apr_getopt_option_t *option_table, const svn_opt_subcommand_desc2_t *command, apr_pool_t *pool);/** * Return the first entry from @a option_table whose option code is @a code, * or @c NULL if no match. @a option_table must end with an element whose * every field is zero. * * @deprecated Provided for backward compatibility with the 1.3 API. */const apr_getopt_option_t *svn_opt_get_option_from_code(int code, const apr_getopt_option_t *option_table);/** * Return @c TRUE iff subcommand @a command supports option @a option_code, * else return @c FALSE. * * @since New in 1.4. */svn_boolean_tsvn_opt_subcommand_takes_option2(const svn_opt_subcommand_desc2_t *command, int option_code);/** * Return @c TRUE iff subcommand @a command supports option @a option_code, * else return @c FALSE. * * Same as svn_opt_subcommand_takes_option2(), but acts on * #svn_opt_subcommand_desc_t. * * @deprecated Provided for backward compatibility with the 1.3 API. */svn_boolean_tsvn_opt_subcommand_takes_option(const svn_opt_subcommand_desc_t *command, int option_code);/** * Print a generic (not command-specific) usage message to @a stream. * * (### todo: why is @a stream a stdio file instead of an svn stream?) * * If @a header is non-null, print @a header followed by a newline. Then * loop over @a cmd_table printing the usage for each command (getting * option usages from @a opt_table). Then if @a footer is non-null, print * @a footer followed by a newline. * * Use @a pool for temporary allocation. * * @since New in 1.4. */voidsvn_opt_print_generic_help2(const char *header, const svn_opt_subcommand_desc2_t *cmd_table, const apr_getopt_option_t *opt_table, const char *footer, apr_pool_t *pool, FILE *stream);/* Same as svn_opt_print_generic_help2(), but acts on * #svn_opt_subcommand_desc_t. * * @deprecated Provided for backward compatibility with the 1.3 API. */voidsvn_opt_print_generic_help(const char *header, const svn_opt_subcommand_desc_t *cmd_table, const apr_getopt_option_t *opt_table, const char *footer, apr_pool_t *pool, FILE *stream);/** * Print an option @a opt nicely into a @a string allocated in @a pool. * If @a doc is set, include the generic documentation string of @a opt, * localized to the current locale if a translation is available. */voidsvn_opt_format_option(const char **string, const apr_getopt_option_t *opt, svn_boolean_t doc, apr_pool_t *pool);/** * Get @a subcommand's usage from @a table, and print it to @c stdout. * Obtain option usage from @a options_table. Use @a pool for temporary * allocation. @a subcommand may be a canonical command name or an * alias. (### todo: why does this only print to @c stdout, whereas * svn_opt_print_generic_help() gives us a choice?) * * @since New in 1.4. */voidsvn_opt_subcommand_help2(const char *subcommand, const svn_opt_subcommand_desc2_t *table, const apr_getopt_option_t *options_table, apr_pool_t *pool);/** * Same as svn_opt_subcommand_help2(), but acts on * #svn_opt_subcommand_desc_t. * * @deprecated Provided for backward compatibility with the 1.3 API. */void
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -