deprecated.c revision 362181
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/* We define this here to remove any further warnings about the usage of 26 deprecated functions in this file. */ 27#define SVN_DEPRECATED 28 29#include "svn_delta.h" 30#include "svn_sorts.h" 31 32 33struct path_driver_2_to_3_baton_t 34{ 35 svn_delta_path_driver_cb_func_t callback_func; 36 void *callback_baton; 37 svn_boolean_t slash_prefix; 38}; 39 40/* Convert from a newer to older callback 41 */ 42static svn_error_t * 43path_driver_2_to_3_func(void **dir_baton, 44 const svn_delta_editor_t *editor, 45 void *edit_baton, 46 void *parent_baton, 47 void *callback_baton, 48 const char *path, 49 apr_pool_t *pool) 50{ 51 struct path_driver_2_to_3_baton_t *b = callback_baton; 52 53 if (b->slash_prefix) 54 path = apr_pstrcat(pool, "/", path, SVN_VA_NULL); 55 56 /* Just drop the 'editor' parameters */ 57 SVN_ERR(b->callback_func(dir_baton, parent_baton, 58 b->callback_baton, 59 path, pool)); 60 return SVN_NO_ERROR; 61} 62 63svn_error_t * 64svn_delta_path_driver2(const svn_delta_editor_t *editor, 65 void *edit_baton, 66 const apr_array_header_t *paths, 67 svn_boolean_t sort_paths, 68 svn_delta_path_driver_cb_func_t callback_func, 69 void *callback_baton, 70 apr_pool_t *pool) 71{ 72 struct path_driver_2_to_3_baton_t b; 73 int i; 74 75 b.callback_func = callback_func; 76 b.callback_baton = callback_baton; 77 b.slash_prefix = FALSE; 78 79 /* Remove any '/' prefix from incoming paths. Arrange to add a '/' 80 prefix to all paths for the callback, if any incoming path had one. */ 81 for (i = 0; i < paths->nelts; i++) 82 { 83 const char *path = APR_ARRAY_IDX(paths, i, const char *); 84 85 if (path[0] == '/') 86 { 87 /* Re-allocate the array and note that we found a '/' prefix. */ 88 if (!b.slash_prefix) 89 { 90 paths = apr_array_copy(pool, paths); 91 b.slash_prefix = TRUE; 92 } 93 94 /* Modify each array element that had a '/' prefix */ 95 APR_ARRAY_IDX(paths, i, const char *) = path + 1; 96 } 97 } 98 99 SVN_ERR(svn_delta_path_driver3(editor, edit_baton, 100 paths, sort_paths, 101 path_driver_2_to_3_func, &b, 102 pool)); 103 return SVN_NO_ERROR; 104} 105 106svn_error_t * 107svn_delta_path_driver(const svn_delta_editor_t *editor, 108 void *edit_baton, 109 svn_revnum_t revision, 110 const apr_array_header_t *paths, 111 svn_delta_path_driver_cb_func_t callback_func, 112 void *callback_baton, 113 apr_pool_t *scratch_pool) 114{ 115 /* REVISION is dropped on the floor. */ 116 117 return svn_error_trace(svn_delta_path_driver2(editor, edit_baton, paths, 118 TRUE, 119 callback_func, callback_baton, 120 scratch_pool)); 121} 122