2 This file is part of systemd.
4 Copyright 2014 Daniel Mack
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 #include "bus-endpoint.h"
24 int bus_endpoint_new(BusEndpoint **ep)
28 *ep = new0(BusEndpoint, 1);
35 int bus_endpoint_add_policy(BusEndpoint *ep, const char *name, BusPolicyAccess access)
37 _cleanup_free_ BusEndpointPolicy *po;
38 _cleanup_free_ char *key;
43 assert(access > _BUS_POLICY_ACCESS_INVALID && access < _BUS_POLICY_ACCESS_MAX);
45 /* check if we already have this name in the policy list. If we do, see if the new access level
46 * is higher than the exising one, and upgrade the entry in that case. Otherwise, do nothing.
49 if (ep->policy_hash) {
50 po = hashmap_get(ep->policy_hash, name);
52 if (po->access < access)
58 ep->policy_hash = hashmap_new(&string_hash_ops);
63 po = new0(BusEndpointPolicy, 1);
74 r = hashmap_put(ep->policy_hash, key, po);
83 void bus_endpoint_free(BusEndpoint *endpoint)
88 hashmap_free_free_free(endpoint->policy_hash);