00001 /** 00002 * @copyright 00003 * ==================================================================== 00004 * Licensed to the Apache Software Foundation (ASF) under one 00005 * or more contributor license agreements. See the NOTICE file 00006 * distributed with this work for additional information 00007 * regarding copyright ownership. The ASF licenses this file 00008 * to you under the Apache License, Version 2.0 (the 00009 * "License"); you may not use this file except in compliance 00010 * with the License. You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, 00015 * software distributed under the License is distributed on an 00016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 00017 * KIND, either express or implied. See the License for the 00018 * specific language governing permissions and limitations 00019 * under the License. 00020 * ==================================================================== 00021 * @endcopyright 00022 * 00023 * @file svn_opt.h 00024 * @brief Option and argument parsing for Subversion command lines 00025 */ 00026 00027 #ifndef SVN_OPT_H 00028 #define SVN_OPT_H 00029 00030 #include <apr.h> 00031 #include <apr_pools.h> 00032 #include <apr_getopt.h> 00033 #include <apr_tables.h> 00034 #include <apr_hash.h> 00035 00036 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00037 #define APR_WANT_STDIO 00038 #endif 00039 #include <apr_want.h> /* for FILE* */ 00040 00041 #include "svn_types.h" 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif /* __cplusplus */ 00046 00047 00048 00049 /** 00050 * All subcommand procedures in Subversion conform to this prototype. 00051 * 00052 * @a os is the apr option state after getopt processing has been run; in 00053 * other words, it still contains the non-option arguments following 00054 * the subcommand. See @a os->argv and @a os->ind. 00055 * 00056 * @a baton is anything you need it to be. 00057 * 00058 * @a pool is used for allocating errors, and for any other allocation 00059 * unless the instance is explicitly documented to allocate from a 00060 * pool in @a baton. 00061 */ 00062 typedef svn_error_t *(svn_opt_subcommand_t)( 00063 apr_getopt_t *os, void *baton, apr_pool_t *pool); 00064 00065 00066 /** The maximum number of aliases a subcommand can have. */ 00067 #define SVN_OPT_MAX_ALIASES 3 00068 00069 /** The maximum number of options that can be accepted by a subcommand. */ 00070 #define SVN_OPT_MAX_OPTIONS 50 00071 00072 /** The maximum number of paragraphs of help text a subcommand can have. 00073 * @since New in 1.11. */ 00074 #define SVN_OPT_MAX_PARAGRAPHS 100 00075 00076 /** Options that have no short option char should use an identifying 00077 * integer equal to or greater than this. 00078 */ 00079 #define SVN_OPT_FIRST_LONGOPT_ID 256 00080 00081 00082 /** One element of a subcommand dispatch table. 00083 * 00084 * @since New in 1.11. 00085 */ 00086 typedef struct svn_opt_subcommand_desc3_t 00087 { 00088 /** The full name of this command. */ 00089 const char *name; 00090 00091 /** The function this command invokes. */ 00092 svn_opt_subcommand_t *cmd_func; 00093 00094 /** A list of alias names for this command (e.g., 'up' for 'update'). */ 00095 const char *aliases[SVN_OPT_MAX_ALIASES]; 00096 00097 /** A multi-paragraph string describing this command. */ 00098 const char *help[SVN_OPT_MAX_PARAGRAPHS]; 00099 00100 /** A list of options accepted by this command. Each value in the 00101 * array is a unique enum (the 2nd field in apr_getopt_option_t) 00102 */ 00103 int valid_options[SVN_OPT_MAX_OPTIONS]; 00104 00105 /** A list of option help descriptions, keyed by the option unique enum 00106 * (the 2nd field in apr_getopt_option_t), which override the generic 00107 * descriptions given in an apr_getopt_option_t on a per-subcommand basis. 00108 */ 00109 struct { int optch; const char *desc; } desc_overrides[SVN_OPT_MAX_OPTIONS]; 00110 } svn_opt_subcommand_desc3_t; 00111 00112 00113 /** One element of a subcommand dispatch table. 00114 * 00115 * @since New in 1.4. 00116 * @deprecated Provided for backward compatibility with the 1.10 API. 00117 */ 00118 typedef struct svn_opt_subcommand_desc2_t 00119 { 00120 /** The full name of this command. */ 00121 const char *name; 00122 00123 /** The function this command invokes. */ 00124 svn_opt_subcommand_t *cmd_func; 00125 00126 /** A list of alias names for this command (e.g., 'up' for 'update'). */ 00127 const char *aliases[SVN_OPT_MAX_ALIASES]; 00128 00129 /** A brief string describing this command, for usage messages. */ 00130 const char *help; 00131 00132 /** A list of options accepted by this command. Each value in the 00133 * array is a unique enum (the 2nd field in apr_getopt_option_t) 00134 */ 00135 int valid_options[SVN_OPT_MAX_OPTIONS]; 00136 00137 /** A list of option help descriptions, keyed by the option unique enum 00138 * (the 2nd field in apr_getopt_option_t), which override the generic 00139 * descriptions given in an apr_getopt_option_t on a per-subcommand basis. 00140 */ 00141 struct { int optch; const char *desc; } desc_overrides[SVN_OPT_MAX_OPTIONS]; 00142 } svn_opt_subcommand_desc2_t; 00143 00144 00145 /** One element of a subcommand dispatch table. 00146 * 00147 * @deprecated Provided for backward compatibility with the 1.3 API. 00148 * 00149 * Like #svn_opt_subcommand_desc2_t but lacking the @c desc_overrides 00150 * member. 00151 */ 00152 typedef struct svn_opt_subcommand_desc_t 00153 { 00154 /** The full name of this command. */ 00155 const char *name; 00156 00157 /** The function this command invokes. */ 00158 svn_opt_subcommand_t *cmd_func; 00159 00160 /** A list of alias names for this command (e.g., 'up' for 'update'). */ 00161 const char *aliases[SVN_OPT_MAX_ALIASES]; 00162 00163 /** A brief string describing this command, for usage messages. */ 00164 const char *help; 00165 00166 /** A list of options accepted by this command. Each value in the 00167 * array is a unique enum (the 2nd field in apr_getopt_option_t) 00168 */ 00169 int valid_options[SVN_OPT_MAX_OPTIONS]; 00170 00171 } svn_opt_subcommand_desc_t; 00172 00173 00174 /** 00175 * Return the entry in @a table whose name matches @a cmd_name, or @c NULL if 00176 * none. @a cmd_name may be an alias. 00177 * 00178 * @since New in 1.11. 00179 */ 00180 const svn_opt_subcommand_desc3_t * 00181 svn_opt_get_canonical_subcommand3(const svn_opt_subcommand_desc3_t *table, 00182 const char *cmd_name); 00183 00184 00185 /** 00186 * Same as svn_opt_get_canonical_subcommand3(), but with a different 00187 * version of the subcommand description table. 00188 * 00189 * @since New in 1.4. 00190 * @deprecated Provided for backward compatibility with the 1.10 API. 00191 */ 00192 SVN_DEPRECATED 00193 const svn_opt_subcommand_desc2_t * 00194 svn_opt_get_canonical_subcommand2(const svn_opt_subcommand_desc2_t *table, 00195 const char *cmd_name); 00196 00197 00198 /** 00199 * Return the entry in @a table whose name matches @a cmd_name, or @c NULL if 00200 * none. @a cmd_name may be an alias. 00201 * 00202 * Same as svn_opt_get_canonical_subcommand2(), but acts on 00203 * #svn_opt_subcommand_desc_t. 00204 * 00205 * @deprecated Provided for backward compatibility with the 1.3 API. 00206 */ 00207 SVN_DEPRECATED 00208 const svn_opt_subcommand_desc_t * 00209 svn_opt_get_canonical_subcommand(const svn_opt_subcommand_desc_t *table, 00210 const char *cmd_name); 00211 00212 00213 /** 00214 * Return pointer to an @c apr_getopt_option_t for the option whose 00215 * option code is @a code, or @c NULL if no match. @a option_table must end 00216 * with an element whose every field is zero. If @a command is non-NULL, 00217 * then return the subcommand-specific option description instead of the 00218 * generic one, if a specific description is defined. 00219 * 00220 * The returned value may be statically allocated, or allocated in @a pool. 00221 * 00222 * @since New in 1.11. 00223 */ 00224 const apr_getopt_option_t * 00225 svn_opt_get_option_from_code3(int code, 00226 const apr_getopt_option_t *option_table, 00227 const svn_opt_subcommand_desc3_t *command, 00228 apr_pool_t *pool); 00229 00230 /** 00231 * Same as svn_opt_get_option_from_code3(), but with a different 00232 * version of the subcommand description table. 00233 * 00234 * @since New in 1.4. 00235 * @deprecated Provided for backward compatibility with the 1.10 API. 00236 */ 00237 SVN_DEPRECATED 00238 const apr_getopt_option_t * 00239 svn_opt_get_option_from_code2(int code, 00240 const apr_getopt_option_t *option_table, 00241 const svn_opt_subcommand_desc2_t *command, 00242 apr_pool_t *pool); 00243 00244 00245 /** 00246 * Return the first entry from @a option_table whose option code is @a code, 00247 * or @c NULL if no match. @a option_table must end with an element whose 00248 * every field is zero. 00249 * 00250 * @deprecated Provided for backward compatibility with the 1.3 API. 00251 */ 00252 SVN_DEPRECATED 00253 const apr_getopt_option_t * 00254 svn_opt_get_option_from_code(int code, 00255 const apr_getopt_option_t *option_table); 00256 00257 00258 /** 00259 * Return @c TRUE iff subcommand @a command supports option @a 00260 * option_code, else return @c FALSE. If @a global_options is 00261 * non-NULL, it is a zero-terminated array, and all subcommands take 00262 * the options listed in it. 00263 * 00264 * @since New in 1.11. 00265 */ 00266 svn_boolean_t 00267 svn_opt_subcommand_takes_option4(const svn_opt_subcommand_desc3_t *command, 00268 int option_code, 00269 const int *global_options); 00270 00271 /** 00272 * Same as svn_opt_subcommand_takes_option4(), but with a different 00273 * version of the subcommand description table. 00274 * 00275 * @since New in 1.5. 00276 * @deprecated Provided for backward compatibility with the 1.10 API. 00277 */ 00278 SVN_DEPRECATED 00279 svn_boolean_t 00280 svn_opt_subcommand_takes_option3(const svn_opt_subcommand_desc2_t *command, 00281 int option_code, 00282 const int *global_options); 00283 00284 /** 00285 * Same as svn_opt_subcommand_takes_option3(), but with @c NULL for @a 00286 * global_options. 00287 * 00288 * @deprecated Provided for backward compatibility with the 1.4 API. 00289 */ 00290 SVN_DEPRECATED 00291 svn_boolean_t 00292 svn_opt_subcommand_takes_option2(const svn_opt_subcommand_desc2_t *command, 00293 int option_code); 00294 00295 00296 /** 00297 * Return @c TRUE iff subcommand @a command supports option @a option_code, 00298 * else return @c FALSE. 00299 * 00300 * Same as svn_opt_subcommand_takes_option2(), but acts on 00301 * #svn_opt_subcommand_desc_t. 00302 * 00303 * @deprecated Provided for backward compatibility with the 1.3 API. 00304 */ 00305 SVN_DEPRECATED 00306 svn_boolean_t 00307 svn_opt_subcommand_takes_option(const svn_opt_subcommand_desc_t *command, 00308 int option_code); 00309 00310 00311 /** 00312 * Print a generic (not command-specific) usage message to @a stream. 00313 * 00314 * @todo Why is @a stream a stdio file instead of an svn stream? 00315 * 00316 * If @a header is non-NULL, print @a header followed by a newline. Then 00317 * loop over @a cmd_table printing the usage for each command (getting 00318 * option usages from @a opt_table). Then if @a footer is non-NULL, print 00319 * @a footer followed by a newline. 00320 * 00321 * Use @a pool for temporary allocation. 00322 * 00323 * @since New in 1.11. 00324 */ 00325 void 00326 svn_opt_print_generic_help3(const char *header, 00327 const svn_opt_subcommand_desc3_t *cmd_table, 00328 const apr_getopt_option_t *opt_table, 00329 const char *footer, 00330 apr_pool_t *pool, 00331 FILE *stream); 00332 00333 /** 00334 * Same as svn_opt_print_generic_help3(), but with a different 00335 * version of the subcommand description table. 00336 * 00337 * @since New in 1.4. 00338 * @deprecated Provided for backward compatibility with the 1.10 API. 00339 */ 00340 SVN_DEPRECATED 00341 void 00342 svn_opt_print_generic_help2(const char *header, 00343 const svn_opt_subcommand_desc2_t *cmd_table, 00344 const apr_getopt_option_t *opt_table, 00345 const char *footer, 00346 apr_pool_t *pool, 00347 FILE *stream); 00348 00349 00350 /** 00351 * Same as svn_opt_print_generic_help2(), but acts on 00352 * #svn_opt_subcommand_desc_t. 00353 * 00354 * @deprecated Provided for backward compatibility with the 1.3 API. 00355 */ 00356 SVN_DEPRECATED 00357 void 00358 svn_opt_print_generic_help(const char *header, 00359 const svn_opt_subcommand_desc_t *cmd_table, 00360 const apr_getopt_option_t *opt_table, 00361 const char *footer, 00362 apr_pool_t *pool, 00363 FILE *stream); 00364 00365 00366 /** 00367 * Print an option @a opt nicely into a @a string allocated in @a pool. 00368 * If @a doc is set, include the generic documentation string of @a opt, 00369 * localized to the current locale if a translation is available. 00370 */ 00371 void 00372 svn_opt_format_option(const char **string, 00373 const apr_getopt_option_t *opt, 00374 svn_boolean_t doc, 00375 apr_pool_t *pool); 00376 00377 00378 00379 /** 00380 * Get @a subcommand's usage from @a table, and print it to @c stdout. 00381 * Obtain option usage from @a options_table. If not @c NULL, @a 00382 * global_options is a zero-terminated list of global options. Use @a 00383 * pool for temporary allocation. @a subcommand may be a canonical 00384 * command name or an alias. ### @todo Why does this only print to 00385 * @c stdout, whereas svn_opt_print_generic_help() gives us a choice? 00386 * 00387 * When printing the description of an option, if the same option code 00388 * appears a second time in @a options_table with a different name, then 00389 * use that second name as an alias for the first name. This additional 00390 * behaviour is new in 1.7. 00391 * 00392 * @since New in 1.11. 00393 */ 00394 void 00395 svn_opt_subcommand_help4(const char *subcommand, 00396 const svn_opt_subcommand_desc3_t *table, 00397 const apr_getopt_option_t *options_table, 00398 const int *global_options, 00399 apr_pool_t *pool); 00400 00401 /** 00402 * Same as svn_opt_subcommand_help4(), but with a different 00403 * version of the subcommand description table. 00404 * 00405 * @since New in 1.5. 00406 * @deprecated Provided for backward compatibility with the 1.10 API. 00407 */ 00408 SVN_DEPRECATED 00409 void 00410 svn_opt_subcommand_help3(const char *subcommand, 00411 const svn_opt_subcommand_desc2_t *table, 00412 const apr_getopt_option_t *options_table, 00413 const int *global_options, 00414 apr_pool_t *pool); 00415 00416 /** 00417 * Same as svn_opt_subcommand_help3(), but with @a global_options 00418 * always NULL. 00419 * 00420 * @deprecated Provided for backward compatibility with the 1.4 API. 00421 */ 00422 SVN_DEPRECATED 00423 void 00424 svn_opt_subcommand_help2(const char *subcommand, 00425 const svn_opt_subcommand_desc2_t *table, 00426 const apr_getopt_option_t *options_table, 00427 apr_pool_t *pool); 00428 00429 00430 /** 00431 * Same as svn_opt_subcommand_help2(), but acts on 00432 * #svn_opt_subcommand_desc_t. 00433 * 00434 * @deprecated Provided for backward compatibility with the 1.3 API. 00435 */ 00436 SVN_DEPRECATED 00437 void 00438 svn_opt_subcommand_help(const char *subcommand, 00439 const svn_opt_subcommand_desc_t *table, 00440 const apr_getopt_option_t *options_table, 00441 apr_pool_t *pool); 00442 00443 00444 00445 /* Parsing revision and date options. */ 00446 00447 /** 00448 * Various ways of specifying revisions. 00449 * 00450 * @note 00451 * In contexts where local mods are relevant, the `working' kind 00452 * refers to the uncommitted "working" revision, which may be modified 00453 * with respect to its base revision. In other contexts, `working' 00454 * should behave the same as `committed' or `current'. 00455 */ 00456 enum svn_opt_revision_kind { 00457 /** No revision information given. */ 00458 svn_opt_revision_unspecified, 00459 00460 /** revision given as number */ 00461 svn_opt_revision_number, 00462 00463 /** revision given as date */ 00464 svn_opt_revision_date, 00465 00466 /** rev of most recent change */ 00467 svn_opt_revision_committed, 00468 00469 /** (rev of most recent change) - 1 */ 00470 svn_opt_revision_previous, 00471 00472 /** .svn/entries current revision */ 00473 svn_opt_revision_base, 00474 00475 /** current, plus local mods */ 00476 svn_opt_revision_working, 00477 00478 /** repository youngest */ 00479 svn_opt_revision_head 00480 00481 /* please update svn_opt__revision_to_string() when extending this enum */ 00482 }; 00483 00484 /** 00485 * A revision value, which can be specified as a number or a date. 00486 * 00487 * @note This union was formerly an anonymous inline type in 00488 * @c svn_opt_revision_t, and was converted to a named type just to 00489 * make things easier for SWIG. 00490 * 00491 * @since New in 1.3. 00492 */ 00493 typedef union svn_opt_revision_value_t 00494 { 00495 /** The revision number */ 00496 svn_revnum_t number; 00497 00498 /** the date of the revision */ 00499 apr_time_t date; 00500 } svn_opt_revision_value_t; 00501 00502 /** A revision, specified in one of @c svn_opt_revision_kind ways. */ 00503 typedef struct svn_opt_revision_t 00504 { 00505 enum svn_opt_revision_kind kind; /**< See svn_opt_revision_kind */ 00506 svn_opt_revision_value_t value; /**< Extra data qualifying the @c kind */ 00507 } svn_opt_revision_t; 00508 00509 /** A revision range, specified in one of @c svn_opt_revision_kind ways. */ 00510 typedef struct svn_opt_revision_range_t 00511 { 00512 /** The first revision in the range */ 00513 svn_opt_revision_t start; 00514 00515 /** The last revision in the range */ 00516 svn_opt_revision_t end; 00517 } svn_opt_revision_range_t; 00518 00519 /** 00520 * Set @a *start_revision and/or @a *end_revision according to @a arg, 00521 * where @a arg is "N" or "N:M", like so: 00522 * 00523 * - If @a arg is "N", set @a *start_revision to represent N, and 00524 * leave @a *end_revision untouched. 00525 * 00526 * - If @a arg is "N:M", set @a *start_revision and @a *end_revision 00527 * to represent N and M respectively. 00528 * 00529 * N and/or M may be one of the special revision descriptors 00530 * recognized by revision_from_word(), or a date in curly braces. 00531 * 00532 * If @a arg is invalid, return -1; else return 0. 00533 * It is invalid to omit a revision (as in, ":", "N:" or ":M"). 00534 * 00535 * @note It is typical, though not required, for @a *start_revision and 00536 * @a *end_revision to be @c svn_opt_revision_unspecified kind on entry. 00537 * 00538 * Use @a pool for temporary allocations. 00539 */ 00540 int 00541 svn_opt_parse_revision(svn_opt_revision_t *start_revision, 00542 svn_opt_revision_t *end_revision, 00543 const char *arg, 00544 apr_pool_t *pool); 00545 00546 /** 00547 * Parse @a arg, where @a arg is "N" or "N:M", into a 00548 * @c svn_opt_revision_range_t and push that onto @a opt_ranges. 00549 * 00550 * - If @a arg is "N", set the @c start field of the 00551 * @c svn_opt_revision_range_t to represent N and the @c end field 00552 * to @c svn_opt_revision_unspecified. 00553 * 00554 * - If @a arg is "N:M", set the @c start field of the 00555 * @c svn_opt_revision_range_t to represent N and the @c end field 00556 * to represent M. 00557 * 00558 * If @a arg is invalid, return -1; else return 0. It is invalid to omit 00559 * a revision (as in, ":", "N:" or ":M"). 00560 * 00561 * Use @a pool to allocate @c svn_opt_revision_range_t pushed to the array. 00562 * 00563 * @since New in 1.5. 00564 */ 00565 int 00566 svn_opt_parse_revision_to_range(apr_array_header_t *opt_ranges, 00567 const char *arg, 00568 apr_pool_t *pool); 00569 00570 /** 00571 * Resolve peg revisions and operational revisions in the following way: 00572 * 00573 * - If @a is_url is set and @a peg_rev->kind is 00574 * @c svn_opt_revision_unspecified, @a peg_rev->kind defaults to 00575 * @c svn_opt_revision_head. 00576 * 00577 * - If @a is_url is not set, and @a peg_rev->kind is 00578 * @c svn_opt_revision_unspecified, @a peg_rev->kind defaults to 00579 * @c svn_opt_revision_base. 00580 * 00581 * - If @a op_rev->kind is @c svn_opt_revision_unspecified, @a op_rev 00582 * defaults to @a peg_rev. 00583 * 00584 * Both @a peg_rev and @a op_rev may be modified as a result of this 00585 * function. @a is_url should be set if the path the revisions refer to is 00586 * a url, and unset otherwise. 00587 * 00588 * If @a notice_local_mods is set, @c svn_opt_revision_working is used, 00589 * instead of @c svn_opt_revision_base. 00590 * 00591 * Use @a pool for allocations. 00592 * 00593 * @since New in 1.5. 00594 */ 00595 svn_error_t * 00596 svn_opt_resolve_revisions(svn_opt_revision_t *peg_rev, 00597 svn_opt_revision_t *op_rev, 00598 svn_boolean_t is_url, 00599 svn_boolean_t notice_local_mods, 00600 apr_pool_t *pool); 00601 00602 00603 /* Parsing arguments. */ 00604 00605 /** 00606 * Pull remaining target arguments from @a os into @a *targets_p, 00607 * converting them to UTF-8, followed by targets from @a known_targets 00608 * (which might come from, for example, the "--targets" command line 00609 * option), which are already in UTF-8. 00610 * 00611 * On each URL target, do some IRI-to-URI encoding and some 00612 * auto-escaping. On each local path, canonicalize case and path 00613 * separators. 00614 * 00615 * Allocate @a *targets_p and its elements in @a pool. 00616 * 00617 * If a path has the same name as a Subversion working copy 00618 * administrative directory, return SVN_ERR_RESERVED_FILENAME_SPECIFIED; 00619 * if multiple reserved paths are encountered, return a chain of 00620 * errors, all of which are SVN_ERR_RESERVED_FILENAME_SPECIFIED. Do 00621 * not return this type of error in a chain with any other type of 00622 * error, and if this is the only type of error encountered, complete 00623 * the operation before returning the error(s). 00624 * 00625 * @deprecated Provided for backward compatibility with the 1.5 API. 00626 * @see svn_client_args_to_target_array() 00627 */ 00628 SVN_DEPRECATED 00629 svn_error_t * 00630 svn_opt_args_to_target_array3(apr_array_header_t **targets_p, 00631 apr_getopt_t *os, 00632 const apr_array_header_t *known_targets, 00633 apr_pool_t *pool); 00634 00635 /** 00636 * This is the same as svn_opt_args_to_target_array3() except that it 00637 * silently ignores paths that have the same name as a working copy 00638 * administrative directory. 00639 * 00640 * @since New in 1.2. 00641 * 00642 * @deprecated Provided for backward compatibility with the 1.4 API. 00643 */ 00644 SVN_DEPRECATED 00645 svn_error_t * 00646 svn_opt_args_to_target_array2(apr_array_header_t **targets_p, 00647 apr_getopt_t *os, 00648 const apr_array_header_t *known_targets, 00649 apr_pool_t *pool); 00650 00651 00652 /** 00653 * The same as svn_opt_args_to_target_array2() except that, in 00654 * addition, if @a extract_revisions is set, then look for trailing 00655 * "@rev" syntax on the first two paths. If the first target in @a 00656 * *targets_p ends in "@rev", replace it with a canonicalized version of 00657 * the part before "@rev" and replace @a *start_revision with the value 00658 * of "rev". If the second target in @a *targets_p ends in "@rev", 00659 * replace it with a canonicalized version of the part before "@rev" 00660 * and replace @a *end_revision with the value of "rev". Ignore 00661 * revision specifiers on any further paths. "rev" can be any form of 00662 * single revision specifier, as accepted by svn_opt_parse_revision(). 00663 * 00664 * @deprecated Provided for backward compatibility with the 1.1 API. 00665 */ 00666 SVN_DEPRECATED 00667 svn_error_t * 00668 svn_opt_args_to_target_array(apr_array_header_t **targets_p, 00669 apr_getopt_t *os, 00670 const apr_array_header_t *known_targets, 00671 svn_opt_revision_t *start_revision, 00672 svn_opt_revision_t *end_revision, 00673 svn_boolean_t extract_revisions, 00674 apr_pool_t *pool); 00675 00676 00677 /** 00678 * Parse revprop key/value pair from @a revprop_spec (name[=value]) into 00679 * @a revprops, making copies of both with @a pool. If @a revprops is 00680 * @c NULL, allocate a new apr_hash_t in it. @a revprops maps 00681 * const char * revprop names to svn_string_t * revprop values for use 00682 * with svn_repos_get_commit_editor5 and other get_commit_editor APIs. 00683 * 00684 * @since New in 1.6. 00685 */ 00686 svn_error_t * 00687 svn_opt_parse_revprop(apr_hash_t **revprops, const char *revprop_spec, 00688 apr_pool_t *pool); 00689 00690 00691 /** 00692 * If no targets exist in @a *targets, add `.' as the lone target. 00693 * 00694 * (Some commands take an implicit "." string argument when invoked 00695 * with no arguments. Those commands make use of this function to 00696 * add "." to the target array if the user passes no args.) 00697 */ 00698 void 00699 svn_opt_push_implicit_dot_target(apr_array_header_t *targets, 00700 apr_pool_t *pool); 00701 00702 00703 /** 00704 * Parse @a num_args non-target arguments from the list of arguments in 00705 * @a os->argv, return them as <tt>const char *</tt> in @a *args_p, without 00706 * doing any UTF-8 conversion. Allocate @a *args_p and its values in @a pool. 00707 */ 00708 svn_error_t * 00709 svn_opt_parse_num_args(apr_array_header_t **args_p, 00710 apr_getopt_t *os, 00711 int num_args, 00712 apr_pool_t *pool); 00713 00714 00715 /** 00716 * Parse all remaining arguments from @a os->argv, return them as 00717 * <tt>const char *</tt> in @a *args_p, without doing any UTF-8 conversion. 00718 * Allocate @a *args_p and its values in @a pool. 00719 */ 00720 svn_error_t * 00721 svn_opt_parse_all_args(apr_array_header_t **args_p, 00722 apr_getopt_t *os, 00723 apr_pool_t *pool); 00724 00725 /** 00726 * Parse a working-copy path or URL in @a path, extracting any trailing 00727 * revision specifier of the form "@rev" from the last component of 00728 * the path. 00729 * 00730 * Some examples would be: 00731 * 00732 * - "foo/bar" -> "foo/bar", (unspecified) 00733 * - "foo/bar@13" -> "foo/bar", (number, 13) 00734 * - "foo/bar@HEAD" -> "foo/bar", (head) 00735 * - "foo/bar@{1999-12-31}" -> "foo/bar", (date, 1999-12-31) 00736 * - "http://a/b@27" -> "http://a/b", (number, 27) 00737 * - "http://a/b@COMMITTED" -> "http://a/b", (committed) [*] 00738 * - "http://a/b@{1999-12-31}" -> "http://a/b", (date, 1999-12-31) 00739 * - "http://a/b@%7B1999-12-31%7D" -> "http://a/b", (date, 1999-12-31) 00740 * - "foo/bar@1:2" -> error 00741 * - "foo/bar@baz" -> error 00742 * - "foo/bar@" -> "foo/bar", (unspecified) 00743 * - "foo/@bar@" -> "foo/@bar", (unspecified) 00744 * - "foo/bar/@13" -> "foo/bar/", (number, 13) 00745 * - "foo/bar@@13" -> "foo/bar@", (number, 13) 00746 * - "foo/@bar@HEAD" -> "foo/@bar", (head) 00747 * - "foo@/bar" -> "foo@/bar", (unspecified) 00748 * - "foo@HEAD/bar" -> "foo@HEAD/bar", (unspecified) 00749 * - "@foo/bar" -> "@foo/bar", (unspecified) 00750 * - "@foo/bar@" -> "@foo/bar", (unspecified) 00751 * 00752 * [*] Syntactically valid but probably not semantically useful. 00753 * 00754 * If a trailing revision specifier is found, parse it into @a *rev and 00755 * put the rest of the path into @a *truepath, allocating from @a pool; 00756 * or return an @c SVN_ERR_CL_ARG_PARSING_ERROR (with the effect on 00757 * @a *truepath undefined) if the revision specifier is invalid. 00758 * If no trailing revision specifier is found, set @a *truepath to 00759 * @a path and @a rev->kind to @c svn_opt_revision_unspecified. 00760 * 00761 * This function does not require that @a path be in canonical form. 00762 * No canonicalization is done and @a *truepath will only be in 00763 * canonical form if @a path is in canonical form. 00764 * 00765 * @since New in 1.1. 00766 * @since Since 1.6.5, this returns an error if @a path contains a peg 00767 * specifier with no path before it, such as "@abc". 00768 * @since Since 1.9.0, this no longer returns an error if @a path contains a peg 00769 * specifier with no path before it, such as "@abc". 00770 */ 00771 svn_error_t * 00772 svn_opt_parse_path(svn_opt_revision_t *rev, 00773 const char **truepath, 00774 const char *path, 00775 apr_pool_t *pool); 00776 00777 /** 00778 * Central dispatcher function for various kinds of help message. 00779 * Prints one of: 00780 * * subcommand-specific help (svn_opt_subcommand_help) 00781 * * generic help (svn_opt_print_generic_help) 00782 * * version info 00783 * * simple usage complaint: "Type '@a pgm_name help' for usage." 00784 * 00785 * If @a os is not @c NULL and it contains arguments, then try 00786 * printing help for them as though they are subcommands, using @a 00787 * cmd_table and @a option_table for option information. If not @c 00788 * NULL, @a global_options is a zero-terminated array of options taken 00789 * by all subcommands. 00790 * 00791 * Else, if @a print_version is TRUE, then print version info, in 00792 * brief form if @a quiet is also TRUE; if @a quiet is FALSE, then if 00793 * @a version_footer is non-NULL, print it following the version 00794 * information. If @a verbose is TRUE, also print information about 00795 * the running system and loaded shared libraries, where available. 00796 * 00797 * Else, if @a os is not @c NULL and does not contain arguments, print 00798 * generic help, via svn_opt_print_generic_help2() with the @a header, 00799 * @a cmd_table, @a option_table, and @a footer arguments. 00800 * 00801 * Else, when @a os is @c NULL, print the simple usage complaint. 00802 * 00803 * Use @a pool for temporary allocations. 00804 * 00805 * Notes: The reason this function handles both version printing and 00806 * general usage help is that a confused user might put both the 00807 * --version flag *and* subcommand arguments on a help command line. 00808 * The logic for handling such a situation should be in one place. 00809 * 00810 * @since New in 1.11. 00811 */ 00812 svn_error_t * 00813 svn_opt_print_help5(apr_getopt_t *os, 00814 const char *pgm_name, 00815 svn_boolean_t print_version, 00816 svn_boolean_t quiet, 00817 svn_boolean_t verbose, 00818 const char *version_footer, 00819 const char *header, 00820 const svn_opt_subcommand_desc3_t *cmd_table, 00821 const apr_getopt_option_t *option_table, 00822 const int *global_options, 00823 const char *footer, 00824 apr_pool_t *pool); 00825 00826 /** 00827 * Same as svn_opt_print_help5(), but with a different 00828 * version of the subcommand description table. 00829 * 00830 * @since New in 1.8. 00831 * @deprecated Provided for backward compatibility with the 1.10 API. 00832 */ 00833 SVN_DEPRECATED 00834 svn_error_t * 00835 svn_opt_print_help4(apr_getopt_t *os, 00836 const char *pgm_name, 00837 svn_boolean_t print_version, 00838 svn_boolean_t quiet, 00839 svn_boolean_t verbose, 00840 const char *version_footer, 00841 const char *header, 00842 const svn_opt_subcommand_desc2_t *cmd_table, 00843 const apr_getopt_option_t *option_table, 00844 const int *global_options, 00845 const char *footer, 00846 apr_pool_t *pool); 00847 00848 /** 00849 * Same as svn_opt_print_help4(), but with @a verbose always @c FALSE. 00850 * 00851 * @deprecated Provided for backward compatibility with the 1.7 API. 00852 */ 00853 00854 SVN_DEPRECATED 00855 svn_error_t * 00856 svn_opt_print_help3(apr_getopt_t *os, 00857 const char *pgm_name, 00858 svn_boolean_t print_version, 00859 svn_boolean_t quiet, 00860 const char *version_footer, 00861 const char *header, 00862 const svn_opt_subcommand_desc2_t *cmd_table, 00863 const apr_getopt_option_t *option_table, 00864 const int *global_options, 00865 const char *footer, 00866 apr_pool_t *pool); 00867 00868 /** 00869 * Same as svn_opt_print_help3(), but with @a global_options always @c 00870 * NULL. 00871 * 00872 * @deprecated Provided for backward compatibility with the 1.4 API. 00873 */ 00874 00875 SVN_DEPRECATED 00876 svn_error_t * 00877 svn_opt_print_help2(apr_getopt_t *os, 00878 const char *pgm_name, 00879 svn_boolean_t print_version, 00880 svn_boolean_t quiet, 00881 const char *version_footer, 00882 const char *header, 00883 const svn_opt_subcommand_desc2_t *cmd_table, 00884 const apr_getopt_option_t *option_table, 00885 const char *footer, 00886 apr_pool_t *pool); 00887 00888 00889 /** 00890 * Same as svn_opt_print_help2(), but acts on #svn_opt_subcommand_desc_t. 00891 * 00892 * @deprecated Provided for backward compatibility with the 1.3 API. 00893 */ 00894 SVN_DEPRECATED 00895 svn_error_t * 00896 svn_opt_print_help(apr_getopt_t *os, 00897 const char *pgm_name, 00898 svn_boolean_t print_version, 00899 svn_boolean_t quiet, 00900 const char *version_footer, 00901 const char *header, 00902 const svn_opt_subcommand_desc_t *cmd_table, 00903 const apr_getopt_option_t *option_table, 00904 const char *footer, 00905 apr_pool_t *pool); 00906 00907 #ifdef __cplusplus 00908 } 00909 #endif /* __cplusplus */ 00910 00911 #endif /* SVN_OPT_H */
1.6.1