1251881Speter/* 2251881Speter * util.c: A few utility functions. 3251881Speter * 4251881Speter * ==================================================================== 5251881Speter * Licensed to the Apache Software Foundation (ASF) under one 6251881Speter * or more contributor license agreements. See the NOTICE file 7251881Speter * distributed with this work for additional information 8251881Speter * regarding copyright ownership. The ASF licenses this file 9251881Speter * to you under the Apache License, Version 2.0 (the 10251881Speter * "License"); you may not use this file except in compliance 11251881Speter * with the License. You may obtain a copy of the License at 12251881Speter * 13251881Speter * http://www.apache.org/licenses/LICENSE-2.0 14251881Speter * 15251881Speter * Unless required by applicable law or agreed to in writing, 16251881Speter * software distributed under the License is distributed on an 17251881Speter * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18251881Speter * KIND, either express or implied. See the License for the 19251881Speter * specific language governing permissions and limitations 20251881Speter * under the License. 21251881Speter * ==================================================================== 22251881Speter */ 23251881Speter 24251881Speter#include "svn_error.h" 25251881Speter#include "svn_pools.h" 26251881Speter#include "svn_string.h" 27251881Speter#include "svn_props.h" 28251881Speter#include "svn_subst.h" 29251881Speter 30251881Speter#include "svnrdump.h" 31251881Speter 32251881Speter 33251881Spetersvn_error_t * 34251881Spetersvn_rdump__normalize_prop(const char *name, 35251881Speter const svn_string_t **value, 36251881Speter apr_pool_t *result_pool) 37251881Speter{ 38251881Speter if (svn_prop_needs_translation(name)) 39251881Speter { 40251881Speter const char *cstring; 41251881Speter 42251881Speter SVN_ERR(svn_subst_translate_cstring2((*value)->data, &cstring, 43251881Speter "\n", TRUE, 44251881Speter NULL, FALSE, 45251881Speter result_pool)); 46251881Speter 47251881Speter *value = svn_string_create(cstring, result_pool); 48251881Speter } 49251881Speter return SVN_NO_ERROR; 50251881Speter} 51251881Speter 52251881Spetersvn_error_t * 53251881Spetersvn_rdump__normalize_props(apr_hash_t **normal_props, 54251881Speter apr_hash_t *props, 55251881Speter apr_pool_t *result_pool) 56251881Speter{ 57251881Speter apr_hash_index_t *hi; 58251881Speter 59251881Speter *normal_props = apr_hash_make(result_pool); 60251881Speter 61251881Speter for (hi = apr_hash_first(result_pool, props); hi; 62251881Speter hi = apr_hash_next(hi)) 63251881Speter { 64251881Speter const char *key = svn__apr_hash_index_key(hi); 65251881Speter const svn_string_t *value = svn__apr_hash_index_val(hi); 66251881Speter 67251881Speter SVN_ERR(svn_rdump__normalize_prop(key, &value, 68251881Speter result_pool)); 69251881Speter 70251881Speter svn_hash_sets(*normal_props, key, value); 71251881Speter } 72251881Speter return SVN_NO_ERROR; 73251881Speter} 74