]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/subversion/subversion/svnrdump/util.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / subversion / subversion / svnrdump / util.c
1 /*
2  *  util.c: A few utility functions.
3  *
4  * ====================================================================
5  *    Licensed to the Apache Software Foundation (ASF) under one
6  *    or more contributor license agreements.  See the NOTICE file
7  *    distributed with this work for additional information
8  *    regarding copyright ownership.  The ASF licenses this file
9  *    to you under the Apache License, Version 2.0 (the
10  *    "License"); you may not use this file except in compliance
11  *    with the License.  You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  *    Unless required by applicable law or agreed to in writing,
16  *    software distributed under the License is distributed on an
17  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18  *    KIND, either express or implied.  See the License for the
19  *    specific language governing permissions and limitations
20  *    under the License.
21  * ====================================================================
22  */
23
24 #include "svn_error.h"
25 #include "svn_pools.h"
26 #include "svn_string.h"
27 #include "svn_props.h"
28 #include "svn_subst.h"
29
30 #include "svnrdump.h"
31
32 \f
33 svn_error_t *
34 svn_rdump__normalize_prop(const char *name,
35                           const svn_string_t **value,
36                           apr_pool_t *result_pool)
37 {
38   if (svn_prop_needs_translation(name))
39     {
40       const char *cstring;
41
42       SVN_ERR(svn_subst_translate_cstring2((*value)->data, &cstring,
43                                            "\n", TRUE,
44                                            NULL, FALSE,
45                                            result_pool));
46
47       *value = svn_string_create(cstring, result_pool);
48     }
49   return SVN_NO_ERROR;
50 }
51
52 svn_error_t *
53 svn_rdump__normalize_props(apr_hash_t **normal_props,
54                            apr_hash_t *props,
55                            apr_pool_t *result_pool)
56 {
57   apr_hash_index_t *hi;
58
59   *normal_props = apr_hash_make(result_pool);
60
61   for (hi = apr_hash_first(result_pool, props); hi;
62         hi = apr_hash_next(hi))
63     {
64       const char *key = svn__apr_hash_index_key(hi);
65       const svn_string_t *value = svn__apr_hash_index_val(hi);
66
67       SVN_ERR(svn_rdump__normalize_prop(key, &value,
68                                         result_pool));
69
70       svn_hash_sets(*normal_props, key, value);
71     }
72   return SVN_NO_ERROR;
73 }