]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/subversion/subversion/libsvn_diff/deprecated.c
MFC r275385 (by bapt):
[FreeBSD/stable/10.git] / contrib / subversion / subversion / libsvn_diff / 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 /*** Includes. ***/
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_diff.h"
36 #include "svn_utf.h"
37
38 #include "svn_private_config.h"
39
40
41
42 \f
43 /*** Code. ***/
44 struct fns_wrapper_baton
45 {
46   /* We put the old baton in front of this one, so that we can still use
47      this baton in place of the old.  This prevents us from having to
48      implement simple wrappers around each member of diff_fns_t. */
49   void *old_baton;
50   const svn_diff_fns_t *vtable;
51 };
52
53 static svn_error_t *
54 datasources_open(void *baton,
55                  apr_off_t *prefix_lines,
56                  apr_off_t *suffix_lines,
57                  const svn_diff_datasource_e *datasources,
58                  apr_size_t datasource_len)
59 {
60   struct fns_wrapper_baton *fwb = baton;
61   apr_size_t i;
62
63   /* Just iterate over the datasources, using the old singular version. */
64   for (i = 0; i < datasource_len; i++)
65     {
66       SVN_ERR(fwb->vtable->datasource_open(fwb->old_baton, datasources[i]));
67     }
68
69   /* Don't claim any prefix or suffix matches. */
70   *prefix_lines = 0;
71   *suffix_lines = 0;
72
73   return SVN_NO_ERROR;
74 }
75
76 static svn_error_t *
77 datasource_close(void *baton,
78                  svn_diff_datasource_e datasource)
79 {
80   struct fns_wrapper_baton *fwb = baton;
81   return fwb->vtable->datasource_close(fwb->old_baton, datasource);
82 }
83
84 static svn_error_t *
85 datasource_get_next_token(apr_uint32_t *hash,
86                           void **token,
87                           void *baton,
88                           svn_diff_datasource_e datasource)
89 {
90   struct fns_wrapper_baton *fwb = baton;
91   return fwb->vtable->datasource_get_next_token(hash, token, fwb->old_baton,
92                                                 datasource);
93 }
94
95 static svn_error_t *
96 token_compare(void *baton,
97               void *ltoken,
98               void *rtoken,
99               int *compare)
100 {
101   struct fns_wrapper_baton *fwb = baton;
102   return fwb->vtable->token_compare(fwb->old_baton, ltoken, rtoken, compare);
103 }
104
105 static void
106 token_discard(void *baton,
107               void *token)
108 {
109   struct fns_wrapper_baton *fwb = baton;
110   fwb->vtable->token_discard(fwb->old_baton, token);
111 }
112
113 static void
114 token_discard_all(void *baton)
115 {
116   struct fns_wrapper_baton *fwb = baton;
117   fwb->vtable->token_discard_all(fwb->old_baton);
118 }
119
120
121 static void
122 wrap_diff_fns(svn_diff_fns2_t **diff_fns2,
123               struct fns_wrapper_baton **baton2,
124               const svn_diff_fns_t *diff_fns,
125               void *baton,
126               apr_pool_t *result_pool)
127 {
128   /* Initialize the return vtable. */
129   *diff_fns2 = apr_palloc(result_pool, sizeof(**diff_fns2));
130
131   (*diff_fns2)->datasources_open = datasources_open;
132   (*diff_fns2)->datasource_close = datasource_close;
133   (*diff_fns2)->datasource_get_next_token = datasource_get_next_token;
134   (*diff_fns2)->token_compare = token_compare;
135   (*diff_fns2)->token_discard = token_discard;
136   (*diff_fns2)->token_discard_all = token_discard_all;
137
138   /* Initialize the wrapper baton. */
139   *baton2 = apr_palloc(result_pool, sizeof (**baton2));
140   (*baton2)->old_baton = baton;
141   (*baton2)->vtable = diff_fns;
142 }
143
144
145 /*** From diff_file.c ***/
146
147 svn_error_t *
148 svn_diff_file_output_unified3(svn_stream_t *output_stream,
149                               svn_diff_t *diff,
150                               const char *original_path,
151                               const char *modified_path,
152                               const char *original_header,
153                               const char *modified_header,
154                               const char *header_encoding,
155                               const char *relative_to_dir,
156                               svn_boolean_t show_c_function,
157                               apr_pool_t *pool)
158 {
159   return svn_error_trace(
160               svn_diff_file_output_unified4(output_stream,
161                                             diff,
162                                             original_path,
163                                             modified_path,
164                                             original_header,
165                                             modified_header,
166                                             header_encoding,
167                                             relative_to_dir,
168                                             show_c_function,
169                                             -1 /* context_size */,
170                                             NULL, NULL, /* cancel */
171                                             pool));
172 }
173
174 svn_error_t *
175 svn_diff_file_output_unified2(svn_stream_t *output_stream,
176                               svn_diff_t *diff,
177                               const char *original_path,
178                               const char *modified_path,
179                               const char *original_header,
180                               const char *modified_header,
181                               const char *header_encoding,
182                               apr_pool_t *pool)
183 {
184   return svn_diff_file_output_unified3(output_stream, diff,
185                                        original_path, modified_path,
186                                        original_header, modified_header,
187                                        header_encoding, NULL, FALSE, pool);
188 }
189
190 svn_error_t *
191 svn_diff_file_output_unified(svn_stream_t *output_stream,
192                              svn_diff_t *diff,
193                              const char *original_path,
194                              const char *modified_path,
195                              const char *original_header,
196                              const char *modified_header,
197                              apr_pool_t *pool)
198 {
199   return svn_diff_file_output_unified2(output_stream, diff,
200                                        original_path, modified_path,
201                                        original_header, modified_header,
202                                        SVN_APR_LOCALE_CHARSET, pool);
203 }
204
205 svn_error_t *
206 svn_diff_file_diff(svn_diff_t **diff,
207                    const char *original,
208                    const char *modified,
209                    apr_pool_t *pool)
210 {
211   return svn_diff_file_diff_2(diff, original, modified,
212                               svn_diff_file_options_create(pool), pool);
213 }
214
215 svn_error_t *
216 svn_diff_file_diff3(svn_diff_t **diff,
217                     const char *original,
218                     const char *modified,
219                     const char *latest,
220                     apr_pool_t *pool)
221 {
222   return svn_diff_file_diff3_2(diff, original, modified, latest,
223                                svn_diff_file_options_create(pool), pool);
224 }
225
226 svn_error_t *
227 svn_diff_file_diff4(svn_diff_t **diff,
228                     const char *original,
229                     const char *modified,
230                     const char *latest,
231                     const char *ancestor,
232                     apr_pool_t *pool)
233 {
234   return svn_diff_file_diff4_2(diff, original, modified, latest, ancestor,
235                                svn_diff_file_options_create(pool), pool);
236 }
237
238 svn_error_t *
239 svn_diff_file_output_merge(svn_stream_t *output_stream,
240                            svn_diff_t *diff,
241                            const char *original_path,
242                            const char *modified_path,
243                            const char *latest_path,
244                            const char *conflict_original,
245                            const char *conflict_modified,
246                            const char *conflict_latest,
247                            const char *conflict_separator,
248                            svn_boolean_t display_original_in_conflict,
249                            svn_boolean_t display_resolved_conflicts,
250                            apr_pool_t *pool)
251 {
252   svn_diff_conflict_display_style_t style =
253     svn_diff_conflict_display_modified_latest;
254
255   if (display_resolved_conflicts)
256     style = svn_diff_conflict_display_resolved_modified_latest;
257
258   if (display_original_in_conflict)
259     style = svn_diff_conflict_display_modified_original_latest;
260
261   return svn_diff_file_output_merge2(output_stream,
262                                      diff,
263                                      original_path,
264                                      modified_path,
265                                      latest_path,
266                                      conflict_original,
267                                      conflict_modified,
268                                      conflict_latest,
269                                      conflict_separator,
270                                      style,
271                                      pool);
272 }
273
274 svn_error_t *
275 svn_diff_file_output_merge2(svn_stream_t *output_stream,
276                             svn_diff_t *diff,
277                             const char *original_path,
278                             const char *modified_path,
279                             const char *latest_path,
280                             const char *conflict_original,
281                             const char *conflict_modified,
282                             const char *conflict_latest,
283                             const char *conflict_separator,
284                             svn_diff_conflict_display_style_t conflict_style,
285                             apr_pool_t *pool)
286 {
287   return svn_error_trace(svn_diff_file_output_merge3(output_stream,
288                                                      diff, original_path,
289                                                      modified_path,
290                                                      latest_path,
291                                                      conflict_original,
292                                                      conflict_modified,
293                                                      conflict_latest,
294                                                      conflict_separator,
295                                                      conflict_style,
296                                                      NULL, NULL, /* cancel */
297                                                      pool));
298 }
299
300 /*** From diff.c ***/
301 svn_error_t *
302 svn_diff_diff(svn_diff_t **diff,
303               void *diff_baton,
304               const svn_diff_fns_t *vtable,
305               apr_pool_t *pool)
306 {
307   svn_diff_fns2_t *diff_fns2;
308   struct fns_wrapper_baton *fwb;
309
310   wrap_diff_fns(&diff_fns2, &fwb, vtable, diff_baton, pool);
311   return svn_diff_diff_2(diff, fwb, diff_fns2, pool);
312 }
313
314
315 /*** From diff3.c ***/
316 svn_error_t *
317 svn_diff_diff3(svn_diff_t **diff,
318                void *diff_baton,
319                const svn_diff_fns_t *vtable,
320                apr_pool_t *pool)
321 {
322   svn_diff_fns2_t *diff_fns2;
323   struct fns_wrapper_baton *fwb;
324
325   wrap_diff_fns(&diff_fns2, &fwb, vtable, diff_baton, pool);
326   return svn_diff_diff3_2(diff, fwb, diff_fns2, pool);
327 }
328
329
330 /*** From diff4.c ***/
331 svn_error_t *
332 svn_diff_diff4(svn_diff_t **diff,
333                void *diff_baton,
334                const svn_diff_fns_t *vtable,
335                apr_pool_t *pool)
336 {
337   svn_diff_fns2_t *diff_fns2;
338   struct fns_wrapper_baton *fwb;
339
340   wrap_diff_fns(&diff_fns2, &fwb, vtable, diff_baton, pool);
341   return svn_diff_diff4_2(diff, fwb, diff_fns2, pool);
342 }
343
344 /*** From util.c ***/
345 svn_error_t *
346 svn_diff_output(svn_diff_t *diff,
347                 void *output_baton,
348                 const svn_diff_output_fns_t *output_fns)
349 {
350   return svn_error_trace(svn_diff_output2(diff, output_baton, output_fns,
351                                           NULL, NULL /* cancel */));
352 }
353
354 /*** From diff_memory.c ***/
355 svn_error_t *
356 svn_diff_mem_string_output_merge(svn_stream_t *output_stream,
357                                  svn_diff_t *diff,
358                                  const svn_string_t *original,
359                                  const svn_string_t *modified,
360                                  const svn_string_t *latest,
361                                  const char *conflict_original,
362                                  const char *conflict_modified,
363                                  const char *conflict_latest,
364                                  const char *conflict_separator,
365                                  svn_boolean_t display_original_in_conflict,
366                                  svn_boolean_t display_resolved_conflicts,
367                                  apr_pool_t *pool)
368 {
369   svn_diff_conflict_display_style_t style =
370     svn_diff_conflict_display_modified_latest;
371
372   if (display_resolved_conflicts)
373     style = svn_diff_conflict_display_resolved_modified_latest;
374
375   if (display_original_in_conflict)
376     style = svn_diff_conflict_display_modified_original_latest;
377
378   return svn_diff_mem_string_output_merge2(output_stream,
379                                            diff,
380                                            original,
381                                            modified,
382                                            latest,
383                                            conflict_original,
384                                            conflict_modified,
385                                            conflict_latest,
386                                            conflict_separator,
387                                            style,
388                                            pool);
389 }
390
391 svn_error_t *
392 svn_diff_mem_string_output_merge2(svn_stream_t *output_stream,
393                                   svn_diff_t *diff,
394                                   const svn_string_t *original,
395                                   const svn_string_t *modified,
396                                   const svn_string_t *latest,
397                                   const char *conflict_original,
398                                   const char *conflict_modified,
399                                   const char *conflict_latest,
400                                   const char *conflict_separator,
401                                   svn_diff_conflict_display_style_t style,
402                                   apr_pool_t *pool)
403 {
404   return svn_error_trace(svn_diff_mem_string_output_merge3(output_stream, diff,
405                                                            original,
406                                                            modified, latest,
407                                                            conflict_original,
408                                                            conflict_modified,
409                                                            conflict_latest,
410                                                            conflict_separator,
411                                                            style,
412                                                            /* no cancelation */
413                                                            NULL, NULL,
414                                                            pool));
415 }
416
417 svn_error_t *
418 svn_diff_mem_string_output_unified(svn_stream_t *output_stream,
419                                    svn_diff_t *diff,
420                                    const char *original_header,
421                                    const char *modified_header,
422                                    const char *header_encoding,
423                                    const svn_string_t *original,
424                                    const svn_string_t *modified,
425                                    apr_pool_t *pool)
426 {
427   return svn_error_trace(svn_diff_mem_string_output_unified2(output_stream,
428                                                              diff,
429                                                              TRUE,
430                                                              NULL,
431                                                              original_header,
432                                                              modified_header,
433                                                              header_encoding,
434                                                              original,
435                                                              modified,
436                                                              pool));
437 }
438
439 svn_error_t *
440 svn_diff_mem_string_output_unified2(svn_stream_t *output_stream,
441                                     svn_diff_t *diff,
442                                     svn_boolean_t with_diff_header,
443                                     const char *hunk_delimiter,
444                                     const char *original_header,
445                                     const char *modified_header,
446                                     const char *header_encoding,
447                                     const svn_string_t *original,
448                                     const svn_string_t *modified,
449                                     apr_pool_t *pool)
450 {
451   return svn_error_trace(svn_diff_mem_string_output_unified3(output_stream,
452                                                              diff,
453                                                              with_diff_header,
454                                                              hunk_delimiter,
455                                                              original_header,
456                                                              modified_header,
457                                                              header_encoding,
458                                                              original,
459                                                              modified,
460                                                              -1 /* context */,
461                                                              /* cancel */
462                                                              NULL, NULL,
463                                                              pool));
464 }