xref: /freebsd-13-stable/contrib/subversion/subversion/libsvn_subr/deprecated.c (revision b7ec5dea64b6513b41316a38cc72efa9139bc4ae)
1 /*
2  * deprecated.c:  holding file for all deprecated APIs.
3  *                "we can't lose 'em, but we can shun 'em!"
4  *
5  * ====================================================================
6  *    Licensed to the Apache Software Foundation (ASF) under one
7  *    or more contributor license agreements.  See the NOTICE file
8  *    distributed with this work for additional information
9  *    regarding copyright ownership.  The ASF licenses this file
10  *    to you under the Apache License, Version 2.0 (the
11  *    "License"); you may not use this file except in compliance
12  *    with the License.  You may obtain a copy of the License at
13  *
14  *      http://www.apache.org/licenses/LICENSE-2.0
15  *
16  *    Unless required by applicable law or agreed to in writing,
17  *    software distributed under the License is distributed on an
18  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  *    KIND, either express or implied.  See the License for the
20  *    specific language governing permissions and limitations
21  *    under the License.
22  * ====================================================================
23  */
24 
25 /* ==================================================================== */
26 
27 
28 
29 #include <assert.h>
30 
31 #include <apr_md5.h>
32 
33 /* We define this here to remove any further warnings about the usage of
34    deprecated functions in this file. */
35 #define SVN_DEPRECATED
36 
37 #include "svn_hash.h"
38 #include "svn_subst.h"
39 #include "svn_path.h"
40 #include "svn_opt.h"
41 #include "svn_cmdline.h"
42 #include "svn_version.h"
43 #include "svn_pools.h"
44 #include "svn_dso.h"
45 #include "svn_mergeinfo.h"
46 #include "svn_utf.h"
47 #include "svn_xml.h"
48 #include "svn_auth.h"
49 #include "svn_base64.h"
50 
51 #include "opt.h"
52 #include "auth.h"
53 #include "private/svn_opt_private.h"
54 #include "private/svn_mergeinfo_private.h"
55 
56 #include "svn_private_config.h"
57 
58 
59 
60 
61 /*** Code. ***/
62 
63 /*** From subst.c ***/
64 /* Convert an old-style svn_subst_keywords_t struct * into a new-style
65  * keywords hash.  Keyword values are shallow copies, so the produced
66  * hash must not be assumed to have lifetime longer than the struct it
67  * is based on.  A NULL input causes a NULL output. */
68 static apr_hash_t *
kwstruct_to_kwhash(const svn_subst_keywords_t * kwstruct,apr_pool_t * pool)69 kwstruct_to_kwhash(const svn_subst_keywords_t *kwstruct,
70                    apr_pool_t *pool)
71 {
72   apr_hash_t *kwhash;
73 
74   if (kwstruct == NULL)
75     return NULL;
76 
77   kwhash = apr_hash_make(pool);
78 
79   if (kwstruct->revision)
80     {
81       svn_hash_sets(kwhash, SVN_KEYWORD_REVISION_LONG, kwstruct->revision);
82       svn_hash_sets(kwhash, SVN_KEYWORD_REVISION_MEDIUM, kwstruct->revision);
83       svn_hash_sets(kwhash, SVN_KEYWORD_REVISION_SHORT, kwstruct->revision);
84     }
85   if (kwstruct->date)
86     {
87       svn_hash_sets(kwhash, SVN_KEYWORD_DATE_LONG, kwstruct->date);
88       svn_hash_sets(kwhash, SVN_KEYWORD_DATE_SHORT, kwstruct->date);
89     }
90   if (kwstruct->author)
91     {
92       svn_hash_sets(kwhash, SVN_KEYWORD_AUTHOR_LONG, kwstruct->author);
93       svn_hash_sets(kwhash, SVN_KEYWORD_AUTHOR_SHORT, kwstruct->author);
94     }
95   if (kwstruct->url)
96     {
97       svn_hash_sets(kwhash, SVN_KEYWORD_URL_LONG, kwstruct->url);
98       svn_hash_sets(kwhash, SVN_KEYWORD_URL_SHORT, kwstruct->url);
99     }
100   if (kwstruct->id)
101     {
102       svn_hash_sets(kwhash, SVN_KEYWORD_ID, kwstruct->id);
103     }
104 
105   return kwhash;
106 }
107 
108 
109 svn_error_t *
svn_subst_translate_stream3(svn_stream_t * src_stream,svn_stream_t * dst_stream,const char * eol_str,svn_boolean_t repair,apr_hash_t * keywords,svn_boolean_t expand,apr_pool_t * pool)110 svn_subst_translate_stream3(svn_stream_t *src_stream,
111                             svn_stream_t *dst_stream,
112                             const char *eol_str,
113                             svn_boolean_t repair,
114                             apr_hash_t *keywords,
115                             svn_boolean_t expand,
116                             apr_pool_t *pool)
117 {
118   /* The docstring requires that *some* translation be requested. */
119   SVN_ERR_ASSERT(eol_str || keywords);
120 
121   /* We don't want the copy3 to close the provided streams. */
122   src_stream = svn_stream_disown(src_stream, pool);
123   dst_stream = svn_stream_disown(dst_stream, pool);
124 
125   /* Wrap the destination stream with our translation stream. It is more
126      efficient than wrapping the source stream. */
127   dst_stream = svn_subst_stream_translated(dst_stream, eol_str, repair,
128                                            keywords, expand, pool);
129 
130   return svn_error_trace(svn_stream_copy3(src_stream, dst_stream,
131                                           NULL, NULL, pool));
132 }
133 
134 svn_error_t *
svn_subst_translate_stream2(svn_stream_t * s,svn_stream_t * d,const char * eol_str,svn_boolean_t repair,const svn_subst_keywords_t * keywords,svn_boolean_t expand,apr_pool_t * pool)135 svn_subst_translate_stream2(svn_stream_t *s, /* src stream */
136                             svn_stream_t *d, /* dst stream */
137                             const char *eol_str,
138                             svn_boolean_t repair,
139                             const svn_subst_keywords_t *keywords,
140                             svn_boolean_t expand,
141                             apr_pool_t *pool)
142 {
143   apr_hash_t *kh = kwstruct_to_kwhash(keywords, pool);
144 
145   return svn_error_trace(svn_subst_translate_stream3(s, d, eol_str, repair,
146                                                      kh, expand, pool));
147 }
148 
149 svn_error_t *
svn_subst_translate_stream(svn_stream_t * s,svn_stream_t * d,const char * eol_str,svn_boolean_t repair,const svn_subst_keywords_t * keywords,svn_boolean_t expand)150 svn_subst_translate_stream(svn_stream_t *s, /* src stream */
151                            svn_stream_t *d, /* dst stream */
152                            const char *eol_str,
153                            svn_boolean_t repair,
154                            const svn_subst_keywords_t *keywords,
155                            svn_boolean_t expand)
156 {
157   apr_pool_t *pool = svn_pool_create(NULL);
158   svn_error_t *err = svn_subst_translate_stream2(s, d, eol_str, repair,
159                                                  keywords, expand, pool);
160   svn_pool_destroy(pool);
161   return svn_error_trace(err);
162 }
163 
164 svn_error_t *
svn_subst_translate_cstring(const char * src,const char ** dst,const char * eol_str,svn_boolean_t repair,const svn_subst_keywords_t * keywords,svn_boolean_t expand,apr_pool_t * pool)165 svn_subst_translate_cstring(const char *src,
166                             const char **dst,
167                             const char *eol_str,
168                             svn_boolean_t repair,
169                             const svn_subst_keywords_t *keywords,
170                             svn_boolean_t expand,
171                             apr_pool_t *pool)
172 {
173   apr_hash_t *kh = kwstruct_to_kwhash(keywords, pool);
174 
175   return svn_error_trace(svn_subst_translate_cstring2(src, dst, eol_str,
176                                                       repair, kh, expand,
177                                                       pool));
178 }
179 
180 svn_error_t *
svn_subst_copy_and_translate(const char * src,const char * dst,const char * eol_str,svn_boolean_t repair,const svn_subst_keywords_t * keywords,svn_boolean_t expand,apr_pool_t * pool)181 svn_subst_copy_and_translate(const char *src,
182                              const char *dst,
183                              const char *eol_str,
184                              svn_boolean_t repair,
185                              const svn_subst_keywords_t *keywords,
186                              svn_boolean_t expand,
187                              apr_pool_t *pool)
188 {
189   return svn_error_trace(svn_subst_copy_and_translate2(src, dst, eol_str,
190                                                        repair, keywords,
191                                                        expand, FALSE, pool));
192 }
193 
194 svn_error_t *
svn_subst_copy_and_translate2(const char * src,const char * dst,const char * eol_str,svn_boolean_t repair,const svn_subst_keywords_t * keywords,svn_boolean_t expand,svn_boolean_t special,apr_pool_t * pool)195 svn_subst_copy_and_translate2(const char *src,
196                               const char *dst,
197                               const char *eol_str,
198                               svn_boolean_t repair,
199                               const svn_subst_keywords_t *keywords,
200                               svn_boolean_t expand,
201                               svn_boolean_t special,
202                               apr_pool_t *pool)
203 {
204   apr_hash_t *kh = kwstruct_to_kwhash(keywords, pool);
205 
206   return svn_error_trace(svn_subst_copy_and_translate3(src, dst, eol_str,
207                                                        repair, kh, expand,
208                                                        special, pool));
209 }
210 
211 svn_error_t *
svn_subst_copy_and_translate3(const char * src,const char * dst,const char * eol_str,svn_boolean_t repair,apr_hash_t * keywords,svn_boolean_t expand,svn_boolean_t special,apr_pool_t * pool)212 svn_subst_copy_and_translate3(const char *src,
213                               const char *dst,
214                               const char *eol_str,
215                               svn_boolean_t repair,
216                               apr_hash_t *keywords,
217                               svn_boolean_t expand,
218                               svn_boolean_t special,
219                               apr_pool_t *pool)
220 {
221   return svn_error_trace(svn_subst_copy_and_translate4(src, dst, eol_str,
222                                                        repair, keywords,
223                                                        expand, special,
224                                                        NULL, NULL,
225                                                        pool));
226 }
227 
228 
229 svn_error_t *
svn_subst_stream_translated_to_normal_form(svn_stream_t ** stream,svn_stream_t * source,svn_subst_eol_style_t eol_style,const char * eol_str,svn_boolean_t always_repair_eols,apr_hash_t * keywords,apr_pool_t * pool)230 svn_subst_stream_translated_to_normal_form(svn_stream_t **stream,
231                                            svn_stream_t *source,
232                                            svn_subst_eol_style_t eol_style,
233                                            const char *eol_str,
234                                            svn_boolean_t always_repair_eols,
235                                            apr_hash_t *keywords,
236                                            apr_pool_t *pool)
237 {
238   if (eol_style == svn_subst_eol_style_native)
239     eol_str = SVN_SUBST_NATIVE_EOL_STR;
240   else if (! (eol_style == svn_subst_eol_style_fixed
241               || eol_style == svn_subst_eol_style_none))
242     return svn_error_create(SVN_ERR_IO_UNKNOWN_EOL, NULL, NULL);
243 
244  *stream = svn_subst_stream_translated(source, eol_str,
245                                        eol_style == svn_subst_eol_style_fixed
246                                        || always_repair_eols,
247                                        keywords, FALSE, pool);
248 
249  return SVN_NO_ERROR;
250 }
251 
252 svn_error_t *
svn_subst_translate_string(svn_string_t ** new_value,const svn_string_t * value,const char * encoding,apr_pool_t * pool)253 svn_subst_translate_string(svn_string_t **new_value,
254                            const svn_string_t *value,
255                            const char *encoding,
256                            apr_pool_t *pool)
257 {
258   return svn_subst_translate_string2(new_value, NULL, NULL, value,
259                                      encoding, FALSE, pool, pool);
260 }
261 
262 svn_error_t *
svn_subst_stream_detranslated(svn_stream_t ** stream_p,const char * src,svn_subst_eol_style_t eol_style,const char * eol_str,svn_boolean_t always_repair_eols,apr_hash_t * keywords,svn_boolean_t special,apr_pool_t * pool)263 svn_subst_stream_detranslated(svn_stream_t **stream_p,
264                               const char *src,
265                               svn_subst_eol_style_t eol_style,
266                               const char *eol_str,
267                               svn_boolean_t always_repair_eols,
268                               apr_hash_t *keywords,
269                               svn_boolean_t special,
270                               apr_pool_t *pool)
271 {
272   svn_stream_t *src_stream;
273 
274   if (special)
275     return svn_subst_read_specialfile(stream_p, src, pool, pool);
276 
277   /* This will be closed by svn_subst_stream_translated_to_normal_form
278      when the returned stream is closed. */
279   SVN_ERR(svn_stream_open_readonly(&src_stream, src, pool, pool));
280 
281   return svn_error_trace(svn_subst_stream_translated_to_normal_form(
282                            stream_p, src_stream,
283                            eol_style, eol_str,
284                            always_repair_eols,
285                            keywords, pool));
286 }
287 
288 svn_error_t *
svn_subst_translate_to_normal_form(const char * src,const char * dst,svn_subst_eol_style_t eol_style,const char * eol_str,svn_boolean_t always_repair_eols,apr_hash_t * keywords,svn_boolean_t special,apr_pool_t * pool)289 svn_subst_translate_to_normal_form(const char *src,
290                                    const char *dst,
291                                    svn_subst_eol_style_t eol_style,
292                                    const char *eol_str,
293                                    svn_boolean_t always_repair_eols,
294                                    apr_hash_t *keywords,
295                                    svn_boolean_t special,
296                                    apr_pool_t *pool)
297 {
298 
299   if (eol_style == svn_subst_eol_style_native)
300     eol_str = SVN_SUBST_NATIVE_EOL_STR;
301   else if (! (eol_style == svn_subst_eol_style_fixed
302               || eol_style == svn_subst_eol_style_none))
303     return svn_error_create(SVN_ERR_IO_UNKNOWN_EOL, NULL, NULL);
304 
305   return svn_error_trace(svn_subst_copy_and_translate3(
306                            src, dst, eol_str,
307                            eol_style == svn_subst_eol_style_fixed
308                              || always_repair_eols,
309                            keywords,
310                            FALSE /* contract keywords */,
311                            special,
312                            pool));
313 }
314 
315 
316 /*** From opt.c ***/
317 /* Same as print_command_info2(), but with deprecated struct revision. */
318 static svn_error_t *
print_command_info(const svn_opt_subcommand_desc_t * cmd,const apr_getopt_option_t * options_table,svn_boolean_t help,apr_pool_t * pool,FILE * stream)319 print_command_info(const svn_opt_subcommand_desc_t *cmd,
320                    const apr_getopt_option_t *options_table,
321                    svn_boolean_t help,
322                    apr_pool_t *pool,
323                    FILE *stream)
324 {
325   svn_boolean_t first_time;
326   apr_size_t i;
327 
328   /* Print the canonical command name. */
329   SVN_ERR(svn_cmdline_fputs(cmd->name, stream, pool));
330 
331   /* Print the list of aliases. */
332   first_time = TRUE;
333   for (i = 0; i < SVN_OPT_MAX_ALIASES; i++)
334     {
335       if (cmd->aliases[i] == NULL)
336         break;
337 
338       if (first_time) {
339         SVN_ERR(svn_cmdline_fputs(" (", stream, pool));
340         first_time = FALSE;
341       }
342       else
343         SVN_ERR(svn_cmdline_fputs(", ", stream, pool));
344 
345       SVN_ERR(svn_cmdline_fputs(cmd->aliases[i], stream, pool));
346     }
347 
348   if (! first_time)
349     SVN_ERR(svn_cmdline_fputs(")", stream, pool));
350 
351   if (help)
352     {
353       const apr_getopt_option_t *option;
354       svn_boolean_t have_options = FALSE;
355 
356       SVN_ERR(svn_cmdline_fprintf(stream, pool, ": %s", _(cmd->help)));
357 
358       /* Loop over all valid option codes attached to the subcommand */
359       for (i = 0; i < SVN_OPT_MAX_OPTIONS; i++)
360         {
361           if (cmd->valid_options[i])
362             {
363               if (!have_options)
364                 {
365                   SVN_ERR(svn_cmdline_fputs(_("\nValid options:\n"),
366                                             stream, pool));
367                   have_options = TRUE;
368                 }
369 
370               /* convert each option code into an option */
371               option =
372                 svn_opt_get_option_from_code2(cmd->valid_options[i],
373                                               options_table, NULL, pool);
374 
375               /* print the option's docstring */
376               if (option && option->description)
377                 {
378                   const char *optstr;
379                   svn_opt_format_option(&optstr, option, TRUE, pool);
380                   SVN_ERR(svn_cmdline_fprintf(stream, pool, "  %s\n",
381                                               optstr));
382                 }
383             }
384         }
385 
386       if (have_options)
387         SVN_ERR(svn_cmdline_fprintf(stream, pool, "\n"));
388     }
389 
390   return SVN_NO_ERROR;
391 }
392 
393 const svn_opt_subcommand_desc2_t *
svn_opt_get_canonical_subcommand2(const svn_opt_subcommand_desc2_t * table,const char * cmd_name)394 svn_opt_get_canonical_subcommand2(const svn_opt_subcommand_desc2_t *table,
395                                   const char *cmd_name)
396 {
397   int i = 0;
398 
399   if (cmd_name == NULL)
400     return NULL;
401 
402   while (table[i].name) {
403     int j;
404     if (strcmp(cmd_name, table[i].name) == 0)
405       return table + i;
406     for (j = 0; (j < SVN_OPT_MAX_ALIASES) && table[i].aliases[j]; j++)
407       if (strcmp(cmd_name, table[i].aliases[j]) == 0)
408         return table + i;
409 
410     i++;
411   }
412 
413   /* If we get here, there was no matching subcommand name or alias. */
414   return NULL;
415 }
416 
417 const svn_opt_subcommand_desc_t *
svn_opt_get_canonical_subcommand(const svn_opt_subcommand_desc_t * table,const char * cmd_name)418 svn_opt_get_canonical_subcommand(const svn_opt_subcommand_desc_t *table,
419                                  const char *cmd_name)
420 {
421   int i = 0;
422 
423   if (cmd_name == NULL)
424     return NULL;
425 
426   while (table[i].name) {
427     int j;
428     if (strcmp(cmd_name, table[i].name) == 0)
429       return table + i;
430     for (j = 0; (j < SVN_OPT_MAX_ALIASES) && table[i].aliases[j]; j++)
431       if (strcmp(cmd_name, table[i].aliases[j]) == 0)
432         return table + i;
433 
434     i++;
435   }
436 
437   /* If we get here, there was no matching subcommand name or alias. */
438   return NULL;
439 }
440 
441 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)442 svn_opt_get_option_from_code2(int code,
443                               const apr_getopt_option_t *option_table,
444                               const svn_opt_subcommand_desc2_t *command,
445                               apr_pool_t *pool)
446 {
447   apr_size_t i;
448 
449   for (i = 0; option_table[i].optch; i++)
450     if (option_table[i].optch == code)
451       {
452         if (command)
453           {
454             int j;
455 
456             for (j = 0; ((j < SVN_OPT_MAX_OPTIONS) &&
457                          command->desc_overrides[j].optch); j++)
458               if (command->desc_overrides[j].optch == code)
459                 {
460                   apr_getopt_option_t *tmpopt =
461                       apr_palloc(pool, sizeof(*tmpopt));
462                   *tmpopt = option_table[i];
463                   tmpopt->description = command->desc_overrides[j].desc;
464                   return tmpopt;
465                 }
466           }
467         return &(option_table[i]);
468       }
469 
470   return NULL;
471 }
472 
473 const apr_getopt_option_t *
svn_opt_get_option_from_code(int code,const apr_getopt_option_t * option_table)474 svn_opt_get_option_from_code(int code,
475                              const apr_getopt_option_t *option_table)
476 {
477   apr_size_t i;
478 
479   for (i = 0; option_table[i].optch; i++)
480     if (option_table[i].optch == code)
481       return &(option_table[i]);
482 
483   return NULL;
484 }
485 
486 /* Like svn_opt_get_option_from_code2(), but also, if CODE appears a second
487  * time in OPTION_TABLE with a different name, then set *LONG_ALIAS to that
488  * second name, else set it to NULL. */
489 static const apr_getopt_option_t *
get_option_from_code(const char ** long_alias,int code,const apr_getopt_option_t * option_table,const svn_opt_subcommand_desc2_t * command,apr_pool_t * pool)490 get_option_from_code(const char **long_alias,
491                      int code,
492                      const apr_getopt_option_t *option_table,
493                      const svn_opt_subcommand_desc2_t *command,
494                      apr_pool_t *pool)
495 {
496   const apr_getopt_option_t *i;
497   const apr_getopt_option_t *opt
498     = svn_opt_get_option_from_code2(code, option_table, command, pool);
499 
500   /* Find a long alias in the table, if there is one. */
501   *long_alias = NULL;
502   for (i = option_table; i->optch; i++)
503     {
504       if (i->optch == code && i->name != opt->name)
505         {
506           *long_alias = i->name;
507           break;
508         }
509     }
510 
511   return opt;
512 }
513 
514 /* Print an option OPT nicely into a STRING allocated in POOL.
515  * If OPT has a single-character short form, then print OPT->name (if not
516  * NULL) as an alias, else print LONG_ALIAS (if not NULL) as an alias.
517  * If DOC is set, include the generic documentation string of OPT,
518  * localized to the current locale if a translation is available.
519  */
520 static void
format_option(const char ** string,const apr_getopt_option_t * opt,const char * long_alias,svn_boolean_t doc,apr_pool_t * pool)521 format_option(const char **string,
522               const apr_getopt_option_t *opt,
523               const char *long_alias,
524               svn_boolean_t doc,
525               apr_pool_t *pool)
526 {
527   char *opts;
528 
529   if (opt == NULL)
530     {
531       *string = "?";
532       return;
533     }
534 
535   /* We have a valid option which may or may not have a "short
536      name" (a single-character alias for the long option). */
537   if (opt->optch <= 255)
538     opts = apr_psprintf(pool, "-%c [--%s]", opt->optch, opt->name);
539   else if (long_alias)
540     opts = apr_psprintf(pool, "--%s [--%s]", opt->name, long_alias);
541   else
542     opts = apr_psprintf(pool, "--%s", opt->name);
543 
544   if (opt->has_arg)
545     opts = apr_pstrcat(pool, opts, _(" ARG"), SVN_VA_NULL);
546 
547   if (doc)
548     opts = apr_psprintf(pool, "%-24s : %s", opts, _(opt->description));
549 
550   *string = opts;
551 }
552 
553 /* Print the canonical command name for CMD, and all its aliases, to
554    STREAM.  If HELP is set, print CMD's help string too, in which case
555    obtain option usage from OPTIONS_TABLE. */
556 static svn_error_t *
print_command_info2(const svn_opt_subcommand_desc2_t * cmd,const apr_getopt_option_t * options_table,const int * global_options,svn_boolean_t help,apr_pool_t * pool,FILE * stream)557 print_command_info2(const svn_opt_subcommand_desc2_t *cmd,
558                     const apr_getopt_option_t *options_table,
559                     const int *global_options,
560                     svn_boolean_t help,
561                     apr_pool_t *pool,
562                     FILE *stream)
563 {
564   svn_boolean_t first_time;
565   apr_size_t i;
566 
567   /* Print the canonical command name. */
568   SVN_ERR(svn_cmdline_fputs(cmd->name, stream, pool));
569 
570   /* Print the list of aliases. */
571   first_time = TRUE;
572   for (i = 0; i < SVN_OPT_MAX_ALIASES; i++)
573     {
574       if (cmd->aliases[i] == NULL)
575         break;
576 
577       if (first_time) {
578         SVN_ERR(svn_cmdline_fputs(" (", stream, pool));
579         first_time = FALSE;
580       }
581       else
582         SVN_ERR(svn_cmdline_fputs(", ", stream, pool));
583 
584       SVN_ERR(svn_cmdline_fputs(cmd->aliases[i], stream, pool));
585     }
586 
587   if (! first_time)
588     SVN_ERR(svn_cmdline_fputs(")", stream, pool));
589 
590   if (help)
591     {
592       const apr_getopt_option_t *option;
593       const char *long_alias;
594       svn_boolean_t have_options = FALSE;
595 
596       SVN_ERR(svn_cmdline_fprintf(stream, pool, ": %s", _(cmd->help)));
597 
598       /* Loop over all valid option codes attached to the subcommand */
599       for (i = 0; i < SVN_OPT_MAX_OPTIONS; i++)
600         {
601           if (cmd->valid_options[i])
602             {
603               if (!have_options)
604                 {
605                   SVN_ERR(svn_cmdline_fputs(_("\nValid options:\n"),
606                                             stream, pool));
607                   have_options = TRUE;
608                 }
609 
610               /* convert each option code into an option */
611               option = get_option_from_code(&long_alias, cmd->valid_options[i],
612                                             options_table, cmd, pool);
613 
614               /* print the option's docstring */
615               if (option && option->description)
616                 {
617                   const char *optstr;
618                   format_option(&optstr, option, long_alias, TRUE, pool);
619                   SVN_ERR(svn_cmdline_fprintf(stream, pool, "  %s\n",
620                                               optstr));
621                 }
622             }
623         }
624       /* And global options too */
625       if (global_options && *global_options)
626         {
627           SVN_ERR(svn_cmdline_fputs(_("\nGlobal options:\n"),
628                                     stream, pool));
629           have_options = TRUE;
630 
631           for (i = 0; global_options[i]; i++)
632             {
633 
634               /* convert each option code into an option */
635               option = get_option_from_code(&long_alias, global_options[i],
636                                             options_table, cmd, pool);
637 
638               /* print the option's docstring */
639               if (option && option->description)
640                 {
641                   const char *optstr;
642                   format_option(&optstr, option, long_alias, TRUE, pool);
643                   SVN_ERR(svn_cmdline_fprintf(stream, pool, "  %s\n",
644                                               optstr));
645                 }
646             }
647         }
648 
649       if (have_options)
650         SVN_ERR(svn_cmdline_fprintf(stream, pool, "\n"));
651     }
652 
653   return SVN_NO_ERROR;
654 }
655 
656 /* The body for svn_opt_print_generic_help2() function with standard error
657  * handling semantic. Handling of errors implemented at caller side. */
658 static svn_error_t *
print_generic_help_body(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)659 print_generic_help_body(const char *header,
660                         const svn_opt_subcommand_desc2_t *cmd_table,
661                         const apr_getopt_option_t *opt_table,
662                         const char *footer,
663                         apr_pool_t *pool, FILE *stream)
664 {
665   int i = 0;
666 
667   if (header)
668     SVN_ERR(svn_cmdline_fputs(header, stream, pool));
669 
670   while (cmd_table[i].name)
671     {
672       SVN_ERR(svn_cmdline_fputs("   ", stream, pool));
673       SVN_ERR(print_command_info2(cmd_table + i, opt_table,
674                                   NULL, FALSE,
675                                   pool, stream));
676       SVN_ERR(svn_cmdline_fputs("\n", stream, pool));
677       i++;
678     }
679 
680   SVN_ERR(svn_cmdline_fputs("\n", stream, pool));
681 
682   if (footer)
683     SVN_ERR(svn_cmdline_fputs(footer, stream, pool));
684 
685   return SVN_NO_ERROR;
686 }
687 
688 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)689 svn_opt_print_generic_help2(const char *header,
690                             const svn_opt_subcommand_desc2_t *cmd_table,
691                             const apr_getopt_option_t *opt_table,
692                             const char *footer,
693                             apr_pool_t *pool, FILE *stream)
694 {
695   svn_error_t *err;
696 
697   err = print_generic_help_body(header, cmd_table, opt_table, footer, pool,
698                                 stream);
699 
700   /* Issue #3014:
701    * Don't print anything on broken pipes. The pipe was likely
702    * closed by the process at the other end. We expect that
703    * process to perform error reporting as necessary.
704    *
705    * ### This assumes that there is only one error in a chain for
706    * ### SVN_ERR_IO_PIPE_WRITE_ERROR. See svn_cmdline_fputs(). */
707   if (err && err->apr_err != SVN_ERR_IO_PIPE_WRITE_ERROR)
708     svn_handle_error2(err, stderr, FALSE, "svn: ");
709   svn_error_clear(err);
710 }
711 
712 svn_boolean_t
svn_opt_subcommand_takes_option3(const svn_opt_subcommand_desc2_t * command,int option_code,const int * global_options)713 svn_opt_subcommand_takes_option3(const svn_opt_subcommand_desc2_t *command,
714                                  int option_code,
715                                  const int *global_options)
716 {
717   apr_size_t i;
718 
719   for (i = 0; i < SVN_OPT_MAX_OPTIONS; i++)
720     if (command->valid_options[i] == option_code)
721       return TRUE;
722 
723   if (global_options)
724     for (i = 0; global_options[i]; i++)
725       if (global_options[i] == option_code)
726         return TRUE;
727 
728   return FALSE;
729 }
730 
731 svn_boolean_t
svn_opt_subcommand_takes_option2(const svn_opt_subcommand_desc2_t * command,int option_code)732 svn_opt_subcommand_takes_option2(const svn_opt_subcommand_desc2_t *command,
733                                  int option_code)
734 {
735   return svn_opt_subcommand_takes_option3(command,
736                                           option_code,
737                                           NULL);
738 }
739 
740 svn_boolean_t
svn_opt_subcommand_takes_option(const svn_opt_subcommand_desc_t * command,int option_code)741 svn_opt_subcommand_takes_option(const svn_opt_subcommand_desc_t *command,
742                                 int option_code)
743 {
744   apr_size_t i;
745 
746   for (i = 0; i < SVN_OPT_MAX_OPTIONS; i++)
747     if (command->valid_options[i] == option_code)
748       return TRUE;
749 
750   return FALSE;
751 }
752 
753 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)754 svn_opt_subcommand_help3(const char *subcommand,
755                          const svn_opt_subcommand_desc2_t *table,
756                          const apr_getopt_option_t *options_table,
757                          const int *global_options,
758                          apr_pool_t *pool)
759 {
760   const svn_opt_subcommand_desc2_t *cmd =
761     svn_opt_get_canonical_subcommand2(table, subcommand);
762   svn_error_t *err;
763 
764   if (cmd)
765     err = print_command_info2(cmd, options_table, global_options,
766                               TRUE, pool, stdout);
767   else
768     err = svn_cmdline_fprintf(stderr, pool,
769                               _("\"%s\": unknown command.\n\n"), subcommand);
770 
771   if (err) {
772     /* Issue #3014: Don't print anything on broken pipes. */
773     if (err->apr_err != SVN_ERR_IO_PIPE_WRITE_ERROR)
774       svn_handle_error2(err, stderr, FALSE, "svn: ");
775     svn_error_clear(err);
776   }
777 }
778 
779 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)780 svn_opt_subcommand_help2(const char *subcommand,
781                          const svn_opt_subcommand_desc2_t *table,
782                          const apr_getopt_option_t *options_table,
783                          apr_pool_t *pool)
784 {
785   svn_opt_subcommand_help3(subcommand, table, options_table,
786                            NULL, pool);
787 }
788 
789 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)790 svn_opt_subcommand_help(const char *subcommand,
791                         const svn_opt_subcommand_desc_t *table,
792                         const apr_getopt_option_t *options_table,
793                         apr_pool_t *pool)
794 {
795   const svn_opt_subcommand_desc_t *cmd =
796     svn_opt_get_canonical_subcommand(table, subcommand);
797   svn_error_t *err;
798 
799   if (cmd)
800     err = print_command_info(cmd, options_table, TRUE, pool, stdout);
801   else
802     err = svn_cmdline_fprintf(stderr, pool,
803                               _("\"%s\": unknown command.\n\n"), subcommand);
804 
805   if (err) {
806     svn_handle_error2(err, stderr, FALSE, "svn: ");
807     svn_error_clear(err);
808   }
809 }
810 
811 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)812 svn_opt_args_to_target_array3(apr_array_header_t **targets_p,
813                               apr_getopt_t *os,
814                               const apr_array_header_t *known_targets,
815                               apr_pool_t *pool)
816 {
817   return svn_error_trace(svn_opt__args_to_target_array(targets_p, os,
818                                                        known_targets, pool));
819 }
820 
821 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)822 svn_opt_args_to_target_array2(apr_array_header_t **targets_p,
823                               apr_getopt_t *os,
824                               const apr_array_header_t *known_targets,
825                               apr_pool_t *pool)
826 {
827   svn_error_t *err = svn_opt_args_to_target_array3(targets_p, os,
828                                                    known_targets, pool);
829 
830   if (err && err->apr_err == SVN_ERR_RESERVED_FILENAME_SPECIFIED)
831     {
832       svn_error_clear(err);
833       return SVN_NO_ERROR;
834     }
835 
836   return err;
837 }
838 
839 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)840 svn_opt_args_to_target_array(apr_array_header_t **targets_p,
841                              apr_getopt_t *os,
842                              const apr_array_header_t *known_targets,
843                              svn_opt_revision_t *start_revision,
844                              svn_opt_revision_t *end_revision,
845                              svn_boolean_t extract_revisions,
846                              apr_pool_t *pool)
847 {
848   apr_array_header_t *output_targets;
849 
850   SVN_ERR(svn_opt_args_to_target_array2(&output_targets, os,
851                                         known_targets, pool));
852 
853   if (extract_revisions)
854     {
855       svn_opt_revision_t temprev;
856       const char *path;
857 
858       if (output_targets->nelts > 0)
859         {
860           path = APR_ARRAY_IDX(output_targets, 0, const char *);
861           SVN_ERR(svn_opt_parse_path(&temprev, &path, path, pool));
862           if (temprev.kind != svn_opt_revision_unspecified)
863             {
864               APR_ARRAY_IDX(output_targets, 0, const char *) = path;
865               start_revision->kind = temprev.kind;
866               start_revision->value = temprev.value;
867             }
868         }
869       if (output_targets->nelts > 1)
870         {
871           path = APR_ARRAY_IDX(output_targets, 1, const char *);
872           SVN_ERR(svn_opt_parse_path(&temprev, &path, path, pool));
873           if (temprev.kind != svn_opt_revision_unspecified)
874             {
875               APR_ARRAY_IDX(output_targets, 1, const char *) = path;
876               end_revision->kind = temprev.kind;
877               end_revision->value = temprev.value;
878             }
879         }
880     }
881 
882   *targets_p = output_targets;
883   return SVN_NO_ERROR;
884 }
885 
886 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)887 svn_opt_print_help4(apr_getopt_t *os,
888                     const char *pgm_name,
889                     svn_boolean_t print_version,
890                     svn_boolean_t quiet,
891                     svn_boolean_t verbose,
892                     const char *version_footer,
893                     const char *header,
894                     const svn_opt_subcommand_desc2_t *cmd_table,
895                     const apr_getopt_option_t *option_table,
896                     const int *global_options,
897                     const char *footer,
898                     apr_pool_t *pool)
899 {
900   apr_array_header_t *targets = NULL;
901 
902   if (os)
903     SVN_ERR(svn_opt_parse_all_args(&targets, os, pool));
904 
905   if (os && targets->nelts)  /* help on subcommand(s) requested */
906     {
907       int i;
908 
909       for (i = 0; i < targets->nelts; i++)
910         {
911           svn_opt_subcommand_help3(APR_ARRAY_IDX(targets, i, const char *),
912                                    cmd_table, option_table,
913                                    global_options, pool);
914         }
915     }
916   else if (print_version)   /* just --version */
917     {
918       SVN_ERR(svn_opt__print_version_info(pgm_name, version_footer,
919                                           svn_version_extended(verbose, pool),
920                                           quiet, verbose, pool));
921     }
922   else if (os && !targets->nelts)            /* `-h', `--help', or `help' */
923     svn_opt_print_generic_help2(header,
924                                 cmd_table,
925                                 option_table,
926                                 footer,
927                                 pool,
928                                 stdout);
929   else                                       /* unknown option or cmd */
930     SVN_ERR(svn_cmdline_fprintf(stderr, pool,
931                                 _("Type '%s help' for usage.\n"), pgm_name));
932 
933   return SVN_NO_ERROR;
934 }
935 
936 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)937 svn_opt_print_help3(apr_getopt_t *os,
938                     const char *pgm_name,
939                     svn_boolean_t print_version,
940                     svn_boolean_t quiet,
941                     const char *version_footer,
942                     const char *header,
943                     const svn_opt_subcommand_desc2_t *cmd_table,
944                     const apr_getopt_option_t *option_table,
945                     const int *global_options,
946                     const char *footer,
947                     apr_pool_t *pool)
948 {
949   return svn_error_trace(svn_opt_print_help4(os,
950                                              pgm_name,
951                                              print_version,
952                                              quiet,
953                                              FALSE,
954                                              version_footer,
955                                              header,
956                                              cmd_table,
957                                              option_table,
958                                              global_options,
959                                              footer,
960                                              pool));
961 }
962 
963 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)964 svn_opt_print_help2(apr_getopt_t *os,
965                     const char *pgm_name,
966                     svn_boolean_t print_version,
967                     svn_boolean_t quiet,
968                     const char *version_footer,
969                     const char *header,
970                     const svn_opt_subcommand_desc2_t *cmd_table,
971                     const apr_getopt_option_t *option_table,
972                     const char *footer,
973                     apr_pool_t *pool)
974 {
975   return svn_error_trace(svn_opt_print_help4(os,
976                                              pgm_name,
977                                              print_version,
978                                              quiet,
979                                              FALSE,
980                                              version_footer,
981                                              header,
982                                              cmd_table,
983                                              option_table,
984                                              NULL,
985                                              footer,
986                                              pool));
987 }
988 
989 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)990 svn_opt_print_help(apr_getopt_t *os,
991                    const char *pgm_name,
992                    svn_boolean_t print_version,
993                    svn_boolean_t quiet,
994                    const char *version_footer,
995                    const char *header,
996                    const svn_opt_subcommand_desc_t *cmd_table,
997                    const apr_getopt_option_t *option_table,
998                    const char *footer,
999                    apr_pool_t *pool)
1000 {
1001   apr_array_header_t *targets = NULL;
1002 
1003   if (os)
1004     SVN_ERR(svn_opt_parse_all_args(&targets, os, pool));
1005 
1006   if (os && targets->nelts)  /* help on subcommand(s) requested */
1007     {
1008       int i;
1009 
1010       for (i = 0; i < targets->nelts; i++)
1011         {
1012           svn_opt_subcommand_help(APR_ARRAY_IDX(targets, i, const char *),
1013                                   cmd_table, option_table, pool);
1014         }
1015     }
1016   else if (print_version)   /* just --version */
1017     {
1018       SVN_ERR(svn_opt__print_version_info(pgm_name, version_footer,
1019                                           svn_version_extended(FALSE, pool),
1020                                           quiet, FALSE, pool));
1021     }
1022   else if (os && !targets->nelts)            /* `-h', `--help', or `help' */
1023     svn_opt_print_generic_help(header,
1024                                cmd_table,
1025                                option_table,
1026                                footer,
1027                                pool,
1028                                stdout);
1029   else                                       /* unknown option or cmd */
1030     SVN_ERR(svn_cmdline_fprintf(stderr, pool,
1031                                 _("Type '%s help' for usage.\n"), pgm_name));
1032 
1033   return SVN_NO_ERROR;
1034 }
1035 
1036 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)1037 svn_opt_print_generic_help(const char *header,
1038                            const svn_opt_subcommand_desc_t *cmd_table,
1039                            const apr_getopt_option_t *opt_table,
1040                            const char *footer,
1041                            apr_pool_t *pool, FILE *stream)
1042 {
1043   int i = 0;
1044   svn_error_t *err;
1045 
1046   if (header)
1047     if ((err = svn_cmdline_fputs(header, stream, pool)))
1048       goto print_error;
1049 
1050   while (cmd_table[i].name)
1051     {
1052       if ((err = svn_cmdline_fputs("   ", stream, pool))
1053           || (err = print_command_info(cmd_table + i, opt_table, FALSE,
1054                                        pool, stream))
1055           || (err = svn_cmdline_fputs("\n", stream, pool)))
1056         goto print_error;
1057       i++;
1058     }
1059 
1060   if ((err = svn_cmdline_fputs("\n", stream, pool)))
1061     goto print_error;
1062 
1063   if (footer)
1064     if ((err = svn_cmdline_fputs(footer, stream, pool)))
1065       goto print_error;
1066 
1067   return;
1068 
1069  print_error:
1070   svn_handle_error2(err, stderr, FALSE, "svn: ");
1071   svn_error_clear(err);
1072 }
1073 
1074 /*** From io.c ***/
1075 svn_error_t *
svn_io_open_unique_file2(apr_file_t ** file,const char ** temp_path,const char * path,const char * suffix,svn_io_file_del_t delete_when,apr_pool_t * pool)1076 svn_io_open_unique_file2(apr_file_t **file,
1077                          const char **temp_path,
1078                          const char *path,
1079                          const char *suffix,
1080                          svn_io_file_del_t delete_when,
1081                          apr_pool_t *pool)
1082 {
1083   const char *dirpath;
1084   const char *filename;
1085 
1086   svn_path_split(path, &dirpath, &filename, pool);
1087   return svn_error_trace(svn_io_open_uniquely_named(file, temp_path,
1088                                                     dirpath, filename, suffix,
1089                                                     delete_when,
1090                                                     pool, pool));
1091 }
1092 
1093 svn_error_t *
svn_io_open_unique_file(apr_file_t ** file,const char ** temp_path,const char * path,const char * suffix,svn_boolean_t delete_on_close,apr_pool_t * pool)1094 svn_io_open_unique_file(apr_file_t **file,
1095                         const char **temp_path,
1096                         const char *path,
1097                         const char *suffix,
1098                         svn_boolean_t delete_on_close,
1099                         apr_pool_t *pool)
1100 {
1101   return svn_error_trace(svn_io_open_unique_file2(file, temp_path,
1102                                                   path, suffix,
1103                                                   delete_on_close
1104                                                     ? svn_io_file_del_on_close
1105                                                     : svn_io_file_del_none,
1106                                                   pool));
1107 }
1108 
1109 svn_error_t *
svn_io_run_diff(const char * dir,const char * const * user_args,int num_user_args,const char * label1,const char * label2,const char * from,const char * to,int * pexitcode,apr_file_t * outfile,apr_file_t * errfile,const char * diff_cmd,apr_pool_t * pool)1110 svn_io_run_diff(const char *dir,
1111                 const char *const *user_args,
1112                 int num_user_args,
1113                 const char *label1,
1114                 const char *label2,
1115                 const char *from,
1116                 const char *to,
1117                 int *pexitcode,
1118                 apr_file_t *outfile,
1119                 apr_file_t *errfile,
1120                 const char *diff_cmd,
1121                 apr_pool_t *pool)
1122 {
1123   SVN_ERR(svn_path_cstring_to_utf8(&diff_cmd, diff_cmd, pool));
1124 
1125   return svn_error_trace(svn_io_run_diff2(dir, user_args, num_user_args,
1126                                           label1, label2,
1127                                           from, to, pexitcode,
1128                                           outfile, errfile, diff_cmd,
1129                                           pool));
1130 }
1131 
1132 svn_error_t *
svn_io_run_diff3_2(int * exitcode,const char * dir,const char * mine,const char * older,const char * yours,const char * mine_label,const char * older_label,const char * yours_label,apr_file_t * merged,const char * diff3_cmd,const apr_array_header_t * user_args,apr_pool_t * pool)1133 svn_io_run_diff3_2(int *exitcode,
1134                    const char *dir,
1135                    const char *mine,
1136                    const char *older,
1137                    const char *yours,
1138                    const char *mine_label,
1139                    const char *older_label,
1140                    const char *yours_label,
1141                    apr_file_t *merged,
1142                    const char *diff3_cmd,
1143                    const apr_array_header_t *user_args,
1144                    apr_pool_t *pool)
1145 {
1146   SVN_ERR(svn_path_cstring_to_utf8(&diff3_cmd, diff3_cmd, pool));
1147 
1148   return svn_error_trace(svn_io_run_diff3_3(exitcode, dir,
1149                                             mine, older, yours,
1150                                             mine_label, older_label,
1151                                             yours_label, merged,
1152                                             diff3_cmd, user_args, pool));
1153 }
1154 
1155 svn_error_t *
svn_io_run_diff3(const char * dir,const char * mine,const char * older,const char * yours,const char * mine_label,const char * older_label,const char * yours_label,apr_file_t * merged,int * exitcode,const char * diff3_cmd,apr_pool_t * pool)1156 svn_io_run_diff3(const char *dir,
1157                  const char *mine,
1158                  const char *older,
1159                  const char *yours,
1160                  const char *mine_label,
1161                  const char *older_label,
1162                  const char *yours_label,
1163                  apr_file_t *merged,
1164                  int *exitcode,
1165                  const char *diff3_cmd,
1166                  apr_pool_t *pool)
1167 {
1168   return svn_error_trace(svn_io_run_diff3_2(exitcode, dir, mine, older, yours,
1169                                             mine_label, older_label,
1170                                             yours_label,
1171                                             merged, diff3_cmd, NULL, pool));
1172 }
1173 
1174 svn_error_t *
svn_io_remove_file(const char * path,apr_pool_t * scratch_pool)1175 svn_io_remove_file(const char *path,
1176                    apr_pool_t *scratch_pool)
1177 {
1178   return svn_error_trace(svn_io_remove_file2(path, FALSE, scratch_pool));
1179 }
1180 
svn_io_file_lock(const char * lock_file,svn_boolean_t exclusive,apr_pool_t * pool)1181 svn_error_t *svn_io_file_lock(const char *lock_file,
1182                               svn_boolean_t exclusive,
1183                               apr_pool_t *pool)
1184 {
1185   return svn_io_file_lock2(lock_file, exclusive, FALSE, pool);
1186 }
1187 
1188 svn_error_t *
svn_io_get_dirents2(apr_hash_t ** dirents,const char * path,apr_pool_t * pool)1189 svn_io_get_dirents2(apr_hash_t **dirents,
1190                     const char *path,
1191                     apr_pool_t *pool)
1192 {
1193   /* Note that the first part of svn_io_dirent2_t is identical
1194      to svn_io_dirent_t to allow this construct */
1195   return svn_error_trace(
1196             svn_io_get_dirents3(dirents, path, FALSE, pool, pool));
1197 }
1198 
1199 svn_error_t *
svn_io_get_dirents(apr_hash_t ** dirents,const char * path,apr_pool_t * pool)1200 svn_io_get_dirents(apr_hash_t **dirents,
1201                    const char *path,
1202                    apr_pool_t *pool)
1203 {
1204   /* Note that in C, padding is not allowed at the beginning of structs,
1205      so this is actually portable, since the kind field of svn_io_dirent_t
1206      is first in that struct. */
1207   return svn_io_get_dirents2(dirents, path, pool);
1208 }
1209 
1210 svn_error_t *
svn_io_start_cmd2(apr_proc_t * cmd_proc,const char * path,const char * cmd,const char * const * args,svn_boolean_t inherit,svn_boolean_t infile_pipe,apr_file_t * infile,svn_boolean_t outfile_pipe,apr_file_t * outfile,svn_boolean_t errfile_pipe,apr_file_t * errfile,apr_pool_t * pool)1211 svn_io_start_cmd2(apr_proc_t *cmd_proc,
1212                   const char *path,
1213                   const char *cmd,
1214                   const char *const *args,
1215                   svn_boolean_t inherit,
1216                   svn_boolean_t infile_pipe,
1217                   apr_file_t *infile,
1218                   svn_boolean_t outfile_pipe,
1219                   apr_file_t *outfile,
1220                   svn_boolean_t errfile_pipe,
1221                   apr_file_t *errfile,
1222                   apr_pool_t *pool)
1223 {
1224   return svn_io_start_cmd3(cmd_proc, path, cmd, args, NULL, inherit,
1225                            infile_pipe, infile, outfile_pipe, outfile,
1226                            errfile_pipe, errfile, pool);
1227 }
1228 
1229 svn_error_t *
svn_io_start_cmd(apr_proc_t * cmd_proc,const char * path,const char * cmd,const char * const * args,svn_boolean_t inherit,apr_file_t * infile,apr_file_t * outfile,apr_file_t * errfile,apr_pool_t * pool)1230 svn_io_start_cmd(apr_proc_t *cmd_proc,
1231                  const char *path,
1232                  const char *cmd,
1233                  const char *const *args,
1234                  svn_boolean_t inherit,
1235                  apr_file_t *infile,
1236                  apr_file_t *outfile,
1237                  apr_file_t *errfile,
1238                  apr_pool_t *pool)
1239 {
1240   return svn_io_start_cmd2(cmd_proc, path, cmd, args, inherit, FALSE,
1241                            infile, FALSE, outfile, FALSE, errfile, pool);
1242 }
1243 
1244 svn_error_t *
svn_io_file_read_full(apr_file_t * file,void * buf,apr_size_t nbytes,apr_size_t * bytes_read,apr_pool_t * pool)1245 svn_io_file_read_full(apr_file_t *file, void *buf,
1246                       apr_size_t nbytes, apr_size_t *bytes_read,
1247                       apr_pool_t *pool)
1248 {
1249   return svn_io_file_read_full2(file, buf, nbytes, bytes_read, NULL, pool);
1250 }
1251 
1252 struct walk_func_filter_baton_t
1253 {
1254   svn_io_walk_func_t walk_func;
1255   void *walk_baton;
1256 };
1257 
1258 /* Implements svn_io_walk_func_t, but only allows APR_DIR and APR_REG
1259    finfo types through to the wrapped function/baton.  */
1260 static svn_error_t *
walk_func_filter_func(void * baton,const char * path,const apr_finfo_t * finfo,apr_pool_t * pool)1261 walk_func_filter_func(void *baton,
1262                       const char *path,
1263                       const apr_finfo_t *finfo,
1264                       apr_pool_t *pool)
1265 {
1266   struct walk_func_filter_baton_t *b = baton;
1267 
1268   if (finfo->filetype == APR_DIR || finfo->filetype == APR_REG)
1269     SVN_ERR(b->walk_func(b->walk_baton, path, finfo, pool));
1270 
1271   return SVN_NO_ERROR;
1272 }
1273 
1274 svn_error_t *
svn_io_dir_walk(const char * dirname,apr_int32_t wanted,svn_io_walk_func_t walk_func,void * walk_baton,apr_pool_t * pool)1275 svn_io_dir_walk(const char *dirname,
1276                 apr_int32_t wanted,
1277                 svn_io_walk_func_t walk_func,
1278                 void *walk_baton,
1279                 apr_pool_t *pool)
1280 {
1281   struct walk_func_filter_baton_t baton;
1282   baton.walk_func = walk_func;
1283   baton.walk_baton = walk_baton;
1284   return svn_error_trace(svn_io_dir_walk2(dirname, wanted,
1285                                           walk_func_filter_func,
1286                                           &baton, pool));
1287 }
1288 
1289 svn_error_t *
svn_io_stat_dirent(const svn_io_dirent2_t ** dirent_p,const char * path,svn_boolean_t ignore_enoent,apr_pool_t * result_pool,apr_pool_t * scratch_pool)1290 svn_io_stat_dirent(const svn_io_dirent2_t **dirent_p,
1291                    const char *path,
1292                    svn_boolean_t ignore_enoent,
1293                    apr_pool_t *result_pool,
1294                    apr_pool_t *scratch_pool)
1295 {
1296   return svn_error_trace(
1297             svn_io_stat_dirent2(dirent_p,
1298                                 path,
1299                                 FALSE,
1300                                 ignore_enoent,
1301                                 result_pool,
1302                                 scratch_pool));
1303 }
1304 
1305 svn_error_t *
svn_io_file_rename(const char * from_path,const char * to_path,apr_pool_t * pool)1306 svn_io_file_rename(const char *from_path, const char *to_path,
1307                    apr_pool_t *pool)
1308 {
1309   return svn_error_trace(svn_io_file_rename2(from_path, to_path,
1310                                              FALSE, pool));
1311 }
1312 
1313 svn_error_t *
svn_io_write_atomic(const char * final_path,const void * buf,apr_size_t nbytes,const char * copy_perms_path,apr_pool_t * scratch_pool)1314 svn_io_write_atomic(const char *final_path,
1315                     const void *buf,
1316                     apr_size_t nbytes,
1317                     const char *copy_perms_path,
1318                     apr_pool_t *scratch_pool)
1319 {
1320   return svn_error_trace(svn_io_write_atomic2(final_path, buf, nbytes,
1321                                               copy_perms_path, TRUE,
1322                                               scratch_pool));
1323 }
1324 
1325 /*** From constructors.c ***/
1326 svn_log_changed_path_t *
svn_log_changed_path_dup(const svn_log_changed_path_t * changed_path,apr_pool_t * pool)1327 svn_log_changed_path_dup(const svn_log_changed_path_t *changed_path,
1328                          apr_pool_t *pool)
1329 {
1330   svn_log_changed_path_t *new_changed_path
1331     = apr_palloc(pool, sizeof(*new_changed_path));
1332 
1333   *new_changed_path = *changed_path;
1334 
1335   if (new_changed_path->copyfrom_path)
1336     new_changed_path->copyfrom_path =
1337       apr_pstrdup(pool, new_changed_path->copyfrom_path);
1338 
1339   return new_changed_path;
1340 }
1341 
1342 /*** From cmdline.c ***/
1343 svn_error_t *
svn_cmdline_prompt_user(const char ** result,const char * prompt_str,apr_pool_t * pool)1344 svn_cmdline_prompt_user(const char **result,
1345                         const char *prompt_str,
1346                         apr_pool_t *pool)
1347 {
1348   return svn_error_trace(svn_cmdline_prompt_user2(result, prompt_str, NULL,
1349                                                   pool));
1350 }
1351 
1352 svn_error_t *
svn_cmdline_setup_auth_baton(svn_auth_baton_t ** ab,svn_boolean_t non_interactive,const char * auth_username,const char * auth_password,const char * config_dir,svn_boolean_t no_auth_cache,svn_config_t * cfg,svn_cancel_func_t cancel_func,void * cancel_baton,apr_pool_t * pool)1353 svn_cmdline_setup_auth_baton(svn_auth_baton_t **ab,
1354                              svn_boolean_t non_interactive,
1355                              const char *auth_username,
1356                              const char *auth_password,
1357                              const char *config_dir,
1358                              svn_boolean_t no_auth_cache,
1359                              svn_config_t *cfg,
1360                              svn_cancel_func_t cancel_func,
1361                              void *cancel_baton,
1362                              apr_pool_t *pool)
1363 {
1364   return svn_error_trace(svn_cmdline_create_auth_baton(
1365                            ab, non_interactive,
1366                            auth_username, auth_password,
1367                            config_dir, no_auth_cache, FALSE,
1368                            cfg, cancel_func, cancel_baton, pool));
1369 }
1370 
1371 /*** From dso.c ***/
1372 void
svn_dso_initialize(void)1373 svn_dso_initialize(void)
1374 {
1375   svn_error_t *err = svn_dso_initialize2();
1376   if (err)
1377     {
1378       svn_error_clear(err);
1379       abort();
1380     }
1381 }
1382 
1383 /*** From simple_providers.c ***/
1384 void
svn_auth_get_simple_provider(svn_auth_provider_object_t ** provider,apr_pool_t * pool)1385 svn_auth_get_simple_provider(svn_auth_provider_object_t **provider,
1386                              apr_pool_t *pool)
1387 {
1388   svn_auth_get_simple_provider2(provider, NULL, NULL, pool);
1389 }
1390 
1391 /*** From ssl_client_cert_pw_providers.c ***/
1392 void
svn_auth_get_ssl_client_cert_pw_file_provider(svn_auth_provider_object_t ** provider,apr_pool_t * pool)1393 svn_auth_get_ssl_client_cert_pw_file_provider
1394   (svn_auth_provider_object_t **provider,
1395    apr_pool_t *pool)
1396 {
1397   svn_auth_get_ssl_client_cert_pw_file_provider2(provider, NULL, NULL, pool);
1398 }
1399 
1400 /*** From path.c ***/
1401 
1402 #define SVN_EMPTY_PATH ""
1403 
1404 const char *
svn_path_url_add_component(const char * url,const char * component,apr_pool_t * pool)1405 svn_path_url_add_component(const char *url,
1406                            const char *component,
1407                            apr_pool_t *pool)
1408 {
1409   /* URL can have trailing '/' */
1410   url = svn_path_canonicalize(url, pool);
1411 
1412   return svn_path_url_add_component2(url, component, pool);
1413 }
1414 
1415 void
svn_path_split(const char * path,const char ** dirpath,const char ** base_name,apr_pool_t * pool)1416 svn_path_split(const char *path,
1417                const char **dirpath,
1418                const char **base_name,
1419                apr_pool_t *pool)
1420 {
1421   assert(dirpath != base_name);
1422 
1423   if (dirpath)
1424     *dirpath = svn_path_dirname(path, pool);
1425 
1426   if (base_name)
1427     *base_name = svn_path_basename(path, pool);
1428 }
1429 
1430 
1431 svn_error_t *
svn_path_split_if_file(const char * path,const char ** pdirectory,const char ** pfile,apr_pool_t * pool)1432 svn_path_split_if_file(const char *path,
1433                        const char **pdirectory,
1434                        const char **pfile,
1435                        apr_pool_t *pool)
1436 {
1437   apr_finfo_t finfo;
1438   svn_error_t *err;
1439 
1440   SVN_ERR_ASSERT(svn_path_is_canonical(path, pool));
1441 
1442   err = svn_io_stat(&finfo, path, APR_FINFO_TYPE, pool);
1443   if (err && ! APR_STATUS_IS_ENOENT(err->apr_err))
1444     return err;
1445 
1446   if (err || finfo.filetype == APR_REG)
1447     {
1448       svn_error_clear(err);
1449       svn_path_split(path, pdirectory, pfile, pool);
1450     }
1451   else if (finfo.filetype == APR_DIR)
1452     {
1453       *pdirectory = path;
1454       *pfile = SVN_EMPTY_PATH;
1455     }
1456   else
1457     {
1458       return svn_error_createf(SVN_ERR_BAD_FILENAME, NULL,
1459                                _("'%s' is neither a file nor a directory name"),
1460                                svn_path_local_style(path, pool));
1461     }
1462 
1463   return SVN_NO_ERROR;
1464 }
1465 
1466 /*** From stream.c ***/
svn_stream_copy2(svn_stream_t * from,svn_stream_t * to,svn_cancel_func_t cancel_func,void * cancel_baton,apr_pool_t * scratch_pool)1467 svn_error_t *svn_stream_copy2(svn_stream_t *from, svn_stream_t *to,
1468                               svn_cancel_func_t cancel_func,
1469                               void *cancel_baton,
1470                               apr_pool_t *scratch_pool)
1471 {
1472   return svn_error_trace(svn_stream_copy3(
1473                            svn_stream_disown(from, scratch_pool),
1474                            svn_stream_disown(to, scratch_pool),
1475                            cancel_func, cancel_baton, scratch_pool));
1476 }
1477 
svn_stream_copy(svn_stream_t * from,svn_stream_t * to,apr_pool_t * scratch_pool)1478 svn_error_t *svn_stream_copy(svn_stream_t *from, svn_stream_t *to,
1479                              apr_pool_t *scratch_pool)
1480 {
1481   return svn_error_trace(svn_stream_copy3(
1482                            svn_stream_disown(from, scratch_pool),
1483                            svn_stream_disown(to, scratch_pool),
1484                            NULL, NULL, scratch_pool));
1485 }
1486 
1487 svn_stream_t *
svn_stream_from_aprfile(apr_file_t * file,apr_pool_t * pool)1488 svn_stream_from_aprfile(apr_file_t *file, apr_pool_t *pool)
1489 {
1490   return svn_stream_from_aprfile2(file, TRUE, pool);
1491 }
1492 
1493 svn_error_t *
svn_stream_for_stdin(svn_stream_t ** in,apr_pool_t * pool)1494 svn_stream_for_stdin(svn_stream_t **in, apr_pool_t *pool)
1495 {
1496   return svn_error_trace(svn_stream_for_stdin2(in, FALSE, pool));
1497 }
1498 
1499 svn_error_t *
svn_stream_contents_same(svn_boolean_t * same,svn_stream_t * stream1,svn_stream_t * stream2,apr_pool_t * pool)1500 svn_stream_contents_same(svn_boolean_t *same,
1501                          svn_stream_t *stream1,
1502                          svn_stream_t *stream2,
1503                          apr_pool_t *pool)
1504 {
1505   return svn_error_trace(svn_stream_contents_same2(
1506                            same,
1507                            svn_stream_disown(stream1, pool),
1508                            svn_stream_disown(stream2, pool),
1509                            pool));
1510 }
1511 
1512 void
svn_stream_set_read(svn_stream_t * stream,svn_read_fn_t read_fn)1513 svn_stream_set_read(svn_stream_t *stream,
1514                     svn_read_fn_t read_fn)
1515 {
1516   svn_stream_set_read2(stream, NULL /* only full read support */,
1517                        read_fn);
1518 }
1519 
1520 svn_error_t *
svn_stream_read(svn_stream_t * stream,char * buffer,apr_size_t * len)1521 svn_stream_read(svn_stream_t *stream,
1522                 char *buffer,
1523                 apr_size_t *len)
1524 {
1525   return svn_error_trace(svn_stream_read_full(stream, buffer, len));
1526 }
1527 
1528 struct md5_stream_baton
1529 {
1530   const unsigned char **read_digest;
1531   const unsigned char **write_digest;
1532   svn_checksum_t *read_checksum;
1533   svn_checksum_t *write_checksum;
1534   svn_stream_t *proxy;
1535   apr_pool_t *pool;
1536 };
1537 
1538 static svn_error_t *
read_handler_md5(void * baton,char * buffer,apr_size_t * len)1539 read_handler_md5(void *baton, char *buffer, apr_size_t *len)
1540 {
1541   struct md5_stream_baton *btn = baton;
1542   return svn_error_trace(svn_stream_read2(btn->proxy, buffer, len));
1543 }
1544 
1545 static svn_error_t *
read_full_handler_md5(void * baton,char * buffer,apr_size_t * len)1546 read_full_handler_md5(void *baton, char *buffer, apr_size_t *len)
1547 {
1548   struct md5_stream_baton *btn = baton;
1549   return svn_error_trace(svn_stream_read_full(btn->proxy, buffer, len));
1550 }
1551 
1552 static svn_error_t *
skip_handler_md5(void * baton,apr_size_t len)1553 skip_handler_md5(void *baton, apr_size_t len)
1554 {
1555   struct md5_stream_baton *btn = baton;
1556   return svn_error_trace(svn_stream_skip(btn->proxy, len));
1557 }
1558 
1559 static svn_error_t *
write_handler_md5(void * baton,const char * buffer,apr_size_t * len)1560 write_handler_md5(void *baton, const char *buffer, apr_size_t *len)
1561 {
1562   struct md5_stream_baton *btn = baton;
1563   return svn_error_trace(svn_stream_write(btn->proxy, buffer, len));
1564 }
1565 
1566 static svn_error_t *
close_handler_md5(void * baton)1567 close_handler_md5(void *baton)
1568 {
1569   struct md5_stream_baton *btn = baton;
1570 
1571   SVN_ERR(svn_stream_close(btn->proxy));
1572 
1573   if (btn->read_digest)
1574     *btn->read_digest
1575       = apr_pmemdup(btn->pool, btn->read_checksum->digest,
1576                     APR_MD5_DIGESTSIZE);
1577 
1578   if (btn->write_digest)
1579     *btn->write_digest
1580       = apr_pmemdup(btn->pool, btn->write_checksum->digest,
1581                     APR_MD5_DIGESTSIZE);
1582 
1583   return SVN_NO_ERROR;
1584 }
1585 
1586 
1587 svn_stream_t *
svn_stream_checksummed(svn_stream_t * stream,const unsigned char ** read_digest,const unsigned char ** write_digest,svn_boolean_t read_all,apr_pool_t * pool)1588 svn_stream_checksummed(svn_stream_t *stream,
1589                        const unsigned char **read_digest,
1590                        const unsigned char **write_digest,
1591                        svn_boolean_t read_all,
1592                        apr_pool_t *pool)
1593 {
1594   svn_stream_t *s;
1595   struct md5_stream_baton *baton;
1596 
1597   if (! read_digest && ! write_digest)
1598     return stream;
1599 
1600   baton = apr_palloc(pool, sizeof(*baton));
1601   baton->read_digest = read_digest;
1602   baton->write_digest = write_digest;
1603   baton->pool = pool;
1604 
1605   /* Set BATON->proxy to a stream that will fill in BATON->read_checksum
1606    * and BATON->write_checksum (if we want them) when it is closed. */
1607   baton->proxy
1608     = svn_stream_checksummed2(stream,
1609                               read_digest ? &baton->read_checksum : NULL,
1610                               write_digest ? &baton->write_checksum : NULL,
1611                               svn_checksum_md5,
1612                               read_all, pool);
1613 
1614   /* Create a stream that will forward its read/write/close operations to
1615    * BATON->proxy and will fill in *READ_DIGEST and *WRITE_DIGEST (if we
1616    * want them) after it closes BATON->proxy. */
1617   s = svn_stream_create(baton, pool);
1618   svn_stream_set_read2(s, read_handler_md5, read_full_handler_md5);
1619   svn_stream_set_skip(s, skip_handler_md5);
1620   svn_stream_set_write(s, write_handler_md5);
1621   svn_stream_set_close(s, close_handler_md5);
1622   return s;
1623 }
1624 
1625 svn_error_t *
svn_string_from_stream(svn_string_t ** result,svn_stream_t * stream,apr_pool_t * result_pool,apr_pool_t * scratch_pool)1626 svn_string_from_stream(svn_string_t **result,
1627                        svn_stream_t *stream,
1628                        apr_pool_t *result_pool,
1629                        apr_pool_t *scratch_pool)
1630 {
1631   return svn_error_trace(svn_string_from_stream2(result, stream, 0,
1632                                                  result_pool));
1633 }
1634 
1635 /*** From path.c ***/
1636 
1637 const char *
svn_path_internal_style(const char * path,apr_pool_t * pool)1638 svn_path_internal_style(const char *path, apr_pool_t *pool)
1639 {
1640   if (svn_path_is_url(path))
1641     return svn_uri_canonicalize(path, pool);
1642   else
1643     return svn_dirent_internal_style(path, pool);
1644 }
1645 
1646 
1647 const char *
svn_path_local_style(const char * path,apr_pool_t * pool)1648 svn_path_local_style(const char *path, apr_pool_t *pool)
1649 {
1650   if (svn_path_is_url(path))
1651     return apr_pstrdup(pool, path);
1652   else
1653     return svn_dirent_local_style(path, pool);
1654 }
1655 
1656 const char *
svn_path_canonicalize(const char * path,apr_pool_t * pool)1657 svn_path_canonicalize(const char *path, apr_pool_t *pool)
1658 {
1659   if (svn_path_is_url(path))
1660     return svn_uri_canonicalize(path, pool);
1661   else
1662     return svn_dirent_canonicalize(path, pool);
1663 }
1664 
1665 
1666 /*** From mergeinfo.c ***/
1667 
1668 svn_error_t *
svn_mergeinfo_inheritable(svn_mergeinfo_t * output,svn_mergeinfo_t mergeinfo,const char * path,svn_revnum_t start,svn_revnum_t end,apr_pool_t * pool)1669 svn_mergeinfo_inheritable(svn_mergeinfo_t *output,
1670                           svn_mergeinfo_t mergeinfo,
1671                           const char *path,
1672                           svn_revnum_t start,
1673                           svn_revnum_t end,
1674                           apr_pool_t *pool)
1675 {
1676   return svn_error_trace(svn_mergeinfo_inheritable2(output, mergeinfo, path,
1677                                                     start, end,
1678                                                     TRUE, pool, pool));
1679 }
1680 
1681 svn_error_t *
svn_rangelist_inheritable(svn_rangelist_t ** inheritable_rangelist,const svn_rangelist_t * rangelist,svn_revnum_t start,svn_revnum_t end,apr_pool_t * pool)1682 svn_rangelist_inheritable(svn_rangelist_t **inheritable_rangelist,
1683                           const svn_rangelist_t *rangelist,
1684                           svn_revnum_t start,
1685                           svn_revnum_t end,
1686                           apr_pool_t *pool)
1687 {
1688   return svn_error_trace(svn_rangelist_inheritable2(inheritable_rangelist,
1689                                                     rangelist,
1690                                                     start, end, TRUE,
1691                                                     pool, pool));
1692 }
1693 
1694 svn_error_t *
svn_rangelist_merge(svn_rangelist_t ** rangelist,const svn_rangelist_t * changes,apr_pool_t * pool)1695 svn_rangelist_merge(svn_rangelist_t **rangelist,
1696                     const svn_rangelist_t *changes,
1697                     apr_pool_t *pool)
1698 {
1699   SVN_ERR(svn_rangelist_merge2(*rangelist, changes,
1700                                pool, pool));
1701 
1702   return svn_error_trace(
1703             svn_rangelist__canonicalize(*rangelist, pool));
1704 }
1705 
1706 svn_error_t *
svn_mergeinfo_diff(svn_mergeinfo_t * deleted,svn_mergeinfo_t * added,svn_mergeinfo_t from,svn_mergeinfo_t to,svn_boolean_t consider_inheritance,apr_pool_t * pool)1707 svn_mergeinfo_diff(svn_mergeinfo_t *deleted, svn_mergeinfo_t *added,
1708                    svn_mergeinfo_t from, svn_mergeinfo_t to,
1709                    svn_boolean_t consider_inheritance,
1710                    apr_pool_t *pool)
1711 {
1712   return svn_error_trace(svn_mergeinfo_diff2(deleted, added, from, to,
1713                                              consider_inheritance, pool,
1714                                              pool));
1715 }
1716 
1717 svn_error_t *
svn_mergeinfo_merge(svn_mergeinfo_t mergeinfo,svn_mergeinfo_t changes,apr_pool_t * pool)1718 svn_mergeinfo_merge(svn_mergeinfo_t mergeinfo,
1719                     svn_mergeinfo_t changes,
1720                     apr_pool_t *pool)
1721 {
1722   return svn_error_trace(svn_mergeinfo_merge2(mergeinfo, changes, pool,
1723                          pool));
1724 }
1725 
1726 svn_error_t *
svn_mergeinfo_remove(svn_mergeinfo_t * mergeinfo,svn_mergeinfo_t eraser,svn_mergeinfo_t whiteboard,apr_pool_t * pool)1727 svn_mergeinfo_remove(svn_mergeinfo_t *mergeinfo, svn_mergeinfo_t eraser,
1728                      svn_mergeinfo_t whiteboard, apr_pool_t *pool)
1729 {
1730   return svn_mergeinfo_remove2(mergeinfo, eraser, whiteboard, TRUE, pool,
1731                                pool);
1732 }
1733 
1734 svn_error_t *
svn_mergeinfo_intersect(svn_mergeinfo_t * mergeinfo,svn_mergeinfo_t mergeinfo1,svn_mergeinfo_t mergeinfo2,apr_pool_t * pool)1735 svn_mergeinfo_intersect(svn_mergeinfo_t *mergeinfo,
1736                         svn_mergeinfo_t mergeinfo1,
1737                         svn_mergeinfo_t mergeinfo2,
1738                         apr_pool_t *pool)
1739 {
1740   return svn_mergeinfo_intersect2(mergeinfo, mergeinfo1, mergeinfo2,
1741                                   TRUE, pool, pool);
1742 }
1743 
1744 /*** From config.c ***/
1745 svn_error_t *
svn_config_create(svn_config_t ** cfgp,svn_boolean_t section_names_case_sensitive,apr_pool_t * result_pool)1746 svn_config_create(svn_config_t **cfgp,
1747                   svn_boolean_t section_names_case_sensitive,
1748                   apr_pool_t *result_pool)
1749 {
1750   return svn_error_trace(svn_config_create2(cfgp,
1751                                             section_names_case_sensitive,
1752                                             FALSE,
1753                                             result_pool));
1754 }
1755 
1756 svn_error_t *
svn_config_read2(svn_config_t ** cfgp,const char * file,svn_boolean_t must_exist,svn_boolean_t section_names_case_sensitive,apr_pool_t * result_pool)1757 svn_config_read2(svn_config_t **cfgp, const char *file,
1758                  svn_boolean_t must_exist,
1759                  svn_boolean_t section_names_case_sensitive,
1760                  apr_pool_t *result_pool)
1761 {
1762   return svn_error_trace(svn_config_read3(cfgp, file,
1763                                           must_exist,
1764                                           section_names_case_sensitive,
1765                                           FALSE,
1766                                           result_pool));
1767 }
1768 
1769 svn_error_t *
svn_config_read(svn_config_t ** cfgp,const char * file,svn_boolean_t must_exist,apr_pool_t * result_pool)1770 svn_config_read(svn_config_t **cfgp, const char *file,
1771                 svn_boolean_t must_exist,
1772                 apr_pool_t *result_pool)
1773 {
1774   return svn_error_trace(svn_config_read3(cfgp, file,
1775                                           must_exist,
1776                                           FALSE, FALSE,
1777                                           result_pool));
1778 }
1779 
1780 #ifdef SVN_DISABLE_FULL_VERSION_MATCH
1781 /* This double underscore name is used by the 1.6 command line client.
1782    Keeping this name is sufficient for the 1.6 client to use the 1.7
1783    libraries at runtime. */
1784 svn_error_t *
1785 svn_opt__eat_peg_revisions(apr_array_header_t **true_targets_p,
1786                            apr_array_header_t *targets,
1787                            apr_pool_t *pool);
1788 svn_error_t *
svn_opt__eat_peg_revisions(apr_array_header_t ** true_targets_p,apr_array_header_t * targets,apr_pool_t * pool)1789 svn_opt__eat_peg_revisions(apr_array_header_t **true_targets_p,
1790                            apr_array_header_t *targets,
1791                            apr_pool_t *pool)
1792 {
1793   unsigned int i;
1794   apr_array_header_t *true_targets;
1795 
1796   true_targets = apr_array_make(pool, 5, sizeof(const char *));
1797 
1798   for (i = 0; i < targets->nelts; i++)
1799     {
1800       const char *target = APR_ARRAY_IDX(targets, i, const char *);
1801       const char *true_target;
1802 
1803       SVN_ERR(svn_opt__split_arg_at_peg_revision(&true_target, NULL,
1804                                                  target, pool));
1805       APR_ARRAY_PUSH(true_targets, const char *) = true_target;
1806     }
1807 
1808   SVN_ERR_ASSERT(true_targets_p);
1809   *true_targets_p = true_targets;
1810 
1811   return SVN_NO_ERROR;
1812 }
1813 #endif
1814 
1815 void
svn_xml_make_header(svn_stringbuf_t ** str,apr_pool_t * pool)1816 svn_xml_make_header(svn_stringbuf_t **str, apr_pool_t *pool)
1817 {
1818   svn_xml_make_header2(str, NULL, pool);
1819 }
1820 
1821 
1822 /*** From utf.c ***/
1823 void
svn_utf_initialize(apr_pool_t * pool)1824 svn_utf_initialize(apr_pool_t *pool)
1825 {
1826   svn_utf_initialize2(FALSE, pool);
1827 }
1828 
1829 svn_error_t *
svn_utf_cstring_from_utf8_ex(const char ** dest,const char * src,const char * topage,const char * convset_key,apr_pool_t * pool)1830 svn_utf_cstring_from_utf8_ex(const char **dest,
1831                              const char *src,
1832                              const char *topage,
1833                              const char *convset_key,
1834                              apr_pool_t *pool)
1835 {
1836   return svn_utf_cstring_from_utf8_ex2(dest, src, topage, pool);
1837 }
1838 
1839 /*** From error.c ***/
1840 void
svn_handle_error(svn_error_t * err,FILE * stream,svn_boolean_t fatal)1841 svn_handle_error(svn_error_t *err, FILE *stream, svn_boolean_t fatal)
1842 {
1843   svn_handle_error2(err, stream, fatal, "svn: ");
1844 }
1845 
1846 void
svn_handle_warning(FILE * stream,svn_error_t * err)1847 svn_handle_warning(FILE *stream, svn_error_t *err)
1848 {
1849   svn_handle_warning2(stream, err, "svn: ");
1850 }
1851 
1852 
1853 /*** From subst.c ***/
1854 svn_error_t *
svn_subst_build_keywords(svn_subst_keywords_t * kw,const char * keywords_val,const char * rev,const char * url,apr_time_t date,const char * author,apr_pool_t * pool)1855 svn_subst_build_keywords(svn_subst_keywords_t *kw,
1856                          const char *keywords_val,
1857                          const char *rev,
1858                          const char *url,
1859                          apr_time_t date,
1860                          const char *author,
1861                          apr_pool_t *pool)
1862 {
1863   apr_hash_t *kwhash;
1864   const svn_string_t *val;
1865 
1866   SVN_ERR(svn_subst_build_keywords2(&kwhash, keywords_val, rev,
1867                                     url, date, author, pool));
1868 
1869   /* The behaviour of pre-1.3 svn_subst_build_keywords, which we are
1870    * replicating here, is to write to a slot in the svn_subst_keywords_t
1871    * only if the relevant keyword was present in keywords_val, otherwise
1872    * leaving that slot untouched. */
1873 
1874   val = svn_hash_gets(kwhash, SVN_KEYWORD_REVISION_LONG);
1875   if (val)
1876     kw->revision = val;
1877 
1878   val = svn_hash_gets(kwhash, SVN_KEYWORD_DATE_LONG);
1879   if (val)
1880     kw->date = val;
1881 
1882   val = svn_hash_gets(kwhash, SVN_KEYWORD_AUTHOR_LONG);
1883   if (val)
1884     kw->author = val;
1885 
1886   val = svn_hash_gets(kwhash, SVN_KEYWORD_URL_LONG);
1887   if (val)
1888     kw->url = val;
1889 
1890   val = svn_hash_gets(kwhash, SVN_KEYWORD_ID);
1891   if (val)
1892     kw->id = val;
1893 
1894   return SVN_NO_ERROR;
1895 }
1896 
1897 /*** From version.c ***/
1898 svn_error_t *
svn_ver_check_list(const svn_version_t * my_version,const svn_version_checklist_t * checklist)1899 svn_ver_check_list(const svn_version_t *my_version,
1900                    const svn_version_checklist_t *checklist)
1901 {
1902   return svn_ver_check_list2(my_version, checklist, svn_ver_compatible);
1903 }
1904 
1905 /*** From win32_crypto.c ***/
1906 #if defined(WIN32) && !defined(__MINGW32__)
1907 void
svn_auth_get_windows_simple_provider(svn_auth_provider_object_t ** provider,apr_pool_t * pool)1908 svn_auth_get_windows_simple_provider(svn_auth_provider_object_t **provider,
1909                                      apr_pool_t *pool)
1910 {
1911   svn_auth__get_windows_simple_provider(provider, pool);
1912 }
1913 
1914 void
svn_auth_get_windows_ssl_client_cert_pw_provider(svn_auth_provider_object_t ** provider,apr_pool_t * pool)1915 svn_auth_get_windows_ssl_client_cert_pw_provider
1916    (svn_auth_provider_object_t **provider,
1917     apr_pool_t *pool)
1918 {
1919   svn_auth__get_windows_ssl_client_cert_pw_provider(provider, pool);
1920 }
1921 
1922 void
svn_auth_get_windows_ssl_server_trust_provider(svn_auth_provider_object_t ** provider,apr_pool_t * pool)1923 svn_auth_get_windows_ssl_server_trust_provider
1924   (svn_auth_provider_object_t **provider, apr_pool_t *pool)
1925 {
1926   svn_auth__get_windows_ssl_server_trust_provider(provider, pool);
1927 }
1928 #endif /* WIN32 && !__MINGW32__ */
1929 
1930 /*** From macos_keychain.c ***/
1931 #if defined(DARWIN)
1932 void
svn_auth_get_keychain_simple_provider(svn_auth_provider_object_t ** provider,apr_pool_t * pool)1933 svn_auth_get_keychain_simple_provider(svn_auth_provider_object_t **provider,
1934                                       apr_pool_t *pool)
1935 {
1936 #ifdef SVN_HAVE_KEYCHAIN_SERVICES
1937   svn_auth__get_keychain_simple_provider(provider, pool);
1938 #else
1939   svn_auth__get_dummmy_simple_provider(provider, pool);
1940 #endif
1941 }
1942 
1943 void
svn_auth_get_keychain_ssl_client_cert_pw_provider(svn_auth_provider_object_t ** provider,apr_pool_t * pool)1944 svn_auth_get_keychain_ssl_client_cert_pw_provider
1945   (svn_auth_provider_object_t **provider,
1946    apr_pool_t *pool)
1947 {
1948 #ifdef SVN_HAVE_KEYCHAIN_SERVICES
1949   svn_auth__get_keychain_ssl_client_cert_pw_provider(provider, pool);
1950 #else
1951   /* Not really the right type of dummy provider, but doesn't throw NULL
1952      errors as just returning NULL would */
1953   svn_auth__get_dummmy_simple_provider(provider, pool);
1954 #endif
1955 }
1956 #endif /* DARWIN */
1957 
1958 #if !defined(WIN32)
1959 void
svn_auth_get_gpg_agent_simple_provider(svn_auth_provider_object_t ** provider,apr_pool_t * pool)1960 svn_auth_get_gpg_agent_simple_provider(svn_auth_provider_object_t **provider,
1961                                        apr_pool_t *pool)
1962 {
1963 #ifdef SVN_HAVE_GPG_AGENT
1964   svn_auth__get_gpg_agent_simple_provider(provider, pool);
1965 #else
1966   svn_auth__get_dummmy_simple_provider(provider, pool);
1967 #endif /* SVN_HAVE_GPG_AGENT */
1968 }
1969 #endif /* !WIN32 */
1970 
1971 svn_error_t *
svn_cmdline_create_auth_baton(svn_auth_baton_t ** ab,svn_boolean_t non_interactive,const char * auth_username,const char * auth_password,const char * config_dir,svn_boolean_t no_auth_cache,svn_boolean_t trust_server_cert,svn_config_t * cfg,svn_cancel_func_t cancel_func,void * cancel_baton,apr_pool_t * pool)1972 svn_cmdline_create_auth_baton(svn_auth_baton_t **ab,
1973                               svn_boolean_t non_interactive,
1974                               const char *auth_username,
1975                               const char *auth_password,
1976                               const char *config_dir,
1977                               svn_boolean_t no_auth_cache,
1978                               svn_boolean_t trust_server_cert,
1979                               svn_config_t *cfg,
1980                               svn_cancel_func_t cancel_func,
1981                               void *cancel_baton,
1982                               apr_pool_t *pool)
1983 {
1984   return svn_error_trace(svn_cmdline_create_auth_baton2(ab,
1985                                                         non_interactive,
1986                                                         auth_username,
1987                                                         auth_password,
1988                                                         config_dir,
1989                                                         no_auth_cache,
1990                                                         trust_server_cert,
1991                                                         FALSE,
1992                                                         FALSE,
1993                                                         FALSE,
1994                                                         FALSE,
1995                                                         cfg,
1996                                                         cancel_func,
1997                                                         cancel_baton,
1998                                                         pool));
1999 }
2000 
2001 /*** From base64.c ***/
2002 svn_stream_t *
svn_base64_encode(svn_stream_t * output,apr_pool_t * pool)2003 svn_base64_encode(svn_stream_t *output, apr_pool_t *pool)
2004 {
2005   return svn_base64_encode2(output, TRUE, pool);
2006 }
2007 
2008 /*** From string.c ***/
2009 char *
svn_cstring_join(const apr_array_header_t * strings,const char * separator,apr_pool_t * pool)2010 svn_cstring_join(const apr_array_header_t *strings,
2011                  const char *separator,
2012                  apr_pool_t *pool)
2013 {
2014   return svn_cstring_join2(strings, separator, TRUE, pool);
2015 }
2016