]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/subversion/subversion/libsvn_subr/deprecated.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / subversion / subversion / libsvn_subr / deprecated.c
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 \f
29 #include <assert.h>
30
31 /* We define this here to remove any further warnings about the usage of
32    deprecated functions in this file. */
33 #define SVN_DEPRECATED
34
35 #include "svn_hash.h"
36 #include "svn_subst.h"
37 #include "svn_path.h"
38 #include "svn_opt.h"
39 #include "svn_cmdline.h"
40 #include "svn_version.h"
41 #include "svn_pools.h"
42 #include "svn_dso.h"
43 #include "svn_mergeinfo.h"
44 #include "svn_utf.h"
45 #include "svn_xml.h"
46
47 #include "opt.h"
48 #include "private/svn_opt_private.h"
49 #include "private/svn_mergeinfo_private.h"
50
51 #include "svn_private_config.h"
52
53
54
55 \f
56 /*** Code. ***/
57
58 /*** From subst.c ***/
59 /* Convert an old-style svn_subst_keywords_t struct * into a new-style
60  * keywords hash.  Keyword values are shallow copies, so the produced
61  * hash must not be assumed to have lifetime longer than the struct it
62  * is based on.  A NULL input causes a NULL output. */
63 static apr_hash_t *
64 kwstruct_to_kwhash(const svn_subst_keywords_t *kwstruct,
65                    apr_pool_t *pool)
66 {
67   apr_hash_t *kwhash;
68
69   if (kwstruct == NULL)
70     return NULL;
71
72   kwhash = apr_hash_make(pool);
73
74   if (kwstruct->revision)
75     {
76       svn_hash_sets(kwhash, SVN_KEYWORD_REVISION_LONG, kwstruct->revision);
77       svn_hash_sets(kwhash, SVN_KEYWORD_REVISION_MEDIUM, kwstruct->revision);
78       svn_hash_sets(kwhash, SVN_KEYWORD_REVISION_SHORT, kwstruct->revision);
79     }
80   if (kwstruct->date)
81     {
82       svn_hash_sets(kwhash, SVN_KEYWORD_DATE_LONG, kwstruct->date);
83       svn_hash_sets(kwhash, SVN_KEYWORD_DATE_SHORT, kwstruct->date);
84     }
85   if (kwstruct->author)
86     {
87       svn_hash_sets(kwhash, SVN_KEYWORD_AUTHOR_LONG, kwstruct->author);
88       svn_hash_sets(kwhash, SVN_KEYWORD_AUTHOR_SHORT, kwstruct->author);
89     }
90   if (kwstruct->url)
91     {
92       svn_hash_sets(kwhash, SVN_KEYWORD_URL_LONG, kwstruct->url);
93       svn_hash_sets(kwhash, SVN_KEYWORD_URL_SHORT, kwstruct->url);
94     }
95   if (kwstruct->id)
96     {
97       svn_hash_sets(kwhash, SVN_KEYWORD_ID, kwstruct->id);
98     }
99
100   return kwhash;
101 }
102
103
104 svn_error_t *
105 svn_subst_translate_stream3(svn_stream_t *src_stream,
106                             svn_stream_t *dst_stream,
107                             const char *eol_str,
108                             svn_boolean_t repair,
109                             apr_hash_t *keywords,
110                             svn_boolean_t expand,
111                             apr_pool_t *pool)
112 {
113   /* The docstring requires that *some* translation be requested. */
114   SVN_ERR_ASSERT(eol_str || keywords);
115
116   /* We don't want the copy3 to close the provided streams. */
117   src_stream = svn_stream_disown(src_stream, pool);
118   dst_stream = svn_stream_disown(dst_stream, pool);
119
120   /* Wrap the destination stream with our translation stream. It is more
121      efficient than wrapping the source stream. */
122   dst_stream = svn_subst_stream_translated(dst_stream, eol_str, repair,
123                                            keywords, expand, pool);
124
125   return svn_error_trace(svn_stream_copy3(src_stream, dst_stream,
126                                           NULL, NULL, pool));
127 }
128
129 svn_error_t *
130 svn_subst_translate_stream2(svn_stream_t *s, /* src stream */
131                             svn_stream_t *d, /* dst stream */
132                             const char *eol_str,
133                             svn_boolean_t repair,
134                             const svn_subst_keywords_t *keywords,
135                             svn_boolean_t expand,
136                             apr_pool_t *pool)
137 {
138   apr_hash_t *kh = kwstruct_to_kwhash(keywords, pool);
139
140   return svn_error_trace(svn_subst_translate_stream3(s, d, eol_str, repair,
141                                                      kh, expand, pool));
142 }
143
144 svn_error_t *
145 svn_subst_translate_stream(svn_stream_t *s, /* src stream */
146                            svn_stream_t *d, /* dst stream */
147                            const char *eol_str,
148                            svn_boolean_t repair,
149                            const svn_subst_keywords_t *keywords,
150                            svn_boolean_t expand)
151 {
152   apr_pool_t *pool = svn_pool_create(NULL);
153   svn_error_t *err = svn_subst_translate_stream2(s, d, eol_str, repair,
154                                                  keywords, expand, pool);
155   svn_pool_destroy(pool);
156   return svn_error_trace(err);
157 }
158
159 svn_error_t *
160 svn_subst_translate_cstring(const char *src,
161                             const char **dst,
162                             const char *eol_str,
163                             svn_boolean_t repair,
164                             const svn_subst_keywords_t *keywords,
165                             svn_boolean_t expand,
166                             apr_pool_t *pool)
167 {
168   apr_hash_t *kh = kwstruct_to_kwhash(keywords, pool);
169
170   return svn_error_trace(svn_subst_translate_cstring2(src, dst, eol_str,
171                                                       repair, kh, expand,
172                                                       pool));
173 }
174
175 svn_error_t *
176 svn_subst_copy_and_translate(const char *src,
177                              const char *dst,
178                              const char *eol_str,
179                              svn_boolean_t repair,
180                              const svn_subst_keywords_t *keywords,
181                              svn_boolean_t expand,
182                              apr_pool_t *pool)
183 {
184   return svn_error_trace(svn_subst_copy_and_translate2(src, dst, eol_str,
185                                                        repair, keywords,
186                                                        expand, FALSE, pool));
187 }
188
189 svn_error_t *
190 svn_subst_copy_and_translate2(const char *src,
191                               const char *dst,
192                               const char *eol_str,
193                               svn_boolean_t repair,
194                               const svn_subst_keywords_t *keywords,
195                               svn_boolean_t expand,
196                               svn_boolean_t special,
197                               apr_pool_t *pool)
198 {
199   apr_hash_t *kh = kwstruct_to_kwhash(keywords, pool);
200
201   return svn_error_trace(svn_subst_copy_and_translate3(src, dst, eol_str,
202                                                        repair, kh, expand,
203                                                        special, pool));
204 }
205
206 svn_error_t *
207 svn_subst_copy_and_translate3(const char *src,
208                               const char *dst,
209                               const char *eol_str,
210                               svn_boolean_t repair,
211                               apr_hash_t *keywords,
212                               svn_boolean_t expand,
213                               svn_boolean_t special,
214                               apr_pool_t *pool)
215 {
216   return svn_error_trace(svn_subst_copy_and_translate4(src, dst, eol_str,
217                                                        repair, keywords,
218                                                        expand, special,
219                                                        NULL, NULL,
220                                                        pool));
221 }
222
223
224 svn_error_t *
225 svn_subst_stream_translated_to_normal_form(svn_stream_t **stream,
226                                            svn_stream_t *source,
227                                            svn_subst_eol_style_t eol_style,
228                                            const char *eol_str,
229                                            svn_boolean_t always_repair_eols,
230                                            apr_hash_t *keywords,
231                                            apr_pool_t *pool)
232 {
233   if (eol_style == svn_subst_eol_style_native)
234     eol_str = SVN_SUBST_NATIVE_EOL_STR;
235   else if (! (eol_style == svn_subst_eol_style_fixed
236               || eol_style == svn_subst_eol_style_none))
237     return svn_error_create(SVN_ERR_IO_UNKNOWN_EOL, NULL, NULL);
238
239  *stream = svn_subst_stream_translated(source, eol_str,
240                                        eol_style == svn_subst_eol_style_fixed
241                                        || always_repair_eols,
242                                        keywords, FALSE, pool);
243
244  return SVN_NO_ERROR;
245 }
246
247 svn_error_t *
248 svn_subst_translate_string(svn_string_t **new_value,
249                            const svn_string_t *value,
250                            const char *encoding,
251                            apr_pool_t *pool)
252 {
253   return svn_subst_translate_string2(new_value, NULL, NULL, value,
254                                      encoding, FALSE, pool, pool);
255 }
256
257 svn_error_t *
258 svn_subst_stream_detranslated(svn_stream_t **stream_p,
259                               const char *src,
260                               svn_subst_eol_style_t eol_style,
261                               const char *eol_str,
262                               svn_boolean_t always_repair_eols,
263                               apr_hash_t *keywords,
264                               svn_boolean_t special,
265                               apr_pool_t *pool)
266 {
267   svn_stream_t *src_stream;
268
269   if (special)
270     return svn_subst_read_specialfile(stream_p, src, pool, pool);
271
272   /* This will be closed by svn_subst_stream_translated_to_normal_form
273      when the returned stream is closed. */
274   SVN_ERR(svn_stream_open_readonly(&src_stream, src, pool, pool));
275
276   return svn_error_trace(svn_subst_stream_translated_to_normal_form(
277                            stream_p, src_stream,
278                            eol_style, eol_str,
279                            always_repair_eols,
280                            keywords, pool));
281 }
282
283 svn_error_t *
284 svn_subst_translate_to_normal_form(const char *src,
285                                    const char *dst,
286                                    svn_subst_eol_style_t eol_style,
287                                    const char *eol_str,
288                                    svn_boolean_t always_repair_eols,
289                                    apr_hash_t *keywords,
290                                    svn_boolean_t special,
291                                    apr_pool_t *pool)
292 {
293
294   if (eol_style == svn_subst_eol_style_native)
295     eol_str = SVN_SUBST_NATIVE_EOL_STR;
296   else if (! (eol_style == svn_subst_eol_style_fixed
297               || eol_style == svn_subst_eol_style_none))
298     return svn_error_create(SVN_ERR_IO_UNKNOWN_EOL, NULL, NULL);
299
300   return svn_error_trace(svn_subst_copy_and_translate3(
301                            src, dst, eol_str,
302                            eol_style == svn_subst_eol_style_fixed
303                              || always_repair_eols,
304                            keywords,
305                            FALSE /* contract keywords */,
306                            special,
307                            pool));
308 }
309
310
311 /*** From opt.c ***/
312 /* Same as print_command_info2(), but with deprecated struct revision. */
313 static svn_error_t *
314 print_command_info(const svn_opt_subcommand_desc_t *cmd,
315                    const apr_getopt_option_t *options_table,
316                    svn_boolean_t help,
317                    apr_pool_t *pool,
318                    FILE *stream)
319 {
320   svn_boolean_t first_time;
321   apr_size_t i;
322
323   /* Print the canonical command name. */
324   SVN_ERR(svn_cmdline_fputs(cmd->name, stream, pool));
325
326   /* Print the list of aliases. */
327   first_time = TRUE;
328   for (i = 0; i < SVN_OPT_MAX_ALIASES; i++)
329     {
330       if (cmd->aliases[i] == NULL)
331         break;
332
333       if (first_time) {
334         SVN_ERR(svn_cmdline_fputs(" (", stream, pool));
335         first_time = FALSE;
336       }
337       else
338         SVN_ERR(svn_cmdline_fputs(", ", stream, pool));
339
340       SVN_ERR(svn_cmdline_fputs(cmd->aliases[i], stream, pool));
341     }
342
343   if (! first_time)
344     SVN_ERR(svn_cmdline_fputs(")", stream, pool));
345
346   if (help)
347     {
348       const apr_getopt_option_t *option;
349       svn_boolean_t have_options = FALSE;
350
351       SVN_ERR(svn_cmdline_fprintf(stream, pool, ": %s", _(cmd->help)));
352
353       /* Loop over all valid option codes attached to the subcommand */
354       for (i = 0; i < SVN_OPT_MAX_OPTIONS; i++)
355         {
356           if (cmd->valid_options[i])
357             {
358               if (!have_options)
359                 {
360                   SVN_ERR(svn_cmdline_fputs(_("\nValid options:\n"),
361                                             stream, pool));
362                   have_options = TRUE;
363                 }
364
365               /* convert each option code into an option */
366               option =
367                 svn_opt_get_option_from_code2(cmd->valid_options[i],
368                                               options_table, NULL, pool);
369
370               /* print the option's docstring */
371               if (option && option->description)
372                 {
373                   const char *optstr;
374                   svn_opt_format_option(&optstr, option, TRUE, pool);
375                   SVN_ERR(svn_cmdline_fprintf(stream, pool, "  %s\n",
376                                               optstr));
377                 }
378             }
379         }
380
381       if (have_options)
382         SVN_ERR(svn_cmdline_fprintf(stream, pool, "\n"));
383     }
384
385   return SVN_NO_ERROR;
386 }
387
388 const svn_opt_subcommand_desc_t *
389 svn_opt_get_canonical_subcommand(const svn_opt_subcommand_desc_t *table,
390                                  const char *cmd_name)
391 {
392   int i = 0;
393
394   if (cmd_name == NULL)
395     return NULL;
396
397   while (table[i].name) {
398     int j;
399     if (strcmp(cmd_name, table[i].name) == 0)
400       return table + i;
401     for (j = 0; (j < SVN_OPT_MAX_ALIASES) && table[i].aliases[j]; j++)
402       if (strcmp(cmd_name, table[i].aliases[j]) == 0)
403         return table + i;
404
405     i++;
406   }
407
408   /* If we get here, there was no matching subcommand name or alias. */
409   return NULL;
410 }
411
412 void
413 svn_opt_subcommand_help2(const char *subcommand,
414                          const svn_opt_subcommand_desc2_t *table,
415                          const apr_getopt_option_t *options_table,
416                          apr_pool_t *pool)
417 {
418   svn_opt_subcommand_help3(subcommand, table, options_table,
419                            NULL, pool);
420 }
421
422 void
423 svn_opt_subcommand_help(const char *subcommand,
424                         const svn_opt_subcommand_desc_t *table,
425                         const apr_getopt_option_t *options_table,
426                         apr_pool_t *pool)
427 {
428   const svn_opt_subcommand_desc_t *cmd =
429     svn_opt_get_canonical_subcommand(table, subcommand);
430   svn_error_t *err;
431
432   if (cmd)
433     err = print_command_info(cmd, options_table, TRUE, pool, stdout);
434   else
435     err = svn_cmdline_fprintf(stderr, pool,
436                               _("\"%s\": unknown command.\n\n"), subcommand);
437
438   if (err) {
439     svn_handle_error2(err, stderr, FALSE, "svn: ");
440     svn_error_clear(err);
441   }
442 }
443
444 svn_error_t *
445 svn_opt_args_to_target_array3(apr_array_header_t **targets_p,
446                               apr_getopt_t *os,
447                               const apr_array_header_t *known_targets,
448                               apr_pool_t *pool)
449 {
450   return svn_error_trace(svn_opt__args_to_target_array(targets_p, os,
451                                                        known_targets, pool));
452 }
453
454 svn_error_t *
455 svn_opt_args_to_target_array2(apr_array_header_t **targets_p,
456                               apr_getopt_t *os,
457                               const apr_array_header_t *known_targets,
458                               apr_pool_t *pool)
459 {
460   svn_error_t *err = svn_opt_args_to_target_array3(targets_p, os,
461                                                    known_targets, pool);
462
463   if (err && err->apr_err == SVN_ERR_RESERVED_FILENAME_SPECIFIED)
464     {
465       svn_error_clear(err);
466       return SVN_NO_ERROR;
467     }
468
469   return err;
470 }
471
472 svn_error_t *
473 svn_opt_args_to_target_array(apr_array_header_t **targets_p,
474                              apr_getopt_t *os,
475                              const apr_array_header_t *known_targets,
476                              svn_opt_revision_t *start_revision,
477                              svn_opt_revision_t *end_revision,
478                              svn_boolean_t extract_revisions,
479                              apr_pool_t *pool)
480 {
481   apr_array_header_t *output_targets;
482
483   SVN_ERR(svn_opt_args_to_target_array2(&output_targets, os,
484                                         known_targets, pool));
485
486   if (extract_revisions)
487     {
488       svn_opt_revision_t temprev;
489       const char *path;
490
491       if (output_targets->nelts > 0)
492         {
493           path = APR_ARRAY_IDX(output_targets, 0, const char *);
494           SVN_ERR(svn_opt_parse_path(&temprev, &path, path, pool));
495           if (temprev.kind != svn_opt_revision_unspecified)
496             {
497               APR_ARRAY_IDX(output_targets, 0, const char *) = path;
498               start_revision->kind = temprev.kind;
499               start_revision->value = temprev.value;
500             }
501         }
502       if (output_targets->nelts > 1)
503         {
504           path = APR_ARRAY_IDX(output_targets, 1, const char *);
505           SVN_ERR(svn_opt_parse_path(&temprev, &path, path, pool));
506           if (temprev.kind != svn_opt_revision_unspecified)
507             {
508               APR_ARRAY_IDX(output_targets, 1, const char *) = path;
509               end_revision->kind = temprev.kind;
510               end_revision->value = temprev.value;
511             }
512         }
513     }
514
515   *targets_p = output_targets;
516   return SVN_NO_ERROR;
517 }
518
519 svn_error_t *
520 svn_opt_print_help3(apr_getopt_t *os,
521                     const char *pgm_name,
522                     svn_boolean_t print_version,
523                     svn_boolean_t quiet,
524                     const char *version_footer,
525                     const char *header,
526                     const svn_opt_subcommand_desc2_t *cmd_table,
527                     const apr_getopt_option_t *option_table,
528                     const int *global_options,
529                     const char *footer,
530                     apr_pool_t *pool)
531 {
532   return svn_error_trace(svn_opt_print_help4(os,
533                                              pgm_name,
534                                              print_version,
535                                              quiet,
536                                              FALSE,
537                                              version_footer,
538                                              header,
539                                              cmd_table,
540                                              option_table,
541                                              global_options,
542                                              footer,
543                                              pool));
544 }
545
546 svn_error_t *
547 svn_opt_print_help2(apr_getopt_t *os,
548                     const char *pgm_name,
549                     svn_boolean_t print_version,
550                     svn_boolean_t quiet,
551                     const char *version_footer,
552                     const char *header,
553                     const svn_opt_subcommand_desc2_t *cmd_table,
554                     const apr_getopt_option_t *option_table,
555                     const char *footer,
556                     apr_pool_t *pool)
557 {
558   return svn_error_trace(svn_opt_print_help4(os,
559                                              pgm_name,
560                                              print_version,
561                                              quiet,
562                                              FALSE,
563                                              version_footer,
564                                              header,
565                                              cmd_table,
566                                              option_table,
567                                              NULL,
568                                              footer,
569                                              pool));
570 }
571
572 svn_error_t *
573 svn_opt_print_help(apr_getopt_t *os,
574                    const char *pgm_name,
575                    svn_boolean_t print_version,
576                    svn_boolean_t quiet,
577                    const char *version_footer,
578                    const char *header,
579                    const svn_opt_subcommand_desc_t *cmd_table,
580                    const apr_getopt_option_t *option_table,
581                    const char *footer,
582                    apr_pool_t *pool)
583 {
584   apr_array_header_t *targets = NULL;
585
586   if (os)
587     SVN_ERR(svn_opt_parse_all_args(&targets, os, pool));
588
589   if (os && targets->nelts)  /* help on subcommand(s) requested */
590     {
591       int i;
592
593       for (i = 0; i < targets->nelts; i++)
594         {
595           svn_opt_subcommand_help(APR_ARRAY_IDX(targets, i, const char *),
596                                   cmd_table, option_table, pool);
597         }
598     }
599   else if (print_version)   /* just --version */
600     {
601       SVN_ERR(svn_opt__print_version_info(pgm_name, version_footer,
602                                           svn_version_extended(FALSE, pool),
603                                           quiet, FALSE, pool));
604     }
605   else if (os && !targets->nelts)            /* `-h', `--help', or `help' */
606     svn_opt_print_generic_help(header,
607                                cmd_table,
608                                option_table,
609                                footer,
610                                pool,
611                                stdout);
612   else                                       /* unknown option or cmd */
613     SVN_ERR(svn_cmdline_fprintf(stderr, pool,
614                                 _("Type '%s help' for usage.\n"), pgm_name));
615
616   return SVN_NO_ERROR;
617 }
618
619 void
620 svn_opt_print_generic_help(const char *header,
621                            const svn_opt_subcommand_desc_t *cmd_table,
622                            const apr_getopt_option_t *opt_table,
623                            const char *footer,
624                            apr_pool_t *pool, FILE *stream)
625 {
626   int i = 0;
627   svn_error_t *err;
628
629   if (header)
630     if ((err = svn_cmdline_fputs(header, stream, pool)))
631       goto print_error;
632
633   while (cmd_table[i].name)
634     {
635       if ((err = svn_cmdline_fputs("   ", stream, pool))
636           || (err = print_command_info(cmd_table + i, opt_table, FALSE,
637                                        pool, stream))
638           || (err = svn_cmdline_fputs("\n", stream, pool)))
639         goto print_error;
640       i++;
641     }
642
643   if ((err = svn_cmdline_fputs("\n", stream, pool)))
644     goto print_error;
645
646   if (footer)
647     if ((err = svn_cmdline_fputs(footer, stream, pool)))
648       goto print_error;
649
650   return;
651
652  print_error:
653   svn_handle_error2(err, stderr, FALSE, "svn: ");
654   svn_error_clear(err);
655 }
656
657 /*** From io.c ***/
658 svn_error_t *
659 svn_io_open_unique_file2(apr_file_t **file,
660                          const char **temp_path,
661                          const char *path,
662                          const char *suffix,
663                          svn_io_file_del_t delete_when,
664                          apr_pool_t *pool)
665 {
666   const char *dirpath;
667   const char *filename;
668
669   svn_path_split(path, &dirpath, &filename, pool);
670   return svn_error_trace(svn_io_open_uniquely_named(file, temp_path,
671                                                     dirpath, filename, suffix,
672                                                     delete_when,
673                                                     pool, pool));
674 }
675
676 svn_error_t *
677 svn_io_open_unique_file(apr_file_t **file,
678                         const char **temp_path,
679                         const char *path,
680                         const char *suffix,
681                         svn_boolean_t delete_on_close,
682                         apr_pool_t *pool)
683 {
684   return svn_error_trace(svn_io_open_unique_file2(file, temp_path,
685                                                   path, suffix,
686                                                   delete_on_close
687                                                     ? svn_io_file_del_on_close
688                                                     : svn_io_file_del_none,
689                                                   pool));
690 }
691
692 svn_error_t *
693 svn_io_run_diff(const char *dir,
694                 const char *const *user_args,
695                 int num_user_args,
696                 const char *label1,
697                 const char *label2,
698                 const char *from,
699                 const char *to,
700                 int *pexitcode,
701                 apr_file_t *outfile,
702                 apr_file_t *errfile,
703                 const char *diff_cmd,
704                 apr_pool_t *pool)
705 {
706   SVN_ERR(svn_path_cstring_to_utf8(&diff_cmd, diff_cmd, pool));
707
708   return svn_error_trace(svn_io_run_diff2(dir, user_args, num_user_args,
709                                           label1, label2,
710                                           from, to, pexitcode,
711                                           outfile, errfile, diff_cmd,
712                                           pool));
713 }
714
715 svn_error_t *
716 svn_io_run_diff3_2(int *exitcode,
717                    const char *dir,
718                    const char *mine,
719                    const char *older,
720                    const char *yours,
721                    const char *mine_label,
722                    const char *older_label,
723                    const char *yours_label,
724                    apr_file_t *merged,
725                    const char *diff3_cmd,
726                    const apr_array_header_t *user_args,
727                    apr_pool_t *pool)
728 {
729   SVN_ERR(svn_path_cstring_to_utf8(&diff3_cmd, diff3_cmd, pool));
730
731   return svn_error_trace(svn_io_run_diff3_3(exitcode, dir,
732                                             mine, older, yours,
733                                             mine_label, older_label,
734                                             yours_label, merged,
735                                             diff3_cmd, user_args, pool));
736 }
737
738 svn_error_t *
739 svn_io_run_diff3(const char *dir,
740                  const char *mine,
741                  const char *older,
742                  const char *yours,
743                  const char *mine_label,
744                  const char *older_label,
745                  const char *yours_label,
746                  apr_file_t *merged,
747                  int *exitcode,
748                  const char *diff3_cmd,
749                  apr_pool_t *pool)
750 {
751   return svn_error_trace(svn_io_run_diff3_2(exitcode, dir, mine, older, yours,
752                                             mine_label, older_label,
753                                             yours_label,
754                                             merged, diff3_cmd, NULL, pool));
755 }
756
757 svn_error_t *
758 svn_io_remove_file(const char *path,
759                    apr_pool_t *scratch_pool)
760 {
761   return svn_error_trace(svn_io_remove_file2(path, FALSE, scratch_pool));
762 }
763
764 svn_error_t *svn_io_file_lock(const char *lock_file,
765                               svn_boolean_t exclusive,
766                               apr_pool_t *pool)
767 {
768   return svn_io_file_lock2(lock_file, exclusive, FALSE, pool);
769 }
770
771 svn_error_t *
772 svn_io_get_dirents2(apr_hash_t **dirents,
773                     const char *path,
774                     apr_pool_t *pool)
775 {
776   /* Note that the first part of svn_io_dirent2_t is identical
777      to svn_io_dirent_t to allow this construct */
778   return svn_error_trace(
779             svn_io_get_dirents3(dirents, path, FALSE, pool, pool));
780 }
781
782 svn_error_t *
783 svn_io_get_dirents(apr_hash_t **dirents,
784                    const char *path,
785                    apr_pool_t *pool)
786 {
787   /* Note that in C, padding is not allowed at the beginning of structs,
788      so this is actually portable, since the kind field of svn_io_dirent_t
789      is first in that struct. */
790   return svn_io_get_dirents2(dirents, path, pool);
791 }
792
793 svn_error_t *
794 svn_io_start_cmd2(apr_proc_t *cmd_proc,
795                   const char *path,
796                   const char *cmd,
797                   const char *const *args,
798                   svn_boolean_t inherit,
799                   svn_boolean_t infile_pipe,
800                   apr_file_t *infile,
801                   svn_boolean_t outfile_pipe,
802                   apr_file_t *outfile,
803                   svn_boolean_t errfile_pipe,
804                   apr_file_t *errfile,
805                   apr_pool_t *pool)
806 {
807   return svn_io_start_cmd3(cmd_proc, path, cmd, args, NULL, inherit,
808                            infile_pipe, infile, outfile_pipe, outfile,
809                            errfile_pipe, errfile, pool);
810 }
811
812 svn_error_t *
813 svn_io_start_cmd(apr_proc_t *cmd_proc,
814                  const char *path,
815                  const char *cmd,
816                  const char *const *args,
817                  svn_boolean_t inherit,
818                  apr_file_t *infile,
819                  apr_file_t *outfile,
820                  apr_file_t *errfile,
821                  apr_pool_t *pool)
822 {
823   return svn_io_start_cmd2(cmd_proc, path, cmd, args, inherit, FALSE,
824                            infile, FALSE, outfile, FALSE, errfile, pool);
825 }
826
827 svn_error_t *
828 svn_io_file_read_full(apr_file_t *file, void *buf,
829                       apr_size_t nbytes, apr_size_t *bytes_read,
830                       apr_pool_t *pool)
831 {
832   return svn_io_file_read_full2(file, buf, nbytes, bytes_read, NULL, pool);
833 }
834
835 struct walk_func_filter_baton_t
836 {
837   svn_io_walk_func_t walk_func;
838   void *walk_baton;
839 };
840
841 /* Implements svn_io_walk_func_t, but only allows APR_DIR and APR_REG
842    finfo types through to the wrapped function/baton.  */
843 static svn_error_t *
844 walk_func_filter_func(void *baton,
845                       const char *path,
846                       const apr_finfo_t *finfo,
847                       apr_pool_t *pool)
848 {
849   struct walk_func_filter_baton_t *b = baton;
850
851   if (finfo->filetype == APR_DIR || finfo->filetype == APR_REG)
852     SVN_ERR(b->walk_func(b->walk_baton, path, finfo, pool));
853
854   return SVN_NO_ERROR;
855 }
856
857 svn_error_t *
858 svn_io_dir_walk(const char *dirname,
859                 apr_int32_t wanted,
860                 svn_io_walk_func_t walk_func,
861                 void *walk_baton,
862                 apr_pool_t *pool)
863 {
864   struct walk_func_filter_baton_t baton;
865   baton.walk_func = walk_func;
866   baton.walk_baton = walk_baton;
867   return svn_error_trace(svn_io_dir_walk2(dirname, wanted,
868                                           walk_func_filter_func,
869                                           &baton, pool));
870 }
871
872 svn_error_t *
873 svn_io_stat_dirent(const svn_io_dirent2_t **dirent_p,
874                    const char *path,
875                    svn_boolean_t ignore_enoent,
876                    apr_pool_t *result_pool,
877                    apr_pool_t *scratch_pool)
878 {
879   return svn_error_trace(
880             svn_io_stat_dirent2(dirent_p,
881                                 path,
882                                 FALSE,
883                                 ignore_enoent,
884                                 result_pool,
885                                 scratch_pool));
886 }
887
888 /*** From constructors.c ***/
889 svn_log_changed_path_t *
890 svn_log_changed_path_dup(const svn_log_changed_path_t *changed_path,
891                          apr_pool_t *pool)
892 {
893   svn_log_changed_path_t *new_changed_path
894     = apr_palloc(pool, sizeof(*new_changed_path));
895
896   *new_changed_path = *changed_path;
897
898   if (new_changed_path->copyfrom_path)
899     new_changed_path->copyfrom_path =
900       apr_pstrdup(pool, new_changed_path->copyfrom_path);
901
902   return new_changed_path;
903 }
904
905 /*** From cmdline.c ***/
906 svn_error_t *
907 svn_cmdline_prompt_user(const char **result,
908                         const char *prompt_str,
909                         apr_pool_t *pool)
910 {
911   return svn_error_trace(svn_cmdline_prompt_user2(result, prompt_str, NULL,
912                                                   pool));
913 }
914
915 svn_error_t *
916 svn_cmdline_setup_auth_baton(svn_auth_baton_t **ab,
917                              svn_boolean_t non_interactive,
918                              const char *auth_username,
919                              const char *auth_password,
920                              const char *config_dir,
921                              svn_boolean_t no_auth_cache,
922                              svn_config_t *cfg,
923                              svn_cancel_func_t cancel_func,
924                              void *cancel_baton,
925                              apr_pool_t *pool)
926 {
927   return svn_error_trace(svn_cmdline_create_auth_baton(
928                            ab, non_interactive,
929                            auth_username, auth_password,
930                            config_dir, no_auth_cache, FALSE,
931                            cfg, cancel_func, cancel_baton, pool));
932 }
933
934 /*** From dso.c ***/
935 void
936 svn_dso_initialize(void)
937 {
938   svn_error_t *err = svn_dso_initialize2();
939   if (err)
940     {
941       svn_error_clear(err);
942       abort();
943     }
944 }
945
946 /*** From simple_providers.c ***/
947 void
948 svn_auth_get_simple_provider(svn_auth_provider_object_t **provider,
949                              apr_pool_t *pool)
950 {
951   svn_auth_get_simple_provider2(provider, NULL, NULL, pool);
952 }
953
954 /*** From ssl_client_cert_pw_providers.c ***/
955 void
956 svn_auth_get_ssl_client_cert_pw_file_provider
957   (svn_auth_provider_object_t **provider,
958    apr_pool_t *pool)
959 {
960   svn_auth_get_ssl_client_cert_pw_file_provider2(provider, NULL, NULL, pool);
961 }
962
963 /*** From path.c ***/
964
965 #define SVN_EMPTY_PATH ""
966
967 const char *
968 svn_path_url_add_component(const char *url,
969                            const char *component,
970                            apr_pool_t *pool)
971 {
972   /* URL can have trailing '/' */
973   url = svn_path_canonicalize(url, pool);
974
975   return svn_path_url_add_component2(url, component, pool);
976 }
977
978 void
979 svn_path_split(const char *path,
980                const char **dirpath,
981                const char **base_name,
982                apr_pool_t *pool)
983 {
984   assert(dirpath != base_name);
985
986   if (dirpath)
987     *dirpath = svn_path_dirname(path, pool);
988
989   if (base_name)
990     *base_name = svn_path_basename(path, pool);
991 }
992
993
994 svn_error_t *
995 svn_path_split_if_file(const char *path,
996                        const char **pdirectory,
997                        const char **pfile,
998                        apr_pool_t *pool)
999 {
1000   apr_finfo_t finfo;
1001   svn_error_t *err;
1002
1003   SVN_ERR_ASSERT(svn_path_is_canonical(path, pool));
1004
1005   err = svn_io_stat(&finfo, path, APR_FINFO_TYPE, pool);
1006   if (err && ! APR_STATUS_IS_ENOENT(err->apr_err))
1007     return err;
1008
1009   if (err || finfo.filetype == APR_REG)
1010     {
1011       svn_error_clear(err);
1012       svn_path_split(path, pdirectory, pfile, pool);
1013     }
1014   else if (finfo.filetype == APR_DIR)
1015     {
1016       *pdirectory = path;
1017       *pfile = SVN_EMPTY_PATH;
1018     }
1019   else
1020     {
1021       return svn_error_createf(SVN_ERR_BAD_FILENAME, NULL,
1022                                _("'%s' is neither a file nor a directory name"),
1023                                svn_path_local_style(path, pool));
1024     }
1025
1026   return SVN_NO_ERROR;
1027 }
1028
1029 /*** From stream.c ***/
1030 svn_error_t *svn_stream_copy2(svn_stream_t *from, svn_stream_t *to,
1031                               svn_cancel_func_t cancel_func,
1032                               void *cancel_baton,
1033                               apr_pool_t *scratch_pool)
1034 {
1035   return svn_error_trace(svn_stream_copy3(
1036                            svn_stream_disown(from, scratch_pool),
1037                            svn_stream_disown(to, scratch_pool),
1038                            cancel_func, cancel_baton, scratch_pool));
1039 }
1040
1041 svn_error_t *svn_stream_copy(svn_stream_t *from, svn_stream_t *to,
1042                              apr_pool_t *scratch_pool)
1043 {
1044   return svn_error_trace(svn_stream_copy3(
1045                            svn_stream_disown(from, scratch_pool),
1046                            svn_stream_disown(to, scratch_pool),
1047                            NULL, NULL, scratch_pool));
1048 }
1049
1050 svn_stream_t *
1051 svn_stream_from_aprfile(apr_file_t *file, apr_pool_t *pool)
1052 {
1053   return svn_stream_from_aprfile2(file, TRUE, pool);
1054 }
1055
1056 svn_error_t *
1057 svn_stream_contents_same(svn_boolean_t *same,
1058                          svn_stream_t *stream1,
1059                          svn_stream_t *stream2,
1060                          apr_pool_t *pool)
1061 {
1062   return svn_error_trace(svn_stream_contents_same2(
1063                            same,
1064                            svn_stream_disown(stream1, pool),
1065                            svn_stream_disown(stream2, pool),
1066                            pool));
1067 }
1068
1069 /*** From path.c ***/
1070
1071 const char *
1072 svn_path_internal_style(const char *path, apr_pool_t *pool)
1073 {
1074   if (svn_path_is_url(path))
1075     return svn_uri_canonicalize(path, pool);
1076   else
1077     return svn_dirent_internal_style(path, pool);
1078 }
1079
1080
1081 const char *
1082 svn_path_local_style(const char *path, apr_pool_t *pool)
1083 {
1084   if (svn_path_is_url(path))
1085     return apr_pstrdup(pool, path);
1086   else
1087     return svn_dirent_local_style(path, pool);
1088 }
1089
1090 const char *
1091 svn_path_canonicalize(const char *path, apr_pool_t *pool)
1092 {
1093   if (svn_path_is_url(path))
1094     return svn_uri_canonicalize(path, pool);
1095   else
1096     return svn_dirent_canonicalize(path, pool);
1097 }
1098
1099
1100 /*** From mergeinfo.c ***/
1101
1102 svn_error_t *
1103 svn_mergeinfo_inheritable(svn_mergeinfo_t *output,
1104                           svn_mergeinfo_t mergeinfo,
1105                           const char *path,
1106                           svn_revnum_t start,
1107                           svn_revnum_t end,
1108                           apr_pool_t *pool)
1109 {
1110   return svn_error_trace(svn_mergeinfo_inheritable2(output, mergeinfo, path,
1111                                                     start, end,
1112                                                     TRUE, pool, pool));
1113 }
1114
1115 svn_error_t *
1116 svn_rangelist_inheritable(svn_rangelist_t **inheritable_rangelist,
1117                           const svn_rangelist_t *rangelist,
1118                           svn_revnum_t start,
1119                           svn_revnum_t end,
1120                           apr_pool_t *pool)
1121 {
1122   return svn_error_trace(svn_rangelist_inheritable2(inheritable_rangelist,
1123                                                     rangelist,
1124                                                     start, end, TRUE,
1125                                                     pool, pool));
1126 }
1127
1128 svn_error_t *
1129 svn_rangelist_merge(svn_rangelist_t **rangelist,
1130                     const svn_rangelist_t *changes,
1131                     apr_pool_t *pool)
1132 {
1133   SVN_ERR(svn_rangelist_merge2(*rangelist, changes,
1134                                pool, pool));
1135
1136   return svn_error_trace(
1137             svn_rangelist__combine_adjacent_ranges(*rangelist, pool));
1138 }
1139
1140 svn_error_t *
1141 svn_mergeinfo_diff(svn_mergeinfo_t *deleted, svn_mergeinfo_t *added,
1142                    svn_mergeinfo_t from, svn_mergeinfo_t to,
1143                    svn_boolean_t consider_inheritance,
1144                    apr_pool_t *pool)
1145 {
1146   return svn_error_trace(svn_mergeinfo_diff2(deleted, added, from, to,
1147                                              consider_inheritance, pool,
1148                                              pool));
1149 }
1150
1151 svn_error_t *
1152 svn_mergeinfo_merge(svn_mergeinfo_t mergeinfo,
1153                     svn_mergeinfo_t changes,
1154                     apr_pool_t *pool)
1155 {
1156   return svn_error_trace(svn_mergeinfo_merge2(mergeinfo, changes, pool,
1157                          pool));
1158 }
1159
1160 svn_error_t *
1161 svn_mergeinfo_remove(svn_mergeinfo_t *mergeinfo, svn_mergeinfo_t eraser,
1162                      svn_mergeinfo_t whiteboard, apr_pool_t *pool)
1163 {
1164   return svn_mergeinfo_remove2(mergeinfo, eraser, whiteboard, TRUE, pool,
1165                                pool);
1166 }
1167
1168 svn_error_t *
1169 svn_mergeinfo_intersect(svn_mergeinfo_t *mergeinfo,
1170                         svn_mergeinfo_t mergeinfo1,
1171                         svn_mergeinfo_t mergeinfo2,
1172                         apr_pool_t *pool)
1173 {
1174   return svn_mergeinfo_intersect2(mergeinfo, mergeinfo1, mergeinfo2,
1175                                   TRUE, pool, pool);
1176 }
1177
1178 /*** From config.c ***/
1179 svn_error_t *
1180 svn_config_create(svn_config_t **cfgp,
1181                   svn_boolean_t section_names_case_sensitive,
1182                   apr_pool_t *result_pool)
1183 {
1184   return svn_error_trace(svn_config_create2(cfgp,
1185                                             section_names_case_sensitive,
1186                                             FALSE,
1187                                             result_pool));
1188 }
1189
1190 svn_error_t *
1191 svn_config_read2(svn_config_t **cfgp, const char *file,
1192                  svn_boolean_t must_exist,
1193                  svn_boolean_t section_names_case_sensitive,
1194                  apr_pool_t *result_pool)
1195 {
1196   return svn_error_trace(svn_config_read3(cfgp, file,
1197                                           must_exist,
1198                                           section_names_case_sensitive,
1199                                           FALSE,
1200                                           result_pool));
1201 }
1202
1203 svn_error_t *
1204 svn_config_read(svn_config_t **cfgp, const char *file,
1205                 svn_boolean_t must_exist,
1206                 apr_pool_t *result_pool)
1207 {
1208   return svn_error_trace(svn_config_read3(cfgp, file,
1209                                           must_exist,
1210                                           FALSE, FALSE,
1211                                           result_pool));
1212 }
1213
1214 #ifdef SVN_DISABLE_FULL_VERSION_MATCH
1215 /* This double underscore name is used by the 1.6 command line client.
1216    Keeping this name is sufficient for the 1.6 client to use the 1.7
1217    libraries at runtime. */
1218 svn_error_t *
1219 svn_opt__eat_peg_revisions(apr_array_header_t **true_targets_p,
1220                            apr_array_header_t *targets,
1221                            apr_pool_t *pool);
1222 svn_error_t *
1223 svn_opt__eat_peg_revisions(apr_array_header_t **true_targets_p,
1224                            apr_array_header_t *targets,
1225                            apr_pool_t *pool)
1226 {
1227   unsigned int i;
1228   apr_array_header_t *true_targets;
1229
1230   true_targets = apr_array_make(pool, 5, sizeof(const char *));
1231
1232   for (i = 0; i < targets->nelts; i++)
1233     {
1234       const char *target = APR_ARRAY_IDX(targets, i, const char *);
1235       const char *true_target;
1236
1237       SVN_ERR(svn_opt__split_arg_at_peg_revision(&true_target, NULL,
1238                                                  target, pool));
1239       APR_ARRAY_PUSH(true_targets, const char *) = true_target;
1240     }
1241
1242   SVN_ERR_ASSERT(true_targets_p);
1243   *true_targets_p = true_targets;
1244
1245   return SVN_NO_ERROR;
1246 }
1247 #endif
1248
1249 void
1250 svn_xml_make_header(svn_stringbuf_t **str, apr_pool_t *pool)
1251 {
1252   svn_xml_make_header2(str, NULL, pool);
1253 }
1254
1255 void
1256 svn_utf_initialize(apr_pool_t *pool)
1257 {
1258   svn_utf_initialize2(FALSE, pool);
1259 }
1260
1261 svn_error_t *
1262 svn_subst_build_keywords(svn_subst_keywords_t *kw,
1263                          const char *keywords_val,
1264                          const char *rev,
1265                          const char *url,
1266                          apr_time_t date,
1267                          const char *author,
1268                          apr_pool_t *pool)
1269 {
1270   apr_hash_t *kwhash;
1271   const svn_string_t *val;
1272
1273   SVN_ERR(svn_subst_build_keywords2(&kwhash, keywords_val, rev,
1274                                     url, date, author, pool));
1275
1276   /* The behaviour of pre-1.3 svn_subst_build_keywords, which we are
1277    * replicating here, is to write to a slot in the svn_subst_keywords_t
1278    * only if the relevant keyword was present in keywords_val, otherwise
1279    * leaving that slot untouched. */
1280
1281   val = svn_hash_gets(kwhash, SVN_KEYWORD_REVISION_LONG);
1282   if (val)
1283     kw->revision = val;
1284
1285   val = svn_hash_gets(kwhash, SVN_KEYWORD_DATE_LONG);
1286   if (val)
1287     kw->date = val;
1288
1289   val = svn_hash_gets(kwhash, SVN_KEYWORD_AUTHOR_LONG);
1290   if (val)
1291     kw->author = val;
1292
1293   val = svn_hash_gets(kwhash, SVN_KEYWORD_URL_LONG);
1294   if (val)
1295     kw->url = val;
1296
1297   val = svn_hash_gets(kwhash, SVN_KEYWORD_ID);
1298   if (val)
1299     kw->id = val;
1300
1301   return SVN_NO_ERROR;
1302 }
1303
1304