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