2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file libprivilege-control_test_duplicates.cpp
19 * @author Lukasz Wojciechowski (l.wojciechow@partner.samsung.com)
21 * @brief libprivilege-control private functions duplicates
29 #include <sys/smack.h>
34 #include "duplicates.h"
36 std::string app_type_name(app_type_t app_type)
51 std::string app_type_group_name(app_type_t app_type)
68 * This function changes permission URI to basename for file name.
69 * For e.g. from http://tizen.org/privilege/contact.read will be
70 * created basename : org.tizen.privilege.contact.read
72 int base_name_from_perm(const char *perm, std::string& name)
74 iri_t *iris = iri_parse(perm);
75 if (iris == nullptr || iris->host == nullptr)
78 return PC_ERR_INVALID_PARAM;
84 std::string::size_type pos;
86 if (iris->path == nullptr)
94 pos = host.rfind('.');
95 if (pos != std::string::npos)
97 host_dot = host.substr(pos + 1) + ".";
98 host = host.substr(0, pos);
104 std::replace(path.begin(), path.end(), '/', '.');
106 name = host_dot + host + path;
108 return PC_OPERATION_SUCCESS;