Subversion
svn_opt.h
Go to the documentation of this file.
1 /**
2  * @copyright
3  * ====================================================================
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements. See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership. The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License. You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied. See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  * ====================================================================
21  * @endcopyright
22  *
23  * @file svn_opt.h
24  * @brief Option and argument parsing for Subversion command lines
25  */
26 
27 #ifndef SVN_OPT_H
28 #define SVN_OPT_H
29 
30 #include "svn_opt_impl.h"
31 
32 #include <apr.h>
33 #include <apr_pools.h>
34 #include <apr_getopt.h>
35 #include <apr_tables.h>
36 #include <apr_hash.h>
37 
38 #ifndef DOXYGEN_SHOULD_SKIP_THIS
39 #define APR_WANT_STDIO
40 #endif
41 #include <apr_want.h> /* for FILE* */
42 
43 #include "svn_types.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif /* __cplusplus */
48 
49 
50 ␌
51 /**
52  * All subcommand procedures in Subversion conform to this prototype.
53  *
54  * @a os is the apr option state after getopt processing has been run; in
55  * other words, it still contains the non-option arguments following
56  * the subcommand. See @a os->argv and @a os->ind.
57  *
58  * @a baton is anything you need it to be.
59  *
60  * @a pool is used for allocating errors, and for any other allocation
61  * unless the instance is explicitly documented to allocate from a
62  * pool in @a baton.
63  */
65  apr_getopt_t *os, void *baton, apr_pool_t *pool);
66 
67 
68 /** The maximum number of aliases a subcommand can have. */
69 #define SVN_OPT_MAX_ALIASES 3
70 
71 /** The maximum number of options that can be accepted by a subcommand. */
72 #define SVN_OPT_MAX_OPTIONS 50
73 
74 /** The maximum number of paragraphs of help text a subcommand can have.
75  * @since New in 1.11. */
76 #define SVN_OPT_MAX_PARAGRAPHS 100
77 
78 /** Options that have no short option char should use an identifying
79  * integer equal to or greater than this.
80  */
81 #define SVN_OPT_FIRST_LONGOPT_ID 256
82 
83 
84 /** One element of a subcommand dispatch table.
85  *
86  * @since New in 1.11.
87  */
89 {
90  /** The full name of this command. */
91  const char *name;
92 
93  /** The function this command invokes. */
95 
96  /** A list of alias names for this command (e.g., 'up' for 'update'). */
98 
99  /** A multi-paragraph string describing this command. */
101 
102  /** A list of options accepted by this command. Each value in the
103  * array is a unique enum (the 2nd field in apr_getopt_option_t)
104  */
106 
107  /** A list of option help descriptions, keyed by the option unique enum
108  * (the 2nd field in apr_getopt_option_t), which override the generic
109  * descriptions given in an apr_getopt_option_t on a per-subcommand basis.
110  */
111  struct { int optch; const char *desc; } desc_overrides[SVN_OPT_MAX_OPTIONS];
113 
114 
115 /** One element of a subcommand dispatch table.
116  *
117  * @since New in 1.4.
118  * @deprecated Provided for backward compatibility with the 1.10 API.
119  */
121 {
122  /** The full name of this command. */
123  const char *name;
124 
125  /** The function this command invokes. */
127 
128  /** A list of alias names for this command (e.g., 'up' for 'update'). */
130 
131  /** A brief string describing this command, for usage messages. */
132  const char *help;
133 
134  /** A list of options accepted by this command. Each value in the
135  * array is a unique enum (the 2nd field in apr_getopt_option_t)
136  */
138 
139  /** A list of option help descriptions, keyed by the option unique enum
140  * (the 2nd field in apr_getopt_option_t), which override the generic
141  * descriptions given in an apr_getopt_option_t on a per-subcommand basis.
142  */
143  struct { int optch; const char *desc; } desc_overrides[SVN_OPT_MAX_OPTIONS];
145 
146 
147 /** One element of a subcommand dispatch table.
148  *
149  * @deprecated Provided for backward compatibility with the 1.3 API.
150  *
151  * Like #svn_opt_subcommand_desc2_t but lacking the @c desc_overrides
152  * member.
153  */
155 {
156  /** The full name of this command. */
157  const char *name;
158 
159  /** The function this command invokes. */
161 
162  /** A list of alias names for this command (e.g., 'up' for 'update'). */
164 
165  /** A brief string describing this command, for usage messages. */
166  const char *help;
167 
168  /** A list of options accepted by this command. Each value in the
169  * array is a unique enum (the 2nd field in apr_getopt_option_t)
170  */
172 
174 
175 
176 /**
177  * Return the entry in @a table whose name matches @a cmd_name, or @c NULL if
178  * none. @a cmd_name may be an alias.
179  *
180  * @since New in 1.11.
181  */
184  const char *cmd_name);
185 
186 
187 /**
188  * Same as svn_opt_get_canonical_subcommand3(), but with a different
189  * version of the subcommand description table.
190  *
191  * @since New in 1.4.
192  * @deprecated Provided for backward compatibility with the 1.10 API.
193  */
197  const char *cmd_name);
198 
199 
200 /**
201  * Return the entry in @a table whose name matches @a cmd_name, or @c NULL if
202  * none. @a cmd_name may be an alias.
203  *
204  * Same as svn_opt_get_canonical_subcommand2(), but acts on
205  * #svn_opt_subcommand_desc_t.
206  *
207  * @deprecated Provided for backward compatibility with the 1.3 API.
208  */
212  const char *cmd_name);
213 
214 
215 /**
216  * Return pointer to an @c apr_getopt_option_t for the option whose
217  * option code is @a code, or @c NULL if no match. @a option_table must end
218  * with an element whose every field is zero. If @a command is non-NULL,
219  * then return the subcommand-specific option description instead of the
220  * generic one, if a specific description is defined.
221  *
222  * The returned value may be statically allocated, or allocated in @a pool.
223  *
224  * @since New in 1.11.
225  */
226 const apr_getopt_option_t *
228  const apr_getopt_option_t *option_table,
229  const svn_opt_subcommand_desc3_t *command,
230  apr_pool_t *pool);
231 
232 /**
233  * Same as svn_opt_get_option_from_code3(), but with a different
234  * version of the subcommand description table.
235  *
236  * @since New in 1.4.
237  * @deprecated Provided for backward compatibility with the 1.10 API.
238  */
240 const apr_getopt_option_t *
242  const apr_getopt_option_t *option_table,
243  const svn_opt_subcommand_desc2_t *command,
244  apr_pool_t *pool);
245 
246 
247 /**
248  * Return the first entry from @a option_table whose option code is @a code,
249  * or @c NULL if no match. @a option_table must end with an element whose
250  * every field is zero.
251  *
252  * @deprecated Provided for backward compatibility with the 1.3 API.
253  */
255 const apr_getopt_option_t *
257  const apr_getopt_option_t *option_table);
258 
259 
260 /**
261  * Return @c TRUE iff subcommand @a command supports option @a
262  * option_code, else return @c FALSE. If @a global_options is
263  * non-NULL, it is a zero-terminated array, and all subcommands take
264  * the options listed in it.
265  *
266  * @since New in 1.11.
267  */
270  int option_code,
271  const int *global_options);
272 
273 /**
274  * Same as svn_opt_subcommand_takes_option4(), but with a different
275  * version of the subcommand description table.
276  *
277  * @since New in 1.5.
278  * @deprecated Provided for backward compatibility with the 1.10 API.
279  */
283  int option_code,
284  const int *global_options);
285 
286 /**
287  * Same as svn_opt_subcommand_takes_option3(), but with @c NULL for @a
288  * global_options.
289  *
290  * @deprecated Provided for backward compatibility with the 1.4 API.
291  */
295  int option_code);
296 
297 
298 /**
299  * Return @c TRUE iff subcommand @a command supports option @a option_code,
300  * else return @c FALSE.
301  *
302  * Same as svn_opt_subcommand_takes_option2(), but acts on
303  * #svn_opt_subcommand_desc_t.
304  *
305  * @deprecated Provided for backward compatibility with the 1.3 API.
306  */
310  int option_code);
311 
312 
313 /**
314  * Print a generic (not command-specific) usage message to @a stream.
315  *
316  * @todo Why is @a stream a stdio file instead of an svn stream?
317  *
318  * If @a header is non-NULL, print @a header followed by a newline. Then
319  * loop over @a cmd_table printing the usage for each command (getting
320  * option usages from @a opt_table). Then if @a footer is non-NULL, print
321  * @a footer followed by a newline.
322  *
323  * Use @a pool for temporary allocation.
324  *
325  * @since New in 1.11.
326  */
327 void
328 svn_opt_print_generic_help3(const char *header,
329  const svn_opt_subcommand_desc3_t *cmd_table,
330  const apr_getopt_option_t *opt_table,
331  const char *footer,
332  apr_pool_t *pool,
333  FILE *stream);
334 
335 /**
336  * Same as svn_opt_print_generic_help3(), but with a different
337  * version of the subcommand description table.
338  *
339  * @since New in 1.4.
340  * @deprecated Provided for backward compatibility with the 1.10 API.
341  */
343 void
344 svn_opt_print_generic_help2(const char *header,
345  const svn_opt_subcommand_desc2_t *cmd_table,
346  const apr_getopt_option_t *opt_table,
347  const char *footer,
348  apr_pool_t *pool,
349  FILE *stream);
350 
351 
352 /**
353  * Same as svn_opt_print_generic_help2(), but acts on
354  * #svn_opt_subcommand_desc_t.
355  *
356  * @deprecated Provided for backward compatibility with the 1.3 API.
357  */
359 void
360 svn_opt_print_generic_help(const char *header,
361  const svn_opt_subcommand_desc_t *cmd_table,
362  const apr_getopt_option_t *opt_table,
363  const char *footer,
364  apr_pool_t *pool,
365  FILE *stream);
366 
367 
368 /**
369  * Print an option @a opt nicely into a @a string allocated in @a pool.
370  * If @a doc is set, include the generic documentation string of @a opt,
371  * localized to the current locale if a translation is available.
372  */
373 void
374 svn_opt_format_option(const char **string,
375  const apr_getopt_option_t *opt,
376  svn_boolean_t doc,
377  apr_pool_t *pool);
378 
379 
380 
381 /**
382  * Get @a subcommand's usage from @a table, and print it to @c stdout.
383  * Obtain option usage from @a options_table. If not @c NULL, @a
384  * global_options is a zero-terminated list of global options. Use @a
385  * pool for temporary allocation. @a subcommand may be a canonical
386  * command name or an alias. ### @todo Why does this only print to
387  * @c stdout, whereas svn_opt_print_generic_help() gives us a choice?
388  *
389  * When printing the description of an option, if the same option code
390  * appears a second time in @a options_table with a different name, then
391  * use that second name as an alias for the first name. This additional
392  * behaviour is new in 1.7.
393  *
394  * @since New in 1.11.
395  */
396 void
397 svn_opt_subcommand_help4(const char *subcommand,
398  const svn_opt_subcommand_desc3_t *table,
399  const apr_getopt_option_t *options_table,
400  const int *global_options,
401  apr_pool_t *pool);
402 
403 /**
404  * Same as svn_opt_subcommand_help4(), but with a different
405  * version of the subcommand description table.
406  *
407  * @since New in 1.5.
408  * @deprecated Provided for backward compatibility with the 1.10 API.
409  */
411 void
412 svn_opt_subcommand_help3(const char *subcommand,
413  const svn_opt_subcommand_desc2_t *table,
414  const apr_getopt_option_t *options_table,
415  const int *global_options,
416  apr_pool_t *pool);
417 
418 /**
419  * Same as svn_opt_subcommand_help3(), but with @a global_options
420  * always NULL.
421  *
422  * @deprecated Provided for backward compatibility with the 1.4 API.
423  */
425 void
426 svn_opt_subcommand_help2(const char *subcommand,
427  const svn_opt_subcommand_desc2_t *table,
428  const apr_getopt_option_t *options_table,
429  apr_pool_t *pool);
430 
431 
432 /**
433  * Same as svn_opt_subcommand_help2(), but acts on
434  * #svn_opt_subcommand_desc_t.
435  *
436  * @deprecated Provided for backward compatibility with the 1.3 API.
437  */
439 void
440 svn_opt_subcommand_help(const char *subcommand,
441  const svn_opt_subcommand_desc_t *table,
442  const apr_getopt_option_t *options_table,
443  apr_pool_t *pool);
444 
445 
446 ␌
447 /* Parsing revision and date options. */
448 /* NOTE: svn_opt_revision_kind is defined in svn_opt_impl.h */
449 
450 /**
451  * A revision value, which can be specified as a number or a date.
452  *
453  * @note This union was formerly an anonymous inline type in
454  * @c svn_opt_revision_t, and was converted to a named type just to
455  * make things easier for SWIG.
456  *
457  * @since New in 1.3.
458  */
460 {
461  /** The revision number */
463 
464  /** the date of the revision */
465  apr_time_t date;
467 
468 /** A revision, specified in one of @c svn_opt_revision_kind ways. */
469 typedef struct svn_opt_revision_t
470 {
471  enum svn_opt_revision_kind kind; /**< See svn_opt_revision_kind */
472  svn_opt_revision_value_t value; /**< Extra data qualifying the @c kind */
474 
475 /** A revision range, specified in one of @c svn_opt_revision_kind ways. */
477 {
478  /** The first revision in the range */
480 
481  /** The last revision in the range */
484 
485 
486 /**
487  * Parse NULL-terminated C string @a str as a revision number and
488  * store its value in @a rev.
489  *
490  * If @a str is not a valid revision number, then the error
491  * #SVN_ERR_REVNUM_PARSE_FAILURE error is returned. Negative numbers
492  * parsed from @a str are considered invalid, and result in the same error.
493  *
494  * Unlike svn_revnum_parse(), this function support our cmdline revision
495  * number format, whereas the revnum may be prefixed with an 'r' symbol.
496  *
497  * @since New in 1.15
498  * @see svn_revnum_parse()
499  */
500 svn_error_t *
501 svn_opt_parse_revnum(svn_revnum_t *rev, const char *str);
502 
503 /**
504  * Set @a *start_revision and/or @a *end_revision according to @a arg,
505  * where @a arg is "N" or "N:M", like so:
506  *
507  * - If @a arg is "N", set @a *start_revision to represent N, and
508  * leave @a *end_revision untouched.
509  *
510  * - If @a arg is "N:M", set @a *start_revision and @a *end_revision
511  * to represent N and M respectively.
512  *
513  * N and/or M may be one of the special revision descriptors
514  * recognized by revision_from_word(), or a date in curly braces.
515  *
516  * If @a arg is invalid, return -1; else return 0.
517  * It is invalid to omit a revision (as in, ":", "N:" or ":M").
518  *
519  * @note It is typical, though not required, for @a *start_revision and
520  * @a *end_revision to be @c svn_opt_revision_unspecified kind on entry.
521  *
522  * Use @a pool for temporary allocations.
523  */
524 int
526  svn_opt_revision_t *end_revision,
527  const char *arg,
528  apr_pool_t *pool);
529 
530 /**
531  * Parse @a arg, where @a arg is "N" or "N:M", into a
532  * @c svn_opt_revision_range_t and push that onto @a opt_ranges.
533  *
534  * - If @a arg is "N", set the @c start field of the
535  * @c svn_opt_revision_range_t to represent N and the @c end field
536  * to @c svn_opt_revision_unspecified.
537  *
538  * - If @a arg is "N:M", set the @c start field of the
539  * @c svn_opt_revision_range_t to represent N and the @c end field
540  * to represent M.
541  *
542  * If @a arg is invalid, return -1; else return 0. It is invalid to omit
543  * a revision (as in, ":", "N:" or ":M").
544  *
545  * Use @a pool to allocate @c svn_opt_revision_range_t pushed to the array.
546  *
547  * @since New in 1.5.
548  */
549 int
550 svn_opt_parse_revision_to_range(apr_array_header_t *opt_ranges,
551  const char *arg,
552  apr_pool_t *pool);
553 
554 /**
555  * Parse @a arg, where @a arg is "N", "-N", "N-M" into a
556  * @c svn_opt_revision_range_t and push that onto @a opt_ranges.
557  *
558  * - If @a arg is "N", set the @c start field of the
559  * @c svn_opt_revision_range_t to N-1 and @c end field to N.
560  *
561  * - If @a arg is "-N", set the @c start field of the
562  * @c svn_opt_revision_range_t to N and @c end field to N-1.
563  *
564  * - If @a arg is "N-M", set the @c start field of the
565  * @c svn_opt_revision_range_t to N-1 and @c end field to M.
566  *
567  * If @a arg is invalid, return -1; else return 0.
568  *
569  * Use @a result_pool to allocate @c svn_opt_revision_range_t pushed to the
570  * array.
571  *
572  * @since New in 1.15.
573  */
574 int
575 svn_opt_parse_change_to_range(apr_array_header_t *opt_ranges,
576  const char *arg,
577  apr_pool_t *result_pool);
578 
579 /**
580  * Resolve peg revisions and operational revisions in the following way:
581  *
582  * - If @a is_url is set and @a peg_rev->kind is
583  * @c svn_opt_revision_unspecified, @a peg_rev->kind defaults to
584  * @c svn_opt_revision_head.
585  *
586  * - If @a is_url is not set, and @a peg_rev->kind is
587  * @c svn_opt_revision_unspecified, @a peg_rev->kind defaults to
588  * @c svn_opt_revision_base.
589  *
590  * - If @a op_rev->kind is @c svn_opt_revision_unspecified, @a op_rev
591  * defaults to @a peg_rev.
592  *
593  * Both @a peg_rev and @a op_rev may be modified as a result of this
594  * function. @a is_url should be set if the path the revisions refer to is
595  * a url, and unset otherwise.
596  *
597  * If @a notice_local_mods is set, @c svn_opt_revision_working is used,
598  * instead of @c svn_opt_revision_base.
599  *
600  * Use @a pool for allocations.
601  *
602  * @since New in 1.5.
603  */
604 svn_error_t *
606  svn_opt_revision_t *op_rev,
607  svn_boolean_t is_url,
608  svn_boolean_t notice_local_mods,
609  apr_pool_t *pool);
610 
611 ␌
612 /* Parsing arguments. */
613 
614 /**
615  * Pull remaining target arguments from @a os into @a *targets_p,
616  * converting them to UTF-8, followed by targets from @a known_targets
617  * (which might come from, for example, the "--targets" command line
618  * option), which are already in UTF-8.
619  *
620  * On each URL target, do some IRI-to-URI encoding and some
621  * auto-escaping. On each local path, canonicalize case and path
622  * separators.
623  *
624  * Allocate @a *targets_p and its elements in @a pool.
625  *
626  * If a path has the same name as a Subversion working copy
627  * administrative directory, return SVN_ERR_RESERVED_FILENAME_SPECIFIED;
628  * if multiple reserved paths are encountered, return a chain of
629  * errors, all of which are SVN_ERR_RESERVED_FILENAME_SPECIFIED. Do
630  * not return this type of error in a chain with any other type of
631  * error, and if this is the only type of error encountered, complete
632  * the operation before returning the error(s).
633  *
634  * @since New in 1.5.
635  * @see svn_client_args_to_target_array()
636  */
637 svn_error_t *
638 svn_opt_args_to_target_array3(apr_array_header_t **targets_p,
639  apr_getopt_t *os,
640  const apr_array_header_t *known_targets,
641  apr_pool_t *pool);
642 
643 /**
644  * This is the same as svn_opt_args_to_target_array3() except that it
645  * silently ignores paths that have the same name as a working copy
646  * administrative directory.
647  *
648  * @since New in 1.2.
649  *
650  * @deprecated Provided for backward compatibility with the 1.4 API.
651  */
653 svn_error_t *
654 svn_opt_args_to_target_array2(apr_array_header_t **targets_p,
655  apr_getopt_t *os,
656  const apr_array_header_t *known_targets,
657  apr_pool_t *pool);
658 
659 
660 /**
661  * The same as svn_opt_args_to_target_array2() except that, in
662  * addition, if @a extract_revisions is set, then look for trailing
663  * "@rev" syntax on the first two paths. If the first target in @a
664  * *targets_p ends in "@rev", replace it with a canonicalized version of
665  * the part before "@rev" and replace @a *start_revision with the value
666  * of "rev". If the second target in @a *targets_p ends in "@rev",
667  * replace it with a canonicalized version of the part before "@rev"
668  * and replace @a *end_revision with the value of "rev". Ignore
669  * revision specifiers on any further paths. "rev" can be any form of
670  * single revision specifier, as accepted by svn_opt_parse_revision().
671  *
672  * @deprecated Provided for backward compatibility with the 1.1 API.
673  */
675 svn_error_t *
676 svn_opt_args_to_target_array(apr_array_header_t **targets_p,
677  apr_getopt_t *os,
678  const apr_array_header_t *known_targets,
679  svn_opt_revision_t *start_revision,
680  svn_opt_revision_t *end_revision,
681  svn_boolean_t extract_revisions,
682  apr_pool_t *pool);
683 
684 
685 /**
686  * Parse revprop key/value pair from @a revprop_spec (name[=value]) into
687  * @a revprops, making copies of both with @a pool. If @a revprops is
688  * @c NULL, allocate a new apr_hash_t in it. @a revprops maps
689  * const char * revprop names to svn_string_t * revprop values for use
690  * with svn_repos_get_commit_editor5 and other get_commit_editor APIs.
691  *
692  * @since New in 1.6.
693  */
694 svn_error_t *
695 svn_opt_parse_revprop(apr_hash_t **revprops, const char *revprop_spec,
696  apr_pool_t *pool);
697 
698 
699 /**
700  * If no targets exist in @a *targets, add `.' as the lone target.
701  *
702  * (Some commands take an implicit "." string argument when invoked
703  * with no arguments. Those commands make use of this function to
704  * add "." to the target array if the user passes no args.)
705  */
706 void
707 svn_opt_push_implicit_dot_target(apr_array_header_t *targets,
708  apr_pool_t *pool);
709 
710 
711 /**
712  * Parse @a num_args non-target arguments from the list of arguments in
713  * @a os->argv, return them as <tt>const char *</tt> in @a *args_p, without
714  * doing any UTF-8 conversion. Allocate @a *args_p and its values in @a pool.
715  */
716 svn_error_t *
717 svn_opt_parse_num_args(apr_array_header_t **args_p,
718  apr_getopt_t *os,
719  int num_args,
720  apr_pool_t *pool);
721 
722 
723 /**
724  * Parse all remaining arguments from @a os->argv, return them as
725  * <tt>const char *</tt> in @a *args_p, without doing any UTF-8 conversion.
726  * Allocate @a *args_p and its values in @a pool.
727  */
728 svn_error_t *
729 svn_opt_parse_all_args(apr_array_header_t **args_p,
730  apr_getopt_t *os,
731  apr_pool_t *pool);
732 
733 /**
734  * Parse a working-copy path or URL in @a path, extracting any trailing
735  * revision specifier of the form "@rev" from the last component of
736  * the path.
737  *
738  * Some examples would be:
739  *
740  * - "foo/bar" -> "foo/bar", (unspecified)
741  * - "foo/bar@13" -> "foo/bar", (number, 13)
742  * - "foo/bar@HEAD" -> "foo/bar", (head)
743  * - "foo/bar@{1999-12-31}" -> "foo/bar", (date, 1999-12-31)
744  * - "http://a/b@27" -> "http://a/b", (number, 27)
745  * - "http://a/b@COMMITTED" -> "http://a/b", (committed) [*]
746  * - "http://a/b@{1999-12-31}" -> "http://a/b", (date, 1999-12-31)
747  * - "http://a/b@%7B1999-12-31%7D" -> "http://a/b", (date, 1999-12-31)
748  * - "foo/bar@1:2" -> error
749  * - "foo/bar@baz" -> error
750  * - "foo/bar@" -> "foo/bar", (unspecified)
751  * - "foo/@bar@" -> "foo/@bar", (unspecified)
752  * - "foo/bar/@13" -> "foo/bar/", (number, 13)
753  * - "foo/bar@@13" -> "foo/bar@", (number, 13)
754  * - "foo/@bar@HEAD" -> "foo/@bar", (head)
755  * - "foo@/bar" -> "foo@/bar", (unspecified)
756  * - "foo@HEAD/bar" -> "foo@HEAD/bar", (unspecified)
757  * - "@foo/bar" -> "@foo/bar", (unspecified)
758  * - "@foo/bar@" -> "@foo/bar", (unspecified)
759  *
760  * [*] Syntactically valid but probably not semantically useful.
761  *
762  * If a trailing revision specifier is found, parse it into @a *rev and
763  * put the rest of the path into @a *truepath, allocating from @a pool;
764  * or return an @c SVN_ERR_CL_ARG_PARSING_ERROR (with the effect on
765  * @a *truepath undefined) if the revision specifier is invalid.
766  * If no trailing revision specifier is found, set @a *truepath to
767  * @a path and @a rev->kind to @c svn_opt_revision_unspecified.
768  *
769  * This function does not require that @a path be in canonical form.
770  * No canonicalization is done and @a *truepath will only be in
771  * canonical form if @a path is in canonical form.
772  *
773  * @since New in 1.1.
774  * @since Since 1.6.5, this returns an error if @a path contains a peg
775  * specifier with no path before it, such as "@abc".
776  * @since Since 1.9.0, this no longer returns an error if @a path contains a peg
777  * specifier with no path before it, such as "@abc".
778  */
779 svn_error_t *
781  const char **truepath,
782  const char *path,
783  apr_pool_t *pool);
784 
785 /**
786  * Central dispatcher function for various kinds of help message.
787  * Prints one of:
788  * * subcommand-specific help (svn_opt_subcommand_help)
789  * * generic help (svn_opt_print_generic_help)
790  * * version info
791  * * simple usage complaint: "Type '@a pgm_name help' for usage."
792  *
793  * If @a os is not @c NULL and it contains arguments, then try
794  * printing help for them as though they are subcommands, using @a
795  * cmd_table and @a option_table for option information. If not @c
796  * NULL, @a global_options is a zero-terminated array of options taken
797  * by all subcommands.
798  *
799  * Else, if @a print_version is TRUE, then print version info, in
800  * brief form if @a quiet is also TRUE; if @a quiet is FALSE, then if
801  * @a version_footer is non-NULL, print it following the version
802  * information. If @a verbose is TRUE, also print information about
803  * the running system and loaded shared libraries, where available.
804  *
805  * Else, if @a os is not @c NULL and does not contain arguments, print
806  * generic help, via svn_opt_print_generic_help2() with the @a header,
807  * @a cmd_table, @a option_table, and @a footer arguments.
808  *
809  * Else, when @a os is @c NULL, print the simple usage complaint.
810  *
811  * Use @a pool for temporary allocations.
812  *
813  * Notes: The reason this function handles both version printing and
814  * general usage help is that a confused user might put both the
815  * --version flag *and* subcommand arguments on a help command line.
816  * The logic for handling such a situation should be in one place.
817  *
818  * @since New in 1.11.
819  */
820 svn_error_t *
821 svn_opt_print_help5(apr_getopt_t *os,
822  const char *pgm_name,
823  svn_boolean_t print_version,
824  svn_boolean_t quiet,
825  svn_boolean_t verbose,
826  const char *version_footer,
827  const char *header,
828  const svn_opt_subcommand_desc3_t *cmd_table,
829  const apr_getopt_option_t *option_table,
830  const int *global_options,
831  const char *footer,
832  apr_pool_t *pool);
833 
834 /**
835  * Same as svn_opt_print_help5(), but with a different
836  * version of the subcommand description table.
837  *
838  * @since New in 1.8.
839  * @deprecated Provided for backward compatibility with the 1.10 API.
840  */
842 svn_error_t *
843 svn_opt_print_help4(apr_getopt_t *os,
844  const char *pgm_name,
845  svn_boolean_t print_version,
846  svn_boolean_t quiet,
847  svn_boolean_t verbose,
848  const char *version_footer,
849  const char *header,
850  const svn_opt_subcommand_desc2_t *cmd_table,
851  const apr_getopt_option_t *option_table,
852  const int *global_options,
853  const char *footer,
854  apr_pool_t *pool);
855 
856 /**
857  * Same as svn_opt_print_help4(), but with @a verbose always @c FALSE.
858  *
859  * @deprecated Provided for backward compatibility with the 1.7 API.
860  */
861 
863 svn_error_t *
864 svn_opt_print_help3(apr_getopt_t *os,
865  const char *pgm_name,
866  svn_boolean_t print_version,
867  svn_boolean_t quiet,
868  const char *version_footer,
869  const char *header,
870  const svn_opt_subcommand_desc2_t *cmd_table,
871  const apr_getopt_option_t *option_table,
872  const int *global_options,
873  const char *footer,
874  apr_pool_t *pool);
875 
876 /**
877  * Same as svn_opt_print_help3(), but with @a global_options always @c
878  * NULL.
879  *
880  * @deprecated Provided for backward compatibility with the 1.4 API.
881  */
882 
884 svn_error_t *
885 svn_opt_print_help2(apr_getopt_t *os,
886  const char *pgm_name,
887  svn_boolean_t print_version,
888  svn_boolean_t quiet,
889  const char *version_footer,
890  const char *header,
891  const svn_opt_subcommand_desc2_t *cmd_table,
892  const apr_getopt_option_t *option_table,
893  const char *footer,
894  apr_pool_t *pool);
895 
896 
897 /**
898  * Same as svn_opt_print_help2(), but acts on #svn_opt_subcommand_desc_t.
899  *
900  * @deprecated Provided for backward compatibility with the 1.3 API.
901  */
903 svn_error_t *
904 svn_opt_print_help(apr_getopt_t *os,
905  const char *pgm_name,
906  svn_boolean_t print_version,
907  svn_boolean_t quiet,
908  const char *version_footer,
909  const char *header,
910  const svn_opt_subcommand_desc_t *cmd_table,
911  const apr_getopt_option_t *option_table,
912  const char *footer,
913  apr_pool_t *pool);
914 
915 #ifdef __cplusplus
916 }
917 #endif /* __cplusplus */
918 
919 #endif /* SVN_OPT_H */
Subversion error object.
Definition: svn_types.h:177
A revision range, specified in one of svn_opt_revision_kind ways.
Definition: svn_opt.h:477
svn_opt_revision_t start
The first revision in the range.
Definition: svn_opt.h:479
svn_opt_revision_t end
The last revision in the range.
Definition: svn_opt.h:482
A revision, specified in one of svn_opt_revision_kind ways.
Definition: svn_opt.h:470
svn_opt_revision_value_t value
Extra data qualifying the kind.
Definition: svn_opt.h:472
enum svn_opt_revision_kind kind
See svn_opt_revision_kind.
Definition: svn_opt.h:471
One element of a subcommand dispatch table.
Definition: svn_opt.h:121
const char * help
A brief string describing this command, for usage messages.
Definition: svn_opt.h:132
struct svn_opt_subcommand_desc2_t::@1 desc_overrides[50]
A list of option help descriptions, keyed by the option unique enum (the 2nd field in apr_getopt_opti...
svn_opt_subcommand_t * cmd_func
The function this command invokes.
Definition: svn_opt.h:126
const char * name
The full name of this command.
Definition: svn_opt.h:123
const char * aliases[3]
A list of alias names for this command (e.g., 'up' for 'update').
Definition: svn_opt.h:129
int valid_options[50]
A list of options accepted by this command.
Definition: svn_opt.h:137
One element of a subcommand dispatch table.
Definition: svn_opt.h:89
struct svn_opt_subcommand_desc3_t::@0 desc_overrides[50]
A list of option help descriptions, keyed by the option unique enum (the 2nd field in apr_getopt_opti...
svn_opt_subcommand_t * cmd_func
The function this command invokes.
Definition: svn_opt.h:94
const char * aliases[3]
A list of alias names for this command (e.g., 'up' for 'update').
Definition: svn_opt.h:97
const char * name
The full name of this command.
Definition: svn_opt.h:91
const char * help[100]
A multi-paragraph string describing this command.
Definition: svn_opt.h:100
int valid_options[50]
A list of options accepted by this command.
Definition: svn_opt.h:105
One element of a subcommand dispatch table.
Definition: svn_opt.h:155
const char * aliases[3]
A list of alias names for this command (e.g., 'up' for 'update').
Definition: svn_opt.h:163
svn_opt_subcommand_t * cmd_func
The function this command invokes.
Definition: svn_opt.h:160
int valid_options[50]
A list of options accepted by this command.
Definition: svn_opt.h:171
const char * help
A brief string describing this command, for usage messages.
Definition: svn_opt.h:166
const char * name
The full name of this command.
Definition: svn_opt.h:157
svn_error_t * svn_opt_print_help2(apr_getopt_t *os, const char *pgm_name, svn_boolean_t print_version, svn_boolean_t quiet, const char *version_footer, const char *header, const svn_opt_subcommand_desc2_t *cmd_table, const apr_getopt_option_t *option_table, const char *footer, apr_pool_t *pool)
Same as svn_opt_print_help3(), but with global_options always NULL.
int svn_opt_parse_revision_to_range(apr_array_header_t *opt_ranges, const char *arg, apr_pool_t *pool)
Parse arg, where arg is "N" or "N:M", into a svn_opt_revision_range_t and push that onto opt_ranges.
void svn_opt_subcommand_help3(const char *subcommand, const svn_opt_subcommand_desc2_t *table, const apr_getopt_option_t *options_table, const int *global_options, apr_pool_t *pool)
Same as svn_opt_subcommand_help4(), but with a different version of the subcommand description table.
svn_error_t * svn_opt_print_help4(apr_getopt_t *os, const char *pgm_name, svn_boolean_t print_version, svn_boolean_t quiet, svn_boolean_t verbose, const char *version_footer, const char *header, const svn_opt_subcommand_desc2_t *cmd_table, const apr_getopt_option_t *option_table, const int *global_options, const char *footer, apr_pool_t *pool)
Same as svn_opt_print_help5(), but with a different version of the subcommand description table.
#define SVN_OPT_MAX_OPTIONS
The maximum number of options that can be accepted by a subcommand.
Definition: svn_opt.h:72
svn_error_t * svn_opt_parse_revnum(svn_revnum_t *rev, const char *str)
Parse NULL-terminated C string str as a revision number and store its value in rev.
void svn_opt_print_generic_help3(const char *header, const svn_opt_subcommand_desc3_t *cmd_table, const apr_getopt_option_t *opt_table, const char *footer, apr_pool_t *pool, FILE *stream)
Print a generic (not command-specific) usage message to stream.
int svn_opt_parse_change_to_range(apr_array_header_t *opt_ranges, const char *arg, apr_pool_t *result_pool)
Parse arg, where arg is "N", "-N", "N-M" into a svn_opt_revision_range_t and push that onto opt_range...
struct svn_opt_subcommand_desc2_t svn_opt_subcommand_desc2_t
One element of a subcommand dispatch table.
struct svn_opt_subcommand_desc3_t svn_opt_subcommand_desc3_t
One element of a subcommand dispatch table.
#define SVN_OPT_MAX_ALIASES
The maximum number of aliases a subcommand can have.
Definition: svn_opt.h:69
const svn_opt_subcommand_desc2_t * svn_opt_get_canonical_subcommand2(const svn_opt_subcommand_desc2_t *table, const char *cmd_name)
Same as svn_opt_get_canonical_subcommand3(), but with a different version of the subcommand descripti...
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)
Same as svn_opt_get_option_from_code3(), but with a different version of the subcommand description t...
struct svn_opt_revision_range_t svn_opt_revision_range_t
A revision range, specified in one of svn_opt_revision_kind ways.
svn_error_t * svn_opt_parse_num_args(apr_array_header_t **args_p, apr_getopt_t *os, int num_args, apr_pool_t *pool)
Parse num_args non-target arguments from the list of arguments in os->argv, return them as const char...
const apr_getopt_option_t * svn_opt_get_option_from_code(int code, const apr_getopt_option_t *option_table)
Return the first entry from option_table whose option code is code, or NULL if no match.
int svn_opt_parse_revision(svn_opt_revision_t *start_revision, svn_opt_revision_t *end_revision, const char *arg, apr_pool_t *pool)
Set *start_revision and/or *end_revision according to arg, where arg is "N" or "N:M",...
svn_error_t * svn_opt_args_to_target_array(apr_array_header_t **targets_p, apr_getopt_t *os, const apr_array_header_t *known_targets, svn_opt_revision_t *start_revision, svn_opt_revision_t *end_revision, svn_boolean_t extract_revisions, apr_pool_t *pool)
The same as svn_opt_args_to_target_array2() except that, in addition, if extract_revisions is set,...
struct svn_opt_revision_t svn_opt_revision_t
A revision, specified in one of svn_opt_revision_kind ways.
svn_boolean_t svn_opt_subcommand_takes_option4(const svn_opt_subcommand_desc3_t *command, int option_code, const int *global_options)
Return TRUE iff subcommand command supports option option_code, else return FALSE.
union svn_opt_revision_value_t svn_opt_revision_value_t
A revision value, which can be specified as a number or a date.
void svn_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_help3(), but with a different version of the subcommand description tab...
svn_error_t * svn_opt_resolve_revisions(svn_opt_revision_t *peg_rev, svn_opt_revision_t *op_rev, svn_boolean_t is_url, svn_boolean_t notice_local_mods, apr_pool_t *pool)
Resolve peg revisions and operational revisions in the following way:
void svn_opt_subcommand_help4(const char *subcommand, const svn_opt_subcommand_desc3_t *table, const apr_getopt_option_t *options_table, const int *global_options, apr_pool_t *pool)
Get subcommand's usage from table, and print it to stdout.
svn_error_t * svn_opt_parse_all_args(apr_array_header_t **args_p, apr_getopt_t *os, apr_pool_t *pool)
Parse all remaining arguments from os->argv, return them as const char * in *args_p,...
const svn_opt_subcommand_desc_t * svn_opt_get_canonical_subcommand(const svn_opt_subcommand_desc_t *table, const char *cmd_name)
Return the entry in table whose name matches cmd_name, or NULL if none.
svn_error_t * svn_opt_print_help(apr_getopt_t *os, const char *pgm_name, svn_boolean_t print_version, svn_boolean_t quiet, const char *version_footer, const char *header, const svn_opt_subcommand_desc_t *cmd_table, const apr_getopt_option_t *option_table, const char *footer, apr_pool_t *pool)
Same as svn_opt_print_help2(), but acts on svn_opt_subcommand_desc_t.
svn_boolean_t svn_opt_subcommand_takes_option2(const svn_opt_subcommand_desc2_t *command, int option_code)
Same as svn_opt_subcommand_takes_option3(), but with NULL for global_options.
svn_boolean_t svn_opt_subcommand_takes_option(const svn_opt_subcommand_desc_t *command, int option_code)
Return TRUE iff subcommand command supports option option_code, else return FALSE.
svn_error_t * svn_opt_args_to_target_array3(apr_array_header_t **targets_p, apr_getopt_t *os, const apr_array_header_t *known_targets, apr_pool_t *pool)
Pull remaining target arguments from os into *targets_p, converting them to UTF-8,...
svn_error_t *() svn_opt_subcommand_t(apr_getopt_t *os, void *baton, apr_pool_t *pool)
All subcommand procedures in Subversion conform to this prototype.
Definition: svn_opt.h:64
#define SVN_OPT_MAX_PARAGRAPHS
The maximum number of paragraphs of help text a subcommand can have.
Definition: svn_opt.h:76
void svn_opt_format_option(const char **string, const apr_getopt_option_t *opt, svn_boolean_t doc, apr_pool_t *pool)
Print an option opt nicely into a string allocated in pool.
svn_error_t * svn_opt_parse_revprop(apr_hash_t **revprops, const char *revprop_spec, apr_pool_t *pool)
Parse revprop key/value pair from revprop_spec (name[=value]) into revprops, making copies of both wi...
svn_boolean_t svn_opt_subcommand_takes_option3(const svn_opt_subcommand_desc2_t *command, int option_code, const int *global_options)
Same as svn_opt_subcommand_takes_option4(), but with a different version of the subcommand descriptio...
const svn_opt_subcommand_desc3_t * svn_opt_get_canonical_subcommand3(const svn_opt_subcommand_desc3_t *table, const char *cmd_name)
Return the entry in table whose name matches cmd_name, or NULL if none.
void svn_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_help3(), but with global_options always NULL.
struct svn_opt_subcommand_desc_t svn_opt_subcommand_desc_t
One element of a subcommand dispatch table.
void svn_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)
Same as svn_opt_print_generic_help2(), but acts on svn_opt_subcommand_desc_t.
void svn_opt_subcommand_help(const char *subcommand, const svn_opt_subcommand_desc_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.
const apr_getopt_option_t * svn_opt_get_option_from_code3(int code, const apr_getopt_option_t *option_table, const svn_opt_subcommand_desc3_t *command, apr_pool_t *pool)
Return pointer to an apr_getopt_option_t for the option whose option code is code,...
svn_error_t * svn_opt_print_help5(apr_getopt_t *os, const char *pgm_name, svn_boolean_t print_version, svn_boolean_t quiet, svn_boolean_t verbose, const char *version_footer, const char *header, const svn_opt_subcommand_desc3_t *cmd_table, const apr_getopt_option_t *option_table, const int *global_options, const char *footer, apr_pool_t *pool)
Central dispatcher function for various kinds of help message.
svn_error_t * svn_opt_args_to_target_array2(apr_array_header_t **targets_p, apr_getopt_t *os, const apr_array_header_t *known_targets, apr_pool_t *pool)
This is the same as svn_opt_args_to_target_array3() except that it silently ignores paths that have t...
svn_error_t * svn_opt_parse_path(svn_opt_revision_t *rev, const char **truepath, const char *path, apr_pool_t *pool)
Parse a working-copy path or URL in path, extracting any trailing revision specifier of the form "@re...
void svn_opt_push_implicit_dot_target(apr_array_header_t *targets, apr_pool_t *pool)
If no targets exist in *targets, add ‘.
svn_error_t * svn_opt_print_help3(apr_getopt_t *os, const char *pgm_name, svn_boolean_t print_version, svn_boolean_t quiet, const char *version_footer, const char *header, const svn_opt_subcommand_desc2_t *cmd_table, const apr_getopt_option_t *option_table, const int *global_options, const char *footer, apr_pool_t *pool)
Same as svn_opt_print_help4(), but with verbose always FALSE.
Option and argument parsing for Subversion command lines (common implementation)
svn_opt_revision_kind
Various ways of specifying revisions.
Definition: svn_opt_impl.h:54
Subversion's data types.
int svn_boolean_t
YABT: Yet Another Boolean Type.
Definition: svn_types.h:137
#define SVN_DEPRECATED
Macro used to mark deprecated functions.
Definition: svn_types.h:62
long int svn_revnum_t
A revision number.
A revision value, which can be specified as a number or a date.
Definition: svn_opt.h:460
svn_revnum_t number
The revision number.
Definition: svn_opt.h:462
apr_time_t date
the date of the revision
Definition: svn_opt.h:465