1251881Speter/** 2251881Speter * @copyright 3251881Speter * ==================================================================== 4251881Speter * Licensed to the Apache Software Foundation (ASF) under one 5251881Speter * or more contributor license agreements. See the NOTICE file 6251881Speter * distributed with this work for additional information 7251881Speter * regarding copyright ownership. The ASF licenses this file 8251881Speter * to you under the Apache License, Version 2.0 (the 9251881Speter * "License"); you may not use this file except in compliance 10251881Speter * with the License. You may obtain a copy of the License at 11251881Speter * 12251881Speter * http://www.apache.org/licenses/LICENSE-2.0 13251881Speter * 14251881Speter * Unless required by applicable law or agreed to in writing, 15251881Speter * software distributed under the License is distributed on an 16251881Speter * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17251881Speter * KIND, either express or implied. See the License for the 18251881Speter * specific language governing permissions and limitations 19251881Speter * under the License. 20251881Speter * ==================================================================== 21251881Speter * @endcopyright 22251881Speter * 23251881Speter * @file svn_opt.h 24251881Speter * @brief Option and argument parsing for Subversion command lines 25251881Speter */ 26251881Speter 27251881Speter#ifndef SVN_OPTS_H 28251881Speter#define SVN_OPTS_H 29251881Speter 30251881Speter#include <apr.h> 31251881Speter#include <apr_pools.h> 32251881Speter#include <apr_getopt.h> 33251881Speter#include <apr_tables.h> 34251881Speter#include <apr_hash.h> 35251881Speter 36251881Speter#ifndef DOXYGEN_SHOULD_SKIP_THIS 37251881Speter#define APR_WANT_STDIO 38251881Speter#endif 39251881Speter#include <apr_want.h> /* for FILE* */ 40251881Speter 41251881Speter#include "svn_types.h" 42251881Speter 43251881Speter#ifdef __cplusplus 44251881Speterextern "C" { 45251881Speter#endif /* __cplusplus */ 46251881Speter 47251881Speter 48251881Speter 49251881Speter/** 50251881Speter * All subcommand procedures in Subversion conform to this prototype. 51251881Speter * 52251881Speter * @a os is the apr option state after getopt processing has been run; in 53251881Speter * other words, it still contains the non-option arguments following 54251881Speter * the subcommand. See @a os->argv and @a os->ind. 55251881Speter * 56251881Speter * @a baton is anything you need it to be. 57251881Speter * 58251881Speter * @a pool is used for allocating errors, and for any other allocation 59251881Speter * unless the instance is explicitly documented to allocate from a 60251881Speter * pool in @a baton. 61251881Speter */ 62251881Spetertypedef svn_error_t *(svn_opt_subcommand_t)( 63251881Speter apr_getopt_t *os, void *baton, apr_pool_t *pool); 64251881Speter 65251881Speter 66251881Speter/** The maximum number of aliases a subcommand can have. */ 67251881Speter#define SVN_OPT_MAX_ALIASES 3 68251881Speter 69251881Speter/** The maximum number of options that can be accepted by a subcommand. */ 70251881Speter#define SVN_OPT_MAX_OPTIONS 50 71251881Speter 72251881Speter/** Options that have no short option char should use an identifying 73251881Speter * integer equal to or greater than this. 74251881Speter */ 75251881Speter#define SVN_OPT_FIRST_LONGOPT_ID 256 76251881Speter 77251881Speter 78251881Speter/** One element of a subcommand dispatch table. 79251881Speter * 80251881Speter * @since New in 1.4. 81251881Speter */ 82251881Spetertypedef struct svn_opt_subcommand_desc2_t 83251881Speter{ 84251881Speter /** The full name of this command. */ 85251881Speter const char *name; 86251881Speter 87251881Speter /** The function this command invokes. */ 88251881Speter svn_opt_subcommand_t *cmd_func; 89251881Speter 90251881Speter /** A list of alias names for this command (e.g., 'up' for 'update'). */ 91251881Speter const char *aliases[SVN_OPT_MAX_ALIASES]; 92251881Speter 93251881Speter /** A brief string describing this command, for usage messages. */ 94251881Speter const char *help; 95251881Speter 96251881Speter /** A list of options accepted by this command. Each value in the 97251881Speter * array is a unique enum (the 2nd field in apr_getopt_option_t) 98251881Speter */ 99251881Speter int valid_options[SVN_OPT_MAX_OPTIONS]; 100251881Speter 101251881Speter /** A list of option help descriptions, keyed by the option unique enum 102251881Speter * (the 2nd field in apr_getopt_option_t), which override the generic 103251881Speter * descriptions given in an apr_getopt_option_t on a per-subcommand basis. 104251881Speter */ 105251881Speter struct { int optch; const char *desc; } desc_overrides[SVN_OPT_MAX_OPTIONS]; 106251881Speter} svn_opt_subcommand_desc2_t; 107251881Speter 108251881Speter 109251881Speter/** One element of a subcommand dispatch table. 110251881Speter * 111251881Speter * @deprecated Provided for backward compatibility with the 1.3 API. 112251881Speter * 113251881Speter * Like #svn_opt_subcommand_desc2_t but lacking the @c desc_overrides 114251881Speter * member. 115251881Speter */ 116251881Spetertypedef struct svn_opt_subcommand_desc_t 117251881Speter{ 118251881Speter /** The full name of this command. */ 119251881Speter const char *name; 120251881Speter 121251881Speter /** The function this command invokes. */ 122251881Speter svn_opt_subcommand_t *cmd_func; 123251881Speter 124251881Speter /** A list of alias names for this command (e.g., 'up' for 'update'). */ 125251881Speter const char *aliases[SVN_OPT_MAX_ALIASES]; 126251881Speter 127251881Speter /** A brief string describing this command, for usage messages. */ 128251881Speter const char *help; 129251881Speter 130251881Speter /** A list of options accepted by this command. Each value in the 131251881Speter * array is a unique enum (the 2nd field in apr_getopt_option_t) 132251881Speter */ 133251881Speter int valid_options[SVN_OPT_MAX_OPTIONS]; 134251881Speter 135251881Speter} svn_opt_subcommand_desc_t; 136251881Speter 137251881Speter 138251881Speter/** 139251881Speter * Return the entry in @a table whose name matches @a cmd_name, or @c NULL if 140251881Speter * none. @a cmd_name may be an alias. 141251881Speter * 142251881Speter * @since New in 1.4. 143251881Speter */ 144251881Speterconst svn_opt_subcommand_desc2_t * 145251881Spetersvn_opt_get_canonical_subcommand2(const svn_opt_subcommand_desc2_t *table, 146251881Speter const char *cmd_name); 147251881Speter 148251881Speter 149251881Speter/** 150251881Speter * Return the entry in @a table whose name matches @a cmd_name, or @c NULL if 151251881Speter * none. @a cmd_name may be an alias. 152251881Speter * 153251881Speter * Same as svn_opt_get_canonical_subcommand2(), but acts on 154251881Speter * #svn_opt_subcommand_desc_t. 155251881Speter * 156251881Speter * @deprecated Provided for backward compatibility with the 1.3 API. 157251881Speter */ 158251881SpeterSVN_DEPRECATED 159251881Speterconst svn_opt_subcommand_desc_t * 160251881Spetersvn_opt_get_canonical_subcommand(const svn_opt_subcommand_desc_t *table, 161251881Speter const char *cmd_name); 162251881Speter 163251881Speter 164251881Speter/** 165251881Speter * Return pointer to an @c apr_getopt_option_t for the option whose 166251881Speter * option code is @a code, or @c NULL if no match. @a option_table must end 167251881Speter * with an element whose every field is zero. If @a command is non-NULL, 168251881Speter * then return the subcommand-specific option description instead of the 169251881Speter * generic one, if a specific description is defined. 170251881Speter * 171251881Speter * The returned value may be statically allocated, or allocated in @a pool. 172251881Speter * 173251881Speter * @since New in 1.4. 174251881Speter */ 175251881Speterconst apr_getopt_option_t * 176251881Spetersvn_opt_get_option_from_code2(int code, 177251881Speter const apr_getopt_option_t *option_table, 178251881Speter const svn_opt_subcommand_desc2_t *command, 179251881Speter apr_pool_t *pool); 180251881Speter 181251881Speter 182251881Speter/** 183251881Speter * Return the first entry from @a option_table whose option code is @a code, 184251881Speter * or @c NULL if no match. @a option_table must end with an element whose 185251881Speter * every field is zero. 186251881Speter * 187251881Speter * @deprecated Provided for backward compatibility with the 1.3 API. 188251881Speter */ 189251881SpeterSVN_DEPRECATED 190251881Speterconst apr_getopt_option_t * 191251881Spetersvn_opt_get_option_from_code(int code, 192251881Speter const apr_getopt_option_t *option_table); 193251881Speter 194251881Speter 195251881Speter/** 196251881Speter * Return @c TRUE iff subcommand @a command supports option @a 197251881Speter * option_code, else return @c FALSE. If @a global_options is 198251881Speter * non-NULL, it is a zero-terminated array, and all subcommands take 199251881Speter * the options listed in it. 200251881Speter * 201251881Speter * @since New in 1.5. 202251881Speter */ 203251881Spetersvn_boolean_t 204251881Spetersvn_opt_subcommand_takes_option3(const svn_opt_subcommand_desc2_t *command, 205251881Speter int option_code, 206251881Speter const int *global_options); 207251881Speter 208251881Speter/** 209251881Speter * Same as svn_opt_subcommand_takes_option3(), but with @c NULL for @a 210251881Speter * global_options. 211251881Speter * 212251881Speter * @deprecated Provided for backward compatibility with the 1.4 API. 213251881Speter */ 214251881SpeterSVN_DEPRECATED 215251881Spetersvn_boolean_t 216251881Spetersvn_opt_subcommand_takes_option2(const svn_opt_subcommand_desc2_t *command, 217251881Speter int option_code); 218251881Speter 219251881Speter 220251881Speter/** 221251881Speter * Return @c TRUE iff subcommand @a command supports option @a option_code, 222251881Speter * else return @c FALSE. 223251881Speter * 224251881Speter * Same as svn_opt_subcommand_takes_option2(), but acts on 225251881Speter * #svn_opt_subcommand_desc_t. 226251881Speter * 227251881Speter * @deprecated Provided for backward compatibility with the 1.3 API. 228251881Speter */ 229251881SpeterSVN_DEPRECATED 230251881Spetersvn_boolean_t 231251881Spetersvn_opt_subcommand_takes_option(const svn_opt_subcommand_desc_t *command, 232251881Speter int option_code); 233251881Speter 234251881Speter 235251881Speter/** 236251881Speter * Print a generic (not command-specific) usage message to @a stream. 237251881Speter * 238251881Speter * ### @todo Why is @a stream a stdio file instead of an svn stream? 239251881Speter * 240251881Speter * If @a header is non-NULL, print @a header followed by a newline. Then 241251881Speter * loop over @a cmd_table printing the usage for each command (getting 242251881Speter * option usages from @a opt_table). Then if @a footer is non-NULL, print 243251881Speter * @a footer followed by a newline. 244251881Speter * 245251881Speter * Use @a pool for temporary allocation. 246251881Speter * 247251881Speter * @since New in 1.4. 248251881Speter */ 249251881Spetervoid 250251881Spetersvn_opt_print_generic_help2(const char *header, 251251881Speter const svn_opt_subcommand_desc2_t *cmd_table, 252251881Speter const apr_getopt_option_t *opt_table, 253251881Speter const char *footer, 254251881Speter apr_pool_t *pool, 255251881Speter FILE *stream); 256251881Speter 257251881Speter 258251881Speter/** 259251881Speter * Same as svn_opt_print_generic_help2(), but acts on 260251881Speter * #svn_opt_subcommand_desc_t. 261251881Speter * 262251881Speter * @deprecated Provided for backward compatibility with the 1.3 API. 263251881Speter */ 264251881SpeterSVN_DEPRECATED 265251881Spetervoid 266251881Spetersvn_opt_print_generic_help(const char *header, 267251881Speter const svn_opt_subcommand_desc_t *cmd_table, 268251881Speter const apr_getopt_option_t *opt_table, 269251881Speter const char *footer, 270251881Speter apr_pool_t *pool, 271251881Speter FILE *stream); 272251881Speter 273251881Speter 274251881Speter/** 275251881Speter * Print an option @a opt nicely into a @a string allocated in @a pool. 276251881Speter * If @a doc is set, include the generic documentation string of @a opt, 277251881Speter * localized to the current locale if a translation is available. 278251881Speter */ 279251881Spetervoid 280251881Spetersvn_opt_format_option(const char **string, 281251881Speter const apr_getopt_option_t *opt, 282251881Speter svn_boolean_t doc, 283251881Speter apr_pool_t *pool); 284251881Speter 285251881Speter 286251881Speter 287251881Speter/** 288251881Speter * Get @a subcommand's usage from @a table, and print it to @c stdout. 289251881Speter * Obtain option usage from @a options_table. If not @c NULL, @a 290251881Speter * global_options is a zero-terminated list of global options. Use @a 291251881Speter * pool for temporary allocation. @a subcommand may be a canonical 292251881Speter * command name or an alias. ### @todo Why does this only print to 293251881Speter * @c stdout, whereas svn_opt_print_generic_help() gives us a choice? 294251881Speter * 295251881Speter * When printing the description of an option, if the same option code 296251881Speter * appears a second time in @a options_table with a different name, then 297251881Speter * use that second name as an alias for the first name. This additional 298251881Speter * behaviour is new in 1.7. 299251881Speter * 300251881Speter * @since New in 1.5. 301251881Speter */ 302251881Spetervoid 303251881Spetersvn_opt_subcommand_help3(const char *subcommand, 304251881Speter const svn_opt_subcommand_desc2_t *table, 305251881Speter const apr_getopt_option_t *options_table, 306251881Speter const int *global_options, 307251881Speter apr_pool_t *pool); 308251881Speter 309251881Speter/** 310251881Speter * Same as svn_opt_subcommand_help3(), but with @a global_options 311251881Speter * always NULL. 312251881Speter * 313251881Speter * @deprecated Provided for backward compatibility with the 1.4 API. 314251881Speter */ 315251881SpeterSVN_DEPRECATED 316251881Spetervoid 317251881Spetersvn_opt_subcommand_help2(const char *subcommand, 318251881Speter const svn_opt_subcommand_desc2_t *table, 319251881Speter const apr_getopt_option_t *options_table, 320251881Speter apr_pool_t *pool); 321251881Speter 322251881Speter 323251881Speter/** 324251881Speter * Same as svn_opt_subcommand_help2(), but acts on 325251881Speter * #svn_opt_subcommand_desc_t. 326251881Speter * 327251881Speter * @deprecated Provided for backward compatibility with the 1.3 API. 328251881Speter */ 329251881SpeterSVN_DEPRECATED 330251881Spetervoid 331251881Spetersvn_opt_subcommand_help(const char *subcommand, 332251881Speter const svn_opt_subcommand_desc_t *table, 333251881Speter const apr_getopt_option_t *options_table, 334251881Speter apr_pool_t *pool); 335251881Speter 336251881Speter 337251881Speter 338251881Speter/* Parsing revision and date options. */ 339251881Speter 340251881Speter/** 341251881Speter * Various ways of specifying revisions. 342251881Speter * 343251881Speter * @note 344251881Speter * In contexts where local mods are relevant, the `working' kind 345251881Speter * refers to the uncommitted "working" revision, which may be modified 346251881Speter * with respect to its base revision. In other contexts, `working' 347251881Speter * should behave the same as `committed' or `current'. 348251881Speter */ 349251881Speterenum svn_opt_revision_kind { 350251881Speter /** No revision information given. */ 351251881Speter svn_opt_revision_unspecified, 352251881Speter 353251881Speter /** revision given as number */ 354251881Speter svn_opt_revision_number, 355251881Speter 356251881Speter /** revision given as date */ 357251881Speter svn_opt_revision_date, 358251881Speter 359251881Speter /** rev of most recent change */ 360251881Speter svn_opt_revision_committed, 361251881Speter 362251881Speter /** (rev of most recent change) - 1 */ 363251881Speter svn_opt_revision_previous, 364251881Speter 365251881Speter /** .svn/entries current revision */ 366251881Speter svn_opt_revision_base, 367251881Speter 368251881Speter /** current, plus local mods */ 369251881Speter svn_opt_revision_working, 370251881Speter 371251881Speter /** repository youngest */ 372251881Speter svn_opt_revision_head 373251881Speter 374251881Speter /* please update svn_opt__revision_to_string() when extending this enum */ 375251881Speter}; 376251881Speter 377251881Speter/** 378251881Speter * A revision value, which can be specified as a number or a date. 379251881Speter * 380251881Speter * @note This union was formerly an anonymous inline type in 381251881Speter * @c svn_opt_revision_t, and was converted to a named type just to 382251881Speter * make things easier for SWIG. 383251881Speter * 384251881Speter * @since New in 1.3. 385251881Speter */ 386251881Spetertypedef union svn_opt_revision_value_t 387251881Speter{ 388251881Speter /** The revision number */ 389251881Speter svn_revnum_t number; 390251881Speter 391251881Speter /** the date of the revision */ 392251881Speter apr_time_t date; 393251881Speter} svn_opt_revision_value_t; 394251881Speter 395251881Speter/** A revision, specified in one of @c svn_opt_revision_kind ways. */ 396251881Spetertypedef struct svn_opt_revision_t 397251881Speter{ 398251881Speter enum svn_opt_revision_kind kind; /**< See svn_opt_revision_kind */ 399251881Speter svn_opt_revision_value_t value; /**< Extra data qualifying the @c kind */ 400251881Speter} svn_opt_revision_t; 401251881Speter 402251881Speter/** A revision range, specified in one of @c svn_opt_revision_kind ways. */ 403251881Spetertypedef struct svn_opt_revision_range_t 404251881Speter{ 405251881Speter /** The first revision in the range */ 406251881Speter svn_opt_revision_t start; 407251881Speter 408251881Speter /** The last revision in the range */ 409251881Speter svn_opt_revision_t end; 410251881Speter} svn_opt_revision_range_t; 411251881Speter 412251881Speter/** 413251881Speter * Set @a *start_revision and/or @a *end_revision according to @a arg, 414251881Speter * where @a arg is "N" or "N:M", like so: 415251881Speter * 416251881Speter * - If @a arg is "N", set @a *start_revision to represent N, and 417251881Speter * leave @a *end_revision untouched. 418251881Speter * 419251881Speter * - If @a arg is "N:M", set @a *start_revision and @a *end_revision 420251881Speter * to represent N and M respectively. 421251881Speter * 422251881Speter * N and/or M may be one of the special revision descriptors 423251881Speter * recognized by revision_from_word(), or a date in curly braces. 424251881Speter * 425251881Speter * If @a arg is invalid, return -1; else return 0. 426251881Speter * It is invalid to omit a revision (as in, ":", "N:" or ":M"). 427251881Speter * 428251881Speter * @note It is typical, though not required, for @a *start_revision and 429251881Speter * @a *end_revision to be @c svn_opt_revision_unspecified kind on entry. 430251881Speter * 431251881Speter * Use @a pool for temporary allocations. 432251881Speter */ 433251881Speterint 434251881Spetersvn_opt_parse_revision(svn_opt_revision_t *start_revision, 435251881Speter svn_opt_revision_t *end_revision, 436251881Speter const char *arg, 437251881Speter apr_pool_t *pool); 438251881Speter 439251881Speter/** 440251881Speter * Parse @a arg, where @a arg is "N" or "N:M", into a 441251881Speter * @c svn_opt_revision_range_t and push that onto @a opt_ranges. 442251881Speter * 443251881Speter * - If @a arg is "N", set the @c start field of the 444251881Speter * @c svn_opt_revision_range_t to represent N and the @c end field 445251881Speter * to @c svn_opt_revision_unspecified. 446251881Speter * 447251881Speter * - If @a arg is "N:M", set the @c start field of the 448251881Speter * @c svn_opt_revision_range_t to represent N and the @c end field 449251881Speter * to represent M. 450251881Speter * 451251881Speter * If @a arg is invalid, return -1; else return 0. It is invalid to omit 452251881Speter * a revision (as in, ":", "N:" or ":M"). 453251881Speter * 454251881Speter * Use @a pool to allocate @c svn_opt_revision_range_t pushed to the array. 455251881Speter * 456251881Speter * @since New in 1.5. 457251881Speter */ 458251881Speterint 459251881Spetersvn_opt_parse_revision_to_range(apr_array_header_t *opt_ranges, 460251881Speter const char *arg, 461251881Speter apr_pool_t *pool); 462251881Speter 463251881Speter/** 464251881Speter * Resolve peg revisions and operational revisions in the following way: 465251881Speter * 466251881Speter * - If @a is_url is set and @a peg_rev->kind is 467251881Speter * @c svn_opt_revision_unspecified, @a peg_rev->kind defaults to 468251881Speter * @c svn_opt_revision_head. 469251881Speter * 470251881Speter * - If @a is_url is not set, and @a peg_rev->kind is 471251881Speter * @c svn_opt_revision_unspecified, @a peg_rev->kind defaults to 472251881Speter * @c svn_opt_revision_base. 473251881Speter * 474251881Speter * - If @a op_rev->kind is @c svn_opt_revision_unspecified, @a op_rev 475251881Speter * defaults to @a peg_rev. 476251881Speter * 477251881Speter * Both @a peg_rev and @a op_rev may be modified as a result of this 478251881Speter * function. @a is_url should be set if the path the revisions refer to is 479251881Speter * a url, and unset otherwise. 480251881Speter * 481251881Speter * If @a notice_local_mods is set, @c svn_opt_revision_working is used, 482251881Speter * instead of @c svn_opt_revision_base. 483251881Speter * 484251881Speter * Use @a pool for allocations. 485251881Speter * 486251881Speter * @since New in 1.5. 487251881Speter */ 488251881Spetersvn_error_t * 489251881Spetersvn_opt_resolve_revisions(svn_opt_revision_t *peg_rev, 490251881Speter svn_opt_revision_t *op_rev, 491251881Speter svn_boolean_t is_url, 492251881Speter svn_boolean_t notice_local_mods, 493251881Speter apr_pool_t *pool); 494251881Speter 495251881Speter 496251881Speter/* Parsing arguments. */ 497251881Speter 498251881Speter/** 499251881Speter * Pull remaining target arguments from @a os into @a *targets_p, 500251881Speter * converting them to UTF-8, followed by targets from @a known_targets 501251881Speter * (which might come from, for example, the "--targets" command line 502251881Speter * option), which are already in UTF-8. 503251881Speter * 504251881Speter * On each URL target, do some IRI-to-URI encoding and some 505251881Speter * auto-escaping. On each local path, canonicalize case and path 506251881Speter * separators. 507251881Speter * 508251881Speter * Allocate @a *targets_p and its elements in @a pool. 509251881Speter * 510251881Speter * If a path has the same name as a Subversion working copy 511251881Speter * administrative directory, return SVN_ERR_RESERVED_FILENAME_SPECIFIED; 512251881Speter * if multiple reserved paths are encountered, return a chain of 513251881Speter * errors, all of which are SVN_ERR_RESERVED_FILENAME_SPECIFIED. Do 514251881Speter * not return this type of error in a chain with any other type of 515251881Speter * error, and if this is the only type of error encountered, complete 516251881Speter * the operation before returning the error(s). 517251881Speter * 518251881Speter * @deprecated Provided for backward compatibility with the 1.5 API. 519251881Speter * @see svn_client_args_to_target_array() 520251881Speter */ 521251881SpeterSVN_DEPRECATED 522251881Spetersvn_error_t * 523251881Spetersvn_opt_args_to_target_array3(apr_array_header_t **targets_p, 524251881Speter apr_getopt_t *os, 525251881Speter const apr_array_header_t *known_targets, 526251881Speter apr_pool_t *pool); 527251881Speter 528251881Speter/** 529251881Speter * This is the same as svn_opt_args_to_target_array3() except that it 530251881Speter * silently ignores paths that have the same name as a working copy 531251881Speter * administrative directory. 532251881Speter * 533251881Speter * @since New in 1.2. 534251881Speter * 535251881Speter * @deprecated Provided for backward compatibility with the 1.4 API. 536251881Speter */ 537251881SpeterSVN_DEPRECATED 538251881Spetersvn_error_t * 539251881Spetersvn_opt_args_to_target_array2(apr_array_header_t **targets_p, 540251881Speter apr_getopt_t *os, 541251881Speter const apr_array_header_t *known_targets, 542251881Speter apr_pool_t *pool); 543251881Speter 544251881Speter 545251881Speter/** 546251881Speter * The same as svn_opt_args_to_target_array2() except that, in 547251881Speter * addition, if @a extract_revisions is set, then look for trailing 548251881Speter * "@rev" syntax on the first two paths. If the first target in @a 549251881Speter * *targets_p ends in "@rev", replace it with a canonicalized version of 550251881Speter * the part before "@rev" and replace @a *start_revision with the value 551251881Speter * of "rev". If the second target in @a *targets_p ends in "@rev", 552251881Speter * replace it with a canonicalized version of the part before "@rev" 553251881Speter * and replace @a *end_revision with the value of "rev". Ignore 554251881Speter * revision specifiers on any further paths. "rev" can be any form of 555251881Speter * single revision specifier, as accepted by svn_opt_parse_revision(). 556251881Speter * 557251881Speter * @deprecated Provided for backward compatibility with the 1.1 API. 558251881Speter */ 559251881SpeterSVN_DEPRECATED 560251881Spetersvn_error_t * 561251881Spetersvn_opt_args_to_target_array(apr_array_header_t **targets_p, 562251881Speter apr_getopt_t *os, 563251881Speter const apr_array_header_t *known_targets, 564251881Speter svn_opt_revision_t *start_revision, 565251881Speter svn_opt_revision_t *end_revision, 566251881Speter svn_boolean_t extract_revisions, 567251881Speter apr_pool_t *pool); 568251881Speter 569251881Speter 570251881Speter/** 571251881Speter * Parse revprop key/value pair from @a revprop_spec (name[=value]) into 572251881Speter * @a revprops, making copies of both with @a pool. If @a revprops is 573251881Speter * @c NULL, allocate a new apr_hash_t in it. @a revprops maps 574251881Speter * const char * revprop names to svn_string_t * revprop values for use 575251881Speter * with svn_repos_get_commit_editor5 and other get_commit_editor APIs. 576251881Speter * 577251881Speter * @since New in 1.6. 578251881Speter */ 579251881Spetersvn_error_t * 580251881Spetersvn_opt_parse_revprop(apr_hash_t **revprops, const char *revprop_spec, 581251881Speter apr_pool_t *pool); 582251881Speter 583251881Speter 584251881Speter/** 585251881Speter * If no targets exist in @a *targets, add `.' as the lone target. 586251881Speter * 587251881Speter * (Some commands take an implicit "." string argument when invoked 588251881Speter * with no arguments. Those commands make use of this function to 589251881Speter * add "." to the target array if the user passes no args.) 590251881Speter */ 591251881Spetervoid 592251881Spetersvn_opt_push_implicit_dot_target(apr_array_header_t *targets, 593251881Speter apr_pool_t *pool); 594251881Speter 595251881Speter 596251881Speter/** 597251881Speter * Parse @a num_args non-target arguments from the list of arguments in 598251881Speter * @a os->argv, return them as <tt>const char *</tt> in @a *args_p, without 599251881Speter * doing any UTF-8 conversion. Allocate @a *args_p and its values in @a pool. 600251881Speter */ 601251881Spetersvn_error_t * 602251881Spetersvn_opt_parse_num_args(apr_array_header_t **args_p, 603251881Speter apr_getopt_t *os, 604251881Speter int num_args, 605251881Speter apr_pool_t *pool); 606251881Speter 607251881Speter 608251881Speter/** 609251881Speter * Parse all remaining arguments from @a os->argv, return them as 610251881Speter * <tt>const char *</tt> in @a *args_p, without doing any UTF-8 conversion. 611251881Speter * Allocate @a *args_p and its values in @a pool. 612251881Speter */ 613251881Spetersvn_error_t * 614251881Spetersvn_opt_parse_all_args(apr_array_header_t **args_p, 615251881Speter apr_getopt_t *os, 616251881Speter apr_pool_t *pool); 617251881Speter 618251881Speter/** 619251881Speter * Parse a working-copy path or URL in @a path, extracting any trailing 620251881Speter * revision specifier of the form "@rev" from the last component of 621251881Speter * the path. 622251881Speter * 623251881Speter * Some examples would be: 624251881Speter * 625251881Speter * - "foo/bar" -> "foo/bar", (unspecified) 626251881Speter * - "foo/bar@13" -> "foo/bar", (number, 13) 627251881Speter * - "foo/bar@HEAD" -> "foo/bar", (head) 628251881Speter * - "foo/bar@{1999-12-31}" -> "foo/bar", (date, 1999-12-31) 629251881Speter * - "http://a/b@27" -> "http://a/b", (number, 27) 630251881Speter * - "http://a/b@COMMITTED" -> "http://a/b", (committed) [*] 631251881Speter * - "http://a/b@{1999-12-31}" -> "http://a/b", (date, 1999-12-31) 632251881Speter * - "http://a/b@%7B1999-12-31%7D" -> "http://a/b", (date, 1999-12-31) 633251881Speter * - "foo/bar@1:2" -> error 634251881Speter * - "foo/bar@baz" -> error 635251881Speter * - "foo/bar@" -> "foo/bar", (unspecified) 636251881Speter * - "foo/@bar@" -> "foo/@bar", (unspecified) 637251881Speter * - "foo/bar/@13" -> "foo/bar/", (number, 13) 638251881Speter * - "foo/bar@@13" -> "foo/bar@", (number, 13) 639251881Speter * - "foo/@bar@HEAD" -> "foo/@bar", (head) 640251881Speter * - "foo@/bar" -> "foo@/bar", (unspecified) 641251881Speter * - "foo@HEAD/bar" -> "foo@HEAD/bar", (unspecified) 642251881Speter * - "@foo/bar" -> "@foo/bar", (unspecified) 643251881Speter * - "@foo/bar@" -> "@foo/bar", (unspecified) 644251881Speter * 645251881Speter * [*] Syntactically valid but probably not semantically useful. 646251881Speter * 647251881Speter * If a trailing revision specifier is found, parse it into @a *rev and 648251881Speter * put the rest of the path into @a *truepath, allocating from @a pool; 649251881Speter * or return an @c SVN_ERR_CL_ARG_PARSING_ERROR (with the effect on 650251881Speter * @a *truepath undefined) if the revision specifier is invalid. 651251881Speter * If no trailing revision specifier is found, set @a *truepath to 652251881Speter * @a path and @a rev->kind to @c svn_opt_revision_unspecified. 653251881Speter * 654251881Speter * This function does not require that @a path be in canonical form. 655251881Speter * No canonicalization is done and @a *truepath will only be in 656251881Speter * canonical form if @a path is in canonical form. 657251881Speter * 658251881Speter * @since New in 1.1. 659251881Speter */ 660251881Spetersvn_error_t * 661251881Spetersvn_opt_parse_path(svn_opt_revision_t *rev, 662251881Speter const char **truepath, 663251881Speter const char *path, 664251881Speter apr_pool_t *pool); 665251881Speter 666251881Speter/** 667251881Speter * Central dispatcher function for various kinds of help message. 668251881Speter * Prints one of: 669251881Speter * * subcommand-specific help (svn_opt_subcommand_help) 670251881Speter * * generic help (svn_opt_print_generic_help) 671251881Speter * * version info 672251881Speter * * simple usage complaint: "Type '@a pgm_name help' for usage." 673251881Speter * 674251881Speter * If @a os is not @c NULL and it contains arguments, then try 675251881Speter * printing help for them as though they are subcommands, using @a 676251881Speter * cmd_table and @a option_table for option information. If not @c 677251881Speter * NULL, @a global_options is a zero-terminated array of options taken 678251881Speter * by all subcommands. 679251881Speter * 680251881Speter * Else, if @a print_version is TRUE, then print version info, in 681251881Speter * brief form if @a quiet is also TRUE; if @a quiet is FALSE, then if 682251881Speter * @a version_footer is non-NULL, print it following the version 683251881Speter * information. If @a verbose is TRUE, also print information about 684251881Speter * the running system and loaded shared libraries, where available. 685251881Speter * 686251881Speter * Else, if @a os is not @c NULL and does not contain arguments, print 687251881Speter * generic help, via svn_opt_print_generic_help2() with the @a header, 688251881Speter * @a cmd_table, @a option_table, and @a footer arguments. 689251881Speter * 690251881Speter * Else, when @a os is @c NULL, print the simple usage complaint. 691251881Speter * 692251881Speter * Use @a pool for temporary allocations. 693251881Speter * 694251881Speter * Notes: The reason this function handles both version printing and 695251881Speter * general usage help is that a confused user might put both the 696251881Speter * --version flag *and* subcommand arguments on a help command line. 697251881Speter * The logic for handling such a situation should be in one place. 698251881Speter * 699251881Speter * @since New in 1.8. 700251881Speter */ 701251881Speter 702251881Spetersvn_error_t * 703251881Spetersvn_opt_print_help4(apr_getopt_t *os, 704251881Speter const char *pgm_name, 705251881Speter svn_boolean_t print_version, 706251881Speter svn_boolean_t quiet, 707251881Speter svn_boolean_t verbose, 708251881Speter const char *version_footer, 709251881Speter const char *header, 710251881Speter const svn_opt_subcommand_desc2_t *cmd_table, 711251881Speter const apr_getopt_option_t *option_table, 712251881Speter const int *global_options, 713251881Speter const char *footer, 714251881Speter apr_pool_t *pool); 715251881Speter 716251881Speter/** 717251881Speter * Same as svn_opt_print_help4(), but with @a verbose always @c FALSE. 718251881Speter * 719251881Speter * @deprecated Provided for backward compatibility with the 1.7 API. 720251881Speter */ 721251881Speter 722251881SpeterSVN_DEPRECATED 723251881Spetersvn_error_t * 724251881Spetersvn_opt_print_help3(apr_getopt_t *os, 725251881Speter const char *pgm_name, 726251881Speter svn_boolean_t print_version, 727251881Speter svn_boolean_t quiet, 728251881Speter const char *version_footer, 729251881Speter const char *header, 730251881Speter const svn_opt_subcommand_desc2_t *cmd_table, 731251881Speter const apr_getopt_option_t *option_table, 732251881Speter const int *global_options, 733251881Speter const char *footer, 734251881Speter apr_pool_t *pool); 735251881Speter 736251881Speter/** 737251881Speter * Same as svn_opt_print_help3(), but with @a global_options always @c 738251881Speter * NULL. 739251881Speter * 740251881Speter * @deprecated Provided for backward compatibility with the 1.4 API. 741251881Speter */ 742251881Speter 743251881SpeterSVN_DEPRECATED 744251881Spetersvn_error_t * 745251881Spetersvn_opt_print_help2(apr_getopt_t *os, 746251881Speter const char *pgm_name, 747251881Speter svn_boolean_t print_version, 748251881Speter svn_boolean_t quiet, 749251881Speter const char *version_footer, 750251881Speter const char *header, 751251881Speter const svn_opt_subcommand_desc2_t *cmd_table, 752251881Speter const apr_getopt_option_t *option_table, 753251881Speter const char *footer, 754251881Speter apr_pool_t *pool); 755251881Speter 756251881Speter 757251881Speter/** 758251881Speter * Same as svn_opt_print_help2(), but acts on #svn_opt_subcommand_desc_t. 759251881Speter * 760251881Speter * @deprecated Provided for backward compatibility with the 1.3 API. 761251881Speter */ 762251881SpeterSVN_DEPRECATED 763251881Spetersvn_error_t * 764251881Spetersvn_opt_print_help(apr_getopt_t *os, 765251881Speter const char *pgm_name, 766251881Speter svn_boolean_t print_version, 767251881Speter svn_boolean_t quiet, 768251881Speter const char *version_footer, 769251881Speter const char *header, 770251881Speter const svn_opt_subcommand_desc_t *cmd_table, 771251881Speter const apr_getopt_option_t *option_table, 772251881Speter const char *footer, 773251881Speter apr_pool_t *pool); 774251881Speter 775251881Speter#ifdef __cplusplus 776251881Speter} 777251881Speter#endif /* __cplusplus */ 778251881Speter 779251881Speter#endif /* SVN_OPTS_H */ 780